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

http2 working nghttp fetch multi files completely

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2014-10-18 18:54:04 +08:00
parent 200f385716
commit b0e2e50c75
4 changed files with 27 additions and 4 deletions

View file

@ -668,6 +668,9 @@ int lws_add_http2_header_status(struct libwebsocket_context *context,
unsigned char status[10];
int n;
if (code >= 400)
wsi->u.http2.END_STREAM = 1;
n = sprintf((char *)status, "%u", code);
if (lws_add_http2_header_by_token(context, wsi, WSI_TOKEN_HTTP_COLON_STATUS, status, n, p, end))
return 1;

View file

@ -344,6 +344,7 @@ update_end_headers:
int lws_http2_do_pps_send(struct libwebsocket_context *context, struct libwebsocket *wsi)
{
unsigned char settings[LWS_SEND_BUFFER_PRE_PADDING + 6 * LWS_HTTP2_SETTINGS__COUNT];
struct libwebsocket *swsi;
int n, m = 0;
switch (wsi->pps) {
@ -376,8 +377,27 @@ int lws_http2_do_pps_send(struct libwebsocket_context *context, struct libwebsoc
wsi->state = WSI_STATE_HTTP2_ESTABLISHED;
wsi->u.http.fd = LWS_INVALID_FILE;
return 0;
/*
* we need to treat the headers from this upgrade
* as the first job. These need to get
* shifted to stream ID 1
*/
lwsl_info("%s: setting up sid 1\n", __func__);
swsi = wsi->u.http2.stream_wsi = lws_create_server_child_wsi(context, wsi, 1);
/* pass on the initial headers to SID 1 */
swsi->u.http.ah = wsi->u.http.ah;
wsi->u.http.ah = NULL;
lwsl_info("%s: inherited headers %p\n", __func__, swsi->u.http.ah);
swsi->u.http2.tx_credit = wsi->u.http2.peer_settings.setting[LWS_HTTP2_SETTINGS__INITIAL_WINDOW_SIZE];
lwsl_info("initial tx credit on conn %p: %d\n", swsi, swsi->u.http2.tx_credit);
swsi->u.http2.initialized = 1;
/* demanded by HTTP2 */
swsi->u.http2.END_STREAM = 1;
lwsl_info("servicing initial http request\n");
return lws_http_action(context, swsi);
}
break;
default:

View file

@ -456,7 +456,7 @@ send_raw:
}
}
if (protocol == LWS_WRITE_HTTP_FINAL && wsi->u.http2.END_STREAM) {
if ((protocol == LWS_WRITE_HTTP_FINAL || protocol == LWS_WRITE_HTTP_HEADERS) && wsi->u.http2.END_STREAM) {
lwsl_info("%s: setting END_STREAM\n", __func__);
flags |= LWS_HTTP2_FLAG_END_STREAM;
}

View file

@ -72,7 +72,7 @@ lws_context_init_http2_ssl(struct libwebsocket_context *context)
SSL_CTX_set_alpn_select_cb(context->ssl_ctx, alpn_select_proto_cb, NULL);
lwsl_notice(" HTTP2 / ALPN enabled\n");
#else
lwsl_notice(" HTTP2 / ALPN configured but not supported by OpenSSL version\n");
lwsl_notice(" HTTP2 / ALPN configured but not supported by OpenSSL version 0x%x\n", OPENSSL_VERSION_NUMBER);
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
}