From 49c2d8a63502a665291ba8ddd62667fdae2547ba Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Sat, 26 Feb 2022 15:24:17 +0800 Subject: [PATCH] net: http: Rename body_start to body_frag_start Following #42026, the body_start pointer now points to the start of the body fragment in the recv_buffer as long as there is body in it, either entirely or partially. Rename the body_start to body_frag_start to better reflect what it represents. Signed-off-by: Yong Cong Sin --- include/net/http_client.h | 4 ++-- subsys/mgmt/hawkbit/hawkbit.c | 18 +++++++++--------- subsys/net/lib/http/http_client.c | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/net/http_client.h b/include/net/http_client.h index d595dba0f72..504fe2b3b70 100644 --- a/include/net/http_client.h +++ b/include/net/http_client.h @@ -106,8 +106,8 @@ struct http_response { */ http_response_cb_t cb; - /** Where the body starts */ - uint8_t *body_start; + /** Start address of the body fragment contained in the recv_buf */ + uint8_t *body_frag_start; /** Where the response is stored, this is to be * provided by the user. diff --git a/subsys/mgmt/hawkbit/hawkbit.c b/subsys/mgmt/hawkbit/hawkbit.c index 47fd821d9ea..f3ab718be00 100644 --- a/subsys/mgmt/hawkbit/hawkbit.c +++ b/subsys/mgmt/hawkbit/hawkbit.c @@ -691,19 +691,19 @@ static void response_cb(struct http_response *rsp, switch (type) { case HAWKBIT_PROBE: if (hb_context.dl.http_content_size == 0) { - body_data = rsp->body_start; + body_data = rsp->body_frag_start; body_len = rsp->data_len; /* * subtract the size of the HTTP header from body_len */ - body_len -= (rsp->body_start - rsp->recv_buf); + body_len -= (rsp->body_frag_start - rsp->recv_buf); hb_context.dl.http_content_size = rsp->content_length; } else { /* * more general case where body data is set, but no need * to take the HTTP header into account */ - body_data = rsp->body_start; + body_data = rsp->body_frag_start; body_len = rsp->data_len; } @@ -765,19 +765,19 @@ static void response_cb(struct http_response *rsp, case HAWKBIT_PROBE_DEPLOYMENT_BASE: if (hb_context.dl.http_content_size == 0) { - body_data = rsp->body_start; + body_data = rsp->body_frag_start; body_len = rsp->data_len; /* * subtract the size of the HTTP header from body_len */ - body_len -= (rsp->body_start - rsp->recv_buf); + body_len -= (rsp->body_frag_start - rsp->recv_buf); hb_context.dl.http_content_size = rsp->content_length; } else { /* * more general case where body data is set, but no need * to take the HTTP header into account */ - body_data = rsp->body_start; + body_data = rsp->body_frag_start; body_len = rsp->data_len; } @@ -828,19 +828,19 @@ static void response_cb(struct http_response *rsp, case HAWKBIT_DOWNLOAD: if (hb_context.dl.http_content_size == 0) { - body_data = rsp->body_start; + body_data = rsp->body_frag_start; body_len = rsp->data_len; /* * subtract the size of the HTTP header from body_len */ - body_len -= (rsp->body_start - rsp->recv_buf); + body_len -= (rsp->body_frag_start - rsp->recv_buf); hb_context.dl.http_content_size = rsp->content_length; } else { /* * more general case where body data is set, but no need * to take the HTTP header into account */ - body_data = rsp->body_start; + body_data = rsp->body_frag_start; body_len = rsp->data_len; } diff --git a/subsys/net/lib/http/http_client.c b/subsys/net/lib/http/http_client.c index d02f2393169..d42a3badd88 100644 --- a/subsys/net/lib/http/http_client.c +++ b/subsys/net/lib/http/http_client.c @@ -264,9 +264,9 @@ static int on_body(struct http_parser *parser, const char *at, size_t length) req->internal.response.http_cb->on_body(parser, at, length); } - /* Reset the body_start pointer for each fragment. */ - if (!req->internal.response.body_start) { - req->internal.response.body_start = (uint8_t *)at; + /* Reset the body_frag_start pointer for each fragment. */ + if (!req->internal.response.body_frag_start) { + req->internal.response.body_frag_start = (uint8_t *)at; } return 0; @@ -406,7 +406,7 @@ static int http_wait_data(int sock, struct http_request *req) req->internal.response.processed = 0; req->internal.response.data_len = 0; req->internal.response.content_length = 0; - req->internal.response.body_start = NULL; + req->internal.response.body_frag_start = NULL; memset(req->internal.response.http_status, 0, HTTP_STATUS_STR_SIZE); @@ -463,7 +463,7 @@ static int http_wait_data(int sock, struct http_request *req) /* Re-use the result buffer and start to fill it again */ req->internal.response.data_len = 0; - req->internal.response.body_start = NULL; + req->internal.response.body_frag_start = NULL; } }