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;
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) {
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:
}
}
- 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;
}
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
}