mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
h2: post: http_action: issue _HTTP and consume deferred body when resuming
When we have to defer http_action for a stream because we may not have any writeability, we stash any incoming body on the rx buflist for the wsi which is good. But when we resume under some conditions, we don't issue the _HTTP cb and don't drain the stashed body. It's cleaned out in the close flow, but it's broken. This makes the deferred resume flow do the right thing under those conditions.
This commit is contained in:
parent
5af65114c9
commit
c48bebc9ae
1 changed files with 23 additions and 0 deletions
|
@ -767,7 +767,9 @@ rops_callback_on_writable_h2(struct lws *wsi)
|
|||
static int
|
||||
lws_h2_bind_for_post_before_action(struct lws *wsi)
|
||||
{
|
||||
uint8_t *buffered;
|
||||
const char *p;
|
||||
size_t blen;
|
||||
|
||||
p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD);
|
||||
if (p && !strcmp(p, "POST")) {
|
||||
|
@ -808,9 +810,30 @@ lws_h2_bind_for_post_before_action(struct lws *wsi)
|
|||
return 1;
|
||||
}
|
||||
|
||||
{
|
||||
int uri_len = 0;
|
||||
char *uri_ptr = NULL;
|
||||
|
||||
if (lws_http_get_uri_and_method(wsi, &uri_ptr, &uri_len) >= 0)
|
||||
wsi->a.protocol->callback(wsi, LWS_CALLBACK_HTTP,
|
||||
wsi->user_space, uri_ptr, (size_t)uri_len);
|
||||
}
|
||||
|
||||
lwsl_info("%s: setting LRS_BODY from 0x%x (%s)\n", __func__,
|
||||
(int)wsi->wsistate, wsi->a.protocol->name);
|
||||
|
||||
lwsi_set_state(wsi, LRS_BODY);
|
||||
|
||||
/*
|
||||
* Dump any stashed body
|
||||
*/
|
||||
|
||||
while ((blen = lws_buflist_next_segment_len(&wsi->buflist, &buffered))) {
|
||||
if (wsi->a.protocol->callback(wsi, LWS_CALLBACK_HTTP_BODY,
|
||||
wsi->user_space, buffered, blen))
|
||||
return 1;
|
||||
lws_buflist_use_segment(&wsi->buflist, blen);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue