mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
server: http-proxy: fix POST
This commit is contained in:
parent
e49a5f3698
commit
5b8a597c1d
3 changed files with 27 additions and 19 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue