1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

h2: client: handle END_STREAM and END_HEADERS togther on all paths

This commit is contained in:
Yichen Gu 2021-01-28 19:32:11 +00:00 committed by Andy Green
parent cfe4fa1551
commit 403a6591e1
2 changed files with 25 additions and 23 deletions

View file

@ -1641,6 +1641,27 @@ lws_h2_parse_end_of_frame(struct lws *wsi)
}
#if defined(LWS_WITH_CLIENT)
/*
* If we already had the END_STREAM along with the END_HEADERS,
* we have already transitioned to STATE_CLOSED and we are not
* going to be doing anything further on this stream.
*
* In that case handle the transaction completion and
* finalize the stream for the peer
*/
if (h2n->swsi->h2.h2_state == LWS_H2_STATE_CLOSED &&
h2n->swsi->client_mux_substream) {
lws_h2_rst_stream(h2n->swsi, H2_ERR_NO_ERROR,
"client done");
if (lws_http_transaction_completed_client(h2n->swsi))
lwsl_debug("tx completed returned close\n");
break;
}
if (h2n->swsi->client_mux_substream) {
lwsl_info("%s: %s: headers: client path (h2 state %s)\n",
__func__, lws_wsi_tag(wsi),
@ -1692,27 +1713,6 @@ lws_h2_parse_end_of_frame(struct lws *wsi)
break;
}
#if defined(LWS_WITH_CLIENT)
/*
* If we already had the END_STREAM along with the END_HEADERS,
* we have already transitioned to STATE_CLOSED and we are not
* going to be doing anything further on this stream.
*
* In that case handle the transaction completion and
* finalize the stream for the peer
*/
if (h2n->swsi->h2.h2_state == LWS_H2_STATE_CLOSED &&
h2n->swsi->client_mux_substream) {
lws_h2_rst_stream(h2n->swsi, H2_ERR_NO_ERROR,
"client done");
if (lws_http_transaction_completed_client(h2n->swsi))
lwsl_debug("tx completed returned close\n");
} else
#endif
{
lwsl_debug("%s: setting DEF_ACT from 0x%x\n", __func__,
(unsigned int)h2n->swsi->wsistate);

View file

@ -933,10 +933,12 @@ lws_client_interpret_server_handshake(struct lws *wsi)
/*
* Did we get a response from the server with an explicit
* content-length of zero? If so, this transaction is already
* content-length of zero? If so, and it's not H2 which will
* notice it via END_STREAM, this transaction is already
* completed at the end of the header processing...
*/
if (lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_CONTENT_LENGTH) &&
if (!wsi->mux_substream && !wsi->client_mux_substream &&
lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_CONTENT_LENGTH) &&
!wsi->http.rx_content_length)
return !!lws_http_transaction_completed_client(wsi);