Skip to content

Commit 09a7259

Browse files
committed
net: http: Added packet timeout to http client (#174)
Added timeout for individual packets to the HTTP client code. Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
1 parent d4c9a99 commit 09a7259

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/zephyr/net/http/client.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ struct http_request {
253253
/** The HTTP protocol, for example "HTTP/1.1" */
254254
const char *protocol;
255255

256+
/** Max timeout to wait for data receipt, 0 to disable. Value in
257+
* milliseconds
258+
*/
259+
uint32_t packet_timeout;
260+
256261
/** The HTTP header fields (application specific)
257262
* The Content-Type may be specified here or in the next field.
258263
* Depending on your application, the Content-Type may vary, however

subsys/net/lib/http/http_client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ static int http_wait_data(int sock, struct http_request *req, int32_t timeout)
435435
}
436436
}
437437

438-
ret = zsock_poll(fds, nfds, remaining_time);
438+
ret = zsock_poll(fds, nfds,
439+
req->packet_timeout ?
440+
MIN(req->packet_timeout, remaining_time) :
441+
remaining_time);
439442
if (ret == 0) {
440443
LOG_DBG("Timeout");
441444
goto finalize_data;

0 commit comments

Comments
 (0)