net: http: Calculate body_frag_len
Calculate the body_frag_length if any part of the body is found in the http response. Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit is contained in:
parent
49c2d8a635
commit
ce3e1e7e29
2 changed files with 36 additions and 0 deletions
|
@ -269,6 +269,10 @@ static int on_body(struct http_parser *parser, const char *at, size_t length)
|
|||
req->internal.response.body_frag_start = (uint8_t *)at;
|
||||
}
|
||||
|
||||
/* Calculate the length of the body contained in the recv_buf */
|
||||
req->internal.response.body_frag_len = req->internal.response.data_len -
|
||||
(req->internal.response.body_frag_start - req->internal.response.recv_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -464,6 +468,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_frag_start = NULL;
|
||||
req->internal.response.body_frag_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue