net: http: honor CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT setting
We should not use the user suppied timeout setting in
http_client_send_req() for the connection timeout. In the
previous API the call to tcp_connect() used
CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT as the timeout setting.
Let's do that here too.
This fixes -ETIMEDOUT error generation when using K_NO_WAIT
for http_client_send_req().
NOTE: This patch was previously applied but was lost when
commit d1675bf3e6
("net: http: Remove the old legacy API")
moved code around.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
This commit is contained in:
parent
a2dfaebafc
commit
fcb5e2b1ee
1 changed files with 5 additions and 2 deletions
|
@ -38,6 +38,9 @@
|
||||||
#define HTTP_CONTENT_LEN "Content-Length"
|
#define HTTP_CONTENT_LEN "Content-Length"
|
||||||
#define HTTP_CONT_LEN_SIZE 6
|
#define HTTP_CONT_LEN_SIZE 6
|
||||||
|
|
||||||
|
/* Default network activity timeout in seconds */
|
||||||
|
#define HTTP_NETWORK_TIMEOUT K_SECONDS(CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT)
|
||||||
|
|
||||||
int client_reset(struct http_ctx *ctx)
|
int client_reset(struct http_ctx *ctx)
|
||||||
{
|
{
|
||||||
http_parser_init(&ctx->http.parser, HTTP_RESPONSE);
|
http_parser_init(&ctx->http.parser, HTTP_RESPONSE);
|
||||||
|
@ -235,7 +238,7 @@ int http_client_send_req(struct http_ctx *ctx,
|
||||||
|
|
||||||
ctx->http.rsp.cb = cb;
|
ctx->http.rsp.cb = cb;
|
||||||
|
|
||||||
ret = net_app_connect(&ctx->app_ctx, timeout);
|
ret = net_app_connect(&ctx->app_ctx, HTTP_NETWORK_TIMEOUT);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
NET_DBG("Cannot connect to server (%d)", ret);
|
NET_DBG("Cannot connect to server (%d)", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -244,7 +247,7 @@ int http_client_send_req(struct http_ctx *ctx,
|
||||||
/* We might wait longer than timeout if the first connection
|
/* We might wait longer than timeout if the first connection
|
||||||
* establishment takes long time (like with HTTPS)
|
* establishment takes long time (like with HTTPS)
|
||||||
*/
|
*/
|
||||||
if (k_sem_take(&ctx->http.connect_wait, timeout)) {
|
if (k_sem_take(&ctx->http.connect_wait, HTTP_NETWORK_TIMEOUT)) {
|
||||||
NET_DBG("Connection timed out");
|
NET_DBG("Connection timed out");
|
||||||
ret = -ETIMEDOUT;
|
ret = -ETIMEDOUT;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue