diff options
author | Andy Green <andy@warmcat.com> | 2021-08-13 21:16:24 +0100 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2021-08-19 05:31:15 +0100 |
commit | 5b8a597c1dd45cc3cd723a0f607c4b783ab896fa (patch) | |
tree | 6843a386d53517602db30e32f7b0e9a3cbfa439b /lib/roles/h1 | |
parent | e49a5f3698c24dc50c836b3bf30443dcf47d850f (diff) | |
download | libwebsockets-5b8a597c1dd45cc3cd723a0f607c4b783ab896fa.tar.gz |
server: http-proxy: fix POST
Diffstat (limited to 'lib/roles/h1')
-rw-r--r-- | lib/roles/h1/ops-h1.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c index 6a22df83..1b5ea665 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 { + 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; + /* 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; + 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); - } + 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; |