diff --git a/lib/core-net/dummy-callback.c b/lib/core-net/dummy-callback.c index 86be0b546..9552af5ac 100644 --- a/lib/core-net/dummy-callback.c +++ b/lib/core-net/dummy-callback.c @@ -296,6 +296,7 @@ lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason, if (wsi->child_list) { lwsl_wsi_info(wsi, "HTTP_BODY_COMPLETION: %d", (int)len); + lws_callback_on_writable(wsi->child_list); break; } #endif @@ -317,6 +318,7 @@ lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason, if (lws_buflist_append_segment( &wsi->http.buflist_post_body, in, len) < 0) return -1; + lws_client_http_body_pending(wsi->child_list, 1); lws_callback_on_writable(wsi->child_list); } break; diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c index 6a22df835..1b5ea6653 100644 --- a/lib/roles/h1/ops-h1.c +++ b/lib/roles/h1/ops-h1.c @@ -710,7 +710,9 @@ static int rops_handle_POLLOUT_h1(struct lws *wsi) { - if (lwsi_state(wsi) == LRS_ISSUE_HTTP_BODY) { + + if (lwsi_state(wsi) == LRS_ISSUE_HTTP_BODY || + lwsi_state(wsi) == LRS_WAITING_SERVER_REPLY) { #if defined(LWS_WITH_HTTP_PROXY) if (wsi->http.proxy_clientside) { unsigned char *buf, prebuf[LWS_PRE + 1024]; @@ -722,7 +724,6 @@ rops_handle_POLLOUT_h1(struct lws *wsi) len = sizeof(prebuf) - LWS_PRE; if (len) { - memcpy(prebuf + LWS_PRE, buf, len); lwsl_debug("%s: %s: proxying body %d %d %d %d %d\n", @@ -741,23 +742,28 @@ rops_handle_POLLOUT_h1(struct lws *wsi) } lws_buflist_use_segment(&wsi->parent->http.buflist_post_body, len); + } - if (wsi->parent->http.buflist_post_body) + if (wsi->parent->http.buflist_post_body) { lws_callback_on_writable(wsi); - else { -#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) - /* prepare ourselves to do the parsing */ - wsi->http.ah->parser_state = WSI_TOKEN_NAME_PART; - wsi->http.ah->lextable_pos = 0; -#if defined(LWS_WITH_CUSTOM_HEADERS) - wsi->http.ah->unk_pos = 0; -#endif -#endif - lwsi_set_state(wsi, LRS_WAITING_SERVER_REPLY); - lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE, - (int)wsi->a.context->timeout_secs); + return LWS_HP_RET_DROP_POLLOUT; } + + lwsl_wsi_err(wsi, "nothing to send"); +#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) + /* prepare ourselves to do the parsing */ + wsi->http.ah->parser_state = WSI_TOKEN_NAME_PART; + wsi->http.ah->lextable_pos = 0; +#if defined(LWS_WITH_CUSTOM_HEADERS) + wsi->http.ah->unk_pos = 0; +#endif +#endif + lwsi_set_state(wsi, LRS_WAITING_SERVER_REPLY); + lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE, + (int)wsi->a.context->timeout_secs); + + return LWS_HP_RET_DROP_POLLOUT; } #endif return LWS_HP_RET_USER_SERVICE; diff --git a/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index 4014eed85..77191e85c 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -302,7 +302,8 @@ hs2: if (wsi->flags & LCCSCF_HTTP_X_WWW_FORM_URLENCODED) lws_callback_on_writable(wsi); #if defined(LWS_WITH_HTTP_PROXY) - if (wsi->http.proxy_clientside) + if (wsi->http.proxy_clientside && wsi->parent && + wsi->parent->http.buflist_post_body) lws_callback_on_writable(wsi); #endif /* user code must ask for writable callback */ @@ -333,10 +334,9 @@ hs2: case LRS_ISSUE_HTTP_BODY: #if defined(LWS_WITH_HTTP_PROXY) - if (wsi->http.proxy_clientside) { + if (wsi->http.proxy_clientside && wsi->parent && + wsi->parent->http.buflist_post_body) lws_callback_on_writable(wsi); - break; - } #endif if (wsi->client_http_body_pending || lws_has_buffered_out(wsi)) { //lws_set_timeout(wsi,