mgmt: hawkbit: Fix case where body_data not set correctly
When downloading large files from the hawkbit server the only time rsp->body_start is checked is on the first call. After this it is never checked again. This caused the wrong data to be written to flash and a failed update. Signed-off-by: Joep Buruma <burumaj50@gmail.com>
This commit is contained in:
parent
6cb1e22fd4
commit
e45c07cd60
1 changed files with 10 additions and 0 deletions
|
@ -795,8 +795,18 @@ static void response_cb(struct http_response *rsp,
|
||||||
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_start;
|
||||||
body_len = rsp->data_len;
|
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_start - rsp->recv_buf);
|
||||||
hb_context.dl.http_content_size = rsp->content_length;
|
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_len = rsp->data_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rsp->body_found == 1) && (body_data == NULL)) {
|
if ((rsp->body_found == 1) && (body_data == NULL)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue