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 <yongcong.sin@gmail.com>
This commit is contained in:
Yong Cong Sin 2022-02-26 15:24:17 +08:00 committed by Carles Cufí
commit 49c2d8a635
3 changed files with 16 additions and 16 deletions

View file

@ -106,8 +106,8 @@ struct http_response {
*/ */
http_response_cb_t cb; http_response_cb_t cb;
/** Where the body starts */ /** Start address of the body fragment contained in the recv_buf */
uint8_t *body_start; uint8_t *body_frag_start;
/** Where the response is stored, this is to be /** Where the response is stored, this is to be
* provided by the user. * provided by the user.

View file

@ -691,19 +691,19 @@ static void response_cb(struct http_response *rsp,
switch (type) { switch (type) {
case HAWKBIT_PROBE: case HAWKBIT_PROBE:
if (hb_context.dl.http_content_size == 0) { if (hb_context.dl.http_content_size == 0) {
body_data = rsp->body_start; body_data = rsp->body_frag_start;
body_len = rsp->data_len; body_len = rsp->data_len;
/* /*
* subtract the size of the HTTP header from body_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; hb_context.dl.http_content_size = rsp->content_length;
} else { } else {
/* /*
* more general case where body data is set, but no need * more general case where body data is set, but no need
* to take the HTTP header into account * to take the HTTP header into account
*/ */
body_data = rsp->body_start; body_data = rsp->body_frag_start;
body_len = rsp->data_len; body_len = rsp->data_len;
} }
@ -765,19 +765,19 @@ static void response_cb(struct http_response *rsp,
case HAWKBIT_PROBE_DEPLOYMENT_BASE: case HAWKBIT_PROBE_DEPLOYMENT_BASE:
if (hb_context.dl.http_content_size == 0) { if (hb_context.dl.http_content_size == 0) {
body_data = rsp->body_start; body_data = rsp->body_frag_start;
body_len = rsp->data_len; body_len = rsp->data_len;
/* /*
* subtract the size of the HTTP header from body_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; hb_context.dl.http_content_size = rsp->content_length;
} else { } else {
/* /*
* more general case where body data is set, but no need * more general case where body data is set, but no need
* to take the HTTP header into account * to take the HTTP header into account
*/ */
body_data = rsp->body_start; body_data = rsp->body_frag_start;
body_len = rsp->data_len; body_len = rsp->data_len;
} }
@ -828,19 +828,19 @@ static void response_cb(struct http_response *rsp,
case HAWKBIT_DOWNLOAD: case HAWKBIT_DOWNLOAD:
if (hb_context.dl.http_content_size == 0) { if (hb_context.dl.http_content_size == 0) {
body_data = rsp->body_start; body_data = rsp->body_frag_start;
body_len = rsp->data_len; body_len = rsp->data_len;
/* /*
* subtract the size of the HTTP header from body_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; hb_context.dl.http_content_size = rsp->content_length;
} else { } else {
/* /*
* more general case where body data is set, but no need * more general case where body data is set, but no need
* to take the HTTP header into account * to take the HTTP header into account
*/ */
body_data = rsp->body_start; body_data = rsp->body_frag_start;
body_len = rsp->data_len; body_len = rsp->data_len;
} }

View file

@ -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); req->internal.response.http_cb->on_body(parser, at, length);
} }
/* Reset the body_start pointer for each fragment. */ /* Reset the body_frag_start pointer for each fragment. */
if (!req->internal.response.body_start) { if (!req->internal.response.body_frag_start) {
req->internal.response.body_start = (uint8_t *)at; req->internal.response.body_frag_start = (uint8_t *)at;
} }
return 0; 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.processed = 0;
req->internal.response.data_len = 0; req->internal.response.data_len = 0;
req->internal.response.content_length = 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, memset(req->internal.response.http_status, 0,
HTTP_STATUS_STR_SIZE); 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 */ /* Re-use the result buffer and start to fill it again */
req->internal.response.data_len = 0; req->internal.response.data_len = 0;
req->internal.response.body_start = NULL; req->internal.response.body_frag_start = NULL;
} }
} }