Lines Matching defs:wsi

134 void lws_h2_init(struct lws *wsi)
136 wsi->h2.h2n->our_set = wsi->a.vhost->h2.set;
137 wsi->h2.h2n->peer_set = lws_h2_defaults;
141 lws_h2_state(struct lws *wsi, enum lws_h2_states s)
143 if (!wsi)
145 lwsl_info("%s: %s: state %s -> %s\n", __func__, lws_wsi_tag(wsi),
146 h2_state_names[wsi->h2.h2_state],
150 wsi->h2.h2_state = (uint8_t)s;
154 lws_h2_update_peer_txcredit(struct lws *wsi, unsigned int sid, int bump)
156 struct lws *nwsi = lws_get_network_wsi(wsi);
159 assert(wsi);
165 sid = wsi->mux.my_sid;
168 (int)wsi->txc.peer_tx_cr_est + bump);
176 wsi->txc.peer_tx_cr_est += bump;
178 lws_wsi_txc_describe(&wsi->txc, __func__, wsi->mux.my_sid);
180 lws_pps_schedule(wsi, pps);
198 lws_h2_get_peer_txcredit_estimate(struct lws *wsi)
200 lws_wsi_txc_describe(&wsi->txc, __func__, wsi->mux.my_sid);
201 return (int)wsi->txc.peer_tx_cr_est;
205 lws_h2_update_peer_txcredit_thresh(struct lws *wsi, unsigned int sid, int threshold, int bump)
207 if (wsi->txc.peer_tx_cr_est > threshold)
210 return lws_h2_update_peer_txcredit(wsi, sid, bump);
223 struct lws *wsi;
263 wsi = lws_create_new_server_wsi(vh, parent_wsi->tsi, tmp);
264 if (!wsi) {
265 lwsl_notice("new server wsi failed (%s)\n", lws_vh_tag(vh));
271 lws_metrics_caliper_bind(wsi->cal_conn, wsi->a.context->mth_srv);
277 lws_wsi_mux_insert(wsi, parent_wsi, sid);
281 wsi->mux_substream = 1;
282 wsi->seen_nonpseudoheader = 0;
284 wsi->txc.tx_cr = (int32_t)nwsi->h2.h2n->peer_set.s[H2SET_INITIAL_WINDOW_SIZE];
285 wsi->txc.peer_tx_cr_est =
288 lwsi_set_state(wsi, LRS_ESTABLISHED);
289 lwsi_set_role(wsi, lwsi_role(parent_wsi));
291 wsi->a.protocol = &vh->protocols[0];
292 if (lws_ensure_user_space(wsi))
296 if (lws_adopt_ss_server_accept(wsi))
301 lws_validity_confirmed(wsi);
304 lws_wsi_tag(parent_wsi), lws_wsi_tag(wsi), sid, wsi->user_space);
306 lws_wsi_txc_describe(&wsi->txc, __func__, wsi->mux.my_sid);
309 return wsi;
313 parent_wsi->mux.child_list = wsi->mux.sibling_list;
316 if (wsi->user_space)
317 lws_free_set_NULL(wsi->user_space);
318 vh->protocols[0].callback(wsi, LWS_CALLBACK_WSI_DESTROY, NULL, NULL, 0);
319 __lws_vhost_unbind_wsi(wsi);
320 lws_free(wsi);
326 lws_wsi_h2_adopt(struct lws *parent_wsi, struct lws *wsi)
339 wsi->seen_nonpseudoheader = 0;
341 wsi->client_mux_substream = 1;
343 wsi->h2.initialized = 1;
347 if (!wsi->mux.my_sid) {
348 wsi->mux.my_sid = nwsi->h2.h2n->highest_sid;
353 lwsl_info("%s: binding wsi %s to sid %d (next %d)\n", __func__,
354 lws_wsi_tag(wsi), (int)wsi->mux.my_sid, (int)nwsi->h2.h2n->highest_sid);
356 lws_wsi_mux_insert(wsi, parent_wsi, wsi->mux.my_sid);
358 wsi->txc.tx_cr = (int32_t)nwsi->h2.h2n->peer_set.s[H2SET_INITIAL_WINDOW_SIZE];
359 wsi->txc.peer_tx_cr_est = (int32_t)
362 lws_wsi_txc_describe(&wsi->txc, __func__, wsi->mux.my_sid);
364 if (lws_ensure_user_space(wsi))
367 lws_role_transition(wsi, LWSIFR_CLIENT, LRS_H2_WAITING_TO_SEND_HEADERS,
370 lws_callback_on_writable(wsi);
372 return wsi;
376 parent_wsi->mux.child_list = wsi->mux.sibling_list;
379 if (wsi->user_space)
380 lws_free_set_NULL(wsi->user_space);
381 wsi->a.protocol->callback(wsi, LWS_CALLBACK_WSI_DESTROY, NULL, NULL, 0);
382 lws_free(wsi);
389 lws_h2_issue_preface(struct lws *wsi)
391 struct lws_h2_netconn *h2n = wsi->h2.h2n;
402 lwsl_debug("%s: %s: fd %d\n", __func__, lws_wsi_tag(wsi), (int)wsi->desc.sockfd);
404 if (lws_issue_raw(wsi, (uint8_t *)preface, strlen(preface)) !=
410 lws_role_transition(wsi, LWSIFR_CLIENT, LRS_H2_WAITING_TO_SEND_HEADERS,
414 wsi->txc.tx_cr = 65535;
422 lws_pps_schedule(wsi, pps);
429 lws_pps_schedule(struct lws *wsi, struct lws_h2_protocol_send *pps)
431 struct lws *nwsi = lws_get_network_wsi(wsi);
442 lws_rx_flow_control(wsi, LWS_RXFLOW_REASON_APPLIES_DISABLE |
444 lws_callback_on_writable(wsi);
448 lws_h2_goaway(struct lws *wsi, uint32_t err, const char *reason)
450 struct lws_h2_netconn *h2n = wsi->h2.h2n;
460 lwsl_info("%s: %s: ERR 0x%x, '%s'\n", __func__, lws_wsi_tag(wsi), (int)err, reason);
465 lws_pps_schedule(wsi, pps);
473 lws_h2_rst_stream(struct lws *wsi, uint32_t err, const char *reason)
475 struct lws *nwsi = lws_get_network_wsi(wsi);
482 if (!wsi->h2_stream_carries_ws && h2n->type == LWS_H2_FRAME_TYPE_COUNT)
490 (int)err, wsi->mux.my_sid, reason);
492 pps->u.rs.sid = wsi->mux.my_sid;
495 lws_pps_schedule(wsi, pps);
498 lws_h2_state(wsi, LWS_H2_STATE_CLOSED);
504 lws_h2_settings(struct lws *wsi, struct http2_settings *settings,
507 struct lws *nwsi = lws_get_network_wsi(wsi);
545 if (wsi->flags & LCCSCF_H2_QUIRK_OVERFLOWS_TXCR &&
584 if (b < wsi->a.vhost->h2.set.s[H2SET_MAX_FRAME_SIZE]) {
632 lws_h2_tx_cr_get(struct lws *wsi)
634 int c = wsi->txc.tx_cr;
635 struct lws *nwsi = lws_get_network_wsi(wsi);
637 if (!wsi->mux_substream && !nwsi->upgraded_to_http2)
641 __func__, lws_wsi_tag(wsi), c, (int)nwsi->txc.tx_cr);
653 lws_h2_tx_cr_consume(struct lws *wsi, int consumed)
655 struct lws *nwsi = lws_get_network_wsi(wsi);
657 wsi->txc.tx_cr -= consumed;
659 if (nwsi != wsi)
663 int lws_h2_frame_write(struct lws *wsi, int type, int flags,
666 struct lws *nwsi = lws_get_network_wsi(wsi);
670 //if (wsi->h2_stream_carries_ws)
684 "txcr=%d, nwsi->txcr=%d\n", __func__, lws_wsi_tag(wsi),
686 sid, len, (int)wsi->txc.tx_cr, (int)nwsi->txc.tx_cr);
689 if (wsi->txc.tx_cr < (int)len)
693 lws_wsi_tag(wsi), len, (int)wsi->txc.tx_cr);
694 lws_h2_tx_cr_consume(wsi, (int)len);
708 static void lws_h2_set_bin(struct lws *wsi, int n, unsigned char *buf)
712 *buf++ = (uint8_t)(wsi->h2.h2n->our_set.s[n] >> 24);
713 *buf++ = (uint8_t)(wsi->h2.h2n->our_set.s[n] >> 16);
714 *buf++ = (uint8_t)(wsi->h2.h2n->our_set.s[n] >> 8);
715 *buf = (uint8_t)wsi->h2.h2n->our_set.s[n];
720 int lws_h2_do_pps_send(struct lws *wsi)
722 struct lws_h2_netconn *h2n = wsi->h2.h2n;
744 lwsl_info("%s: %s: %d\n", __func__, lws_wsi_tag(wsi), pps->type);
758 wsi->h2.h2n->our_set.s[n]);
760 lws_h2_set_bin(wsi, n, &set[LWS_PRE + m]);
763 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_SETTINGS,
784 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_SETTINGS,
795 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_SETTINGS, 1,
802 wsi->h2_acked_settings = 0;
804 if (lwsi_state(wsi) == LRS_H2_AWAIT_SETTINGS) {
805 lwsi_set_state(wsi, LRS_ESTABLISHED);
807 wsi->http.fop_fd = NULL;
809 if (lws_is_ssl(lws_get_network_wsi(wsi)))
812 if (wsi->a.vhost->options &
821 lws_context_lock(wsi->a.context, "h2 mig");
822 lws_vhost_lock(wsi->a.vhost);
824 h2n->swsi = __lws_wsi_server_new(wsi->a.vhost, wsi, 1);
826 lws_vhost_unlock(wsi->a.vhost);
827 lws_context_unlock(wsi->a.context);
833 h2n->swsi->http.ah = wsi->http.ah;
834 wsi->http.ah = NULL;
870 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_PING, flags,
893 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_GOAWAY, 0,
909 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_RST_STREAM,
915 cwsi = lws_wsi_mux_from_id(wsi, pps->u.rs.sid);
917 lwsl_debug("%s: closing cwsi %s %s %s (wsi %s)\n",
920 cwsi->a.protocol->name, lws_wsi_tag(wsi));
933 n = lws_h2_frame_write(wsi, LWS_H2_FRAME_TYPE_WINDOW_UPDATE,
957 lws_h2_parse_end_of_frame(struct lws *wsi);
964 lws_h2_parse_frame_header(struct lws *wsi)
966 struct lws_h2_netconn *h2n = wsi->h2.h2n;
974 h2n->swsi = wsi;
981 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, pes);
986 /* let the network wsi live a bit longer if subs are active */
988 if (!wsi->immortal_substream_count)
989 lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE,
990 wsi->a.vhost->keepalive_timeout ?
991 wsi->a.vhost->keepalive_timeout : 31);
994 h2n->swsi = lws_wsi_mux_from_id(wsi, h2n->sid);
997 lws_wsi_tag(wsi), lws_wsi_tag(h2n->swsi), h2n->type,
1021 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1035 && wsi->client_h2_alpn
1047 lws_h2_goaway(wsi, H2_ERR_STREAM_CLOSED,
1053 /* if the sid is credible, treat as wsi for it closed */
1060 lws_h2_goaway(wsi, H2_ERR_STREAM_CLOSED,
1078 lws_h2_goaway(wsi, (unsigned int)n, "invalid rx for state");
1094 lws_h2_goaway(wsi, (unsigned int)n, "Continuation hdrs State");
1104 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, "DATA 0 sid");
1121 lws_h2_goaway(wsi, H2_ERR_STREAM_CLOSED, "conn closed");
1126 lws_h2_parse_end_of_frame(wsi);
1133 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1138 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1145 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, "Server only");
1158 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1163 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1174 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1181 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1189 if (wsi->upgraded_to_http2 &&
1191 (!(wsi->flags & LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM) ||
1195 !wsi->h2_acked_settings)) {
1200 lws_pps_schedule(wsi, pps);
1201 wsi->h2_acked_settings = 1;
1208 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1215 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1220 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1234 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1240 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1251 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, "sid 0");
1258 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1264 if (wsi->client_h2_alpn) {
1266 h2n->swsi = lws_wsi_mux_from_id(wsi, h2n->sid);
1268 "to wsi %s\n", lws_wsi_tag(wsi),
1280 if (wsi->mux.child_count + 1 >
1281 wsi->h2.h2n->our_set.s[H2SET_MAX_CONCURRENT_STREAMS]) {
1282 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1293 lws_context_lock(wsi->a.context, "h2 new str");
1294 lws_vhost_lock(wsi->a.vhost);
1296 h2n->swsi = __lws_wsi_server_new(wsi->a.vhost, wsi,
1299 lws_vhost_unlock(wsi->a.vhost);
1300 lws_context_unlock(wsi->a.context);
1303 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1320 * ah needs attaching to child wsi, even though
1321 * we only fill it from network wsi
1339 lws_start_foreach_ll(struct lws *, w, wsi->mux.child_list) {
1387 lws_h2_goaway(wsi, H2_ERR_FRAME_SIZE_ERROR,
1395 lws_h2_parse_end_of_frame(wsi);
1435 * wsi with a pending partial send... we may call lws_http_action() to send
1438 * So in that case we change the wsi state and do the lws_http_action() in the
1442 lws_h2_parse_end_of_frame(struct lws *wsi)
1444 struct lws_h2_netconn *h2n = wsi->h2.h2n;
1445 struct lws *eff_wsi = wsi;
1453 h2n->swsi = lws_wsi_mux_from_id(wsi, h2n->sid);
1459 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR, "depends on own sid");
1468 if (wsi->client_h2_alpn && !wsi->client_mux_migrated &&
1474 wsi->http.fop_fd = NULL;
1477 wsi->client_mux_migrated = 1;
1482 lws_context_lock(wsi->a.context, "h2 mig");
1483 lws_vhost_lock(wsi->a.vhost);
1485 h2n->swsi = __lws_wsi_server_new(wsi->a.vhost, wsi, 1);
1487 lws_vhost_unlock(wsi->a.vhost);
1488 lws_context_unlock(wsi->a.context);
1494 assert(lws_wsi_mux_from_id(wsi, 1) == h2n->swsi);
1496 // lws_role_transition(wsi, LWSIFR_CLIENT,
1505 h2n->swsi->http.ah = wsi->http.ah;
1507 lws_fi_import(&h2n->swsi->fic, &wsi->fic);
1512 h2n->swsi->flags = wsi->flags;
1518 h2n->swsi->conmon = wsi->conmon;
1519 h2n->swsi->conmon_datum = wsi->conmon_datum;
1520 h2n->swsi->sa46_peer = wsi->sa46_peer;
1521 wsi->conmon.dns_results_copy = NULL;
1526 if (wsi->for_ss) {
1527 lws_ss_handle_t *h = (lws_ss_handle_t *)lws_get_opaque_user_data(wsi);
1530 wsi->for_ss = 0;
1532 if (h->wsi == wsi)
1533 h->wsi = h2n->swsi;
1537 h2n->swsi->a.protocol = wsi->a.protocol;
1541 h2n->swsi->user_space = wsi->user_space;
1543 wsi->user_space_externally_allocated;
1544 h2n->swsi->a.opaque_user_data = wsi->a.opaque_user_data;
1545 wsi->a.opaque_user_data = NULL;
1547 wsi->txc.manual_initial_tx_credit;
1550 lws_strncpy(h2n->swsi->alpn, wsi->alpn,
1551 sizeof(wsi->alpn));
1554 wsi->user_space = NULL;
1557 h2n->swsi->http.ah->wsi = h2n->swsi;
1558 wsi->http.ah = NULL;
1561 lws_wsi_tag(wsi), lws_wsi_tag(h2n->swsi));
1570 if (!wsi->h2.initialized) {
1571 wsi->txc.tx_cr = (int32_t)
1576 lws_wsi_tag(wsi), (int)wsi->txc.tx_cr);
1577 wsi->h2.initialized = 1;
1582 if (!wsi->h2_acked_settings ||
1583 !(wsi->flags & LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM)
1588 lws_pps_schedule(wsi, pps);
1590 wsi->h2_acked_settings = 1;
1595 lws_wsi_mux_apply_queue(wsi);
1609 lws_h2_goaway(wsi, H2_ERR_COMPRESSION_ERROR,
1629 lws_h2_goaway(wsi, H2_ERR_COMPRESSION_ERROR,
1644 lwsl_info("http req, %s, h2n->swsi=%s\n", lws_wsi_tag(wsi),
1656 * In that case, the wsi survives having being reset
1713 lws_h2_goaway(wsi, H2_ERR_STREAM_CLOSED,
1760 __func__, lws_wsi_tag(wsi),
1771 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1783 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1875 lws_validity_confirmed(wsi);
1886 lws_pps_schedule(wsi, pps);
1906 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1928 lws_h2_goaway(wsi, H2_ERR_FLOW_CONTROL_ERROR,
1934 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
1956 lws_start_foreach_ll(struct lws *, w, wsi->mux.child_list) {
1992 * This may want to send something on the network wsi, which may be in the
1996 * The read parser for the network wsi has no choice but to parse its stream
2001 * wsi, we must change its state and handle it as a priority in the
2004 * About closing... for the main network wsi, it should return nonzero to
2008 lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t _inlen,
2011 struct lws_h2_netconn *h2n = wsi->h2.h2n;
2023 switch (lwsi_state(wsi)) {
2031 lwsl_info("http2: %s: established\n", lws_wsi_tag(wsi));
2032 lwsi_set_state(wsi, LRS_H2_AWAIT_SETTINGS);
2033 lws_validity_confirmed(wsi);
2035 wsi->txc.tx_cr = 65535;
2045 lws_pps_schedule(wsi, pps);
2077 lws_h2_goaway(wsi,
2103 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
2110 /* applies to wsi->h2.swsi which may be wsi */
2119 lws_h2_settings(wsi, &h2n->peer_set,
2171 * let the network wsi live a bit longer if
2175 if (!wsi->immortal_substream_count)
2176 lws_set_timeout(wsi,
2178 wsi->a.vhost->keepalive_timeout ?
2179 wsi->a.vhost->keepalive_timeout : 31);
2215 lws_h2_goaway(wsi,
2242 wsi->txc.peer_tx_cr_est -= n;
2276 * to the pt list of wsi holding buflist
2306 &wsi->buflist, NULL))) {
2330 wsi->txc.peer_tx_cr_est -= n;
2360 lws_h2_update_peer_txcredit(wsi, 0, n);
2377 lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
2430 n = lws_h2_parse_end_of_frame(wsi);
2476 lws_h2_parse_frame_header(wsi))
2513 lws_h2_client_handshake(struct lws *wsi)
2515 struct lws_context_per_thread *pt = &wsi->a.context->pt[(int)wsi->tsi];
2517 char *meth = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_METHOD),
2518 *uri = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_URI), *simp;
2519 struct lws *nwsi = lws_get_network_wsi(wsi);
2542 wsi->mux.my_sid = nwsi->h2.h2n->highest_sid_opened = sid;
2544 lws_wsi_tag(wsi), sid);
2548 __func__, wsi->mux.my_sid);
2551 end = start + (wsi->a.context->pt_serv_buf_size / 2) - LWS_PRE - 1;
2560 if (lws_add_http_header_by_token(wsi,
2566 if (lws_add_http_header_by_token(wsi,
2573 n = lws_hdr_total_length(wsi, _WSI_TOKEN_CLIENT_URI);
2577 if (wsi->stash && wsi->stash->cis[CIS_PATH]) {
2578 path = wsi->stash->cis[CIS_PATH];
2588 if (n && lws_add_http_header_by_token(wsi,
2593 n = lws_hdr_total_length(wsi, _WSI_TOKEN_CLIENT_HOST);
2594 simp = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_HOST);
2595 if (!n && wsi->stash && wsi->stash->cis[CIS_ADDRESS]) {
2596 n = (int)strlen(wsi->stash->cis[CIS_ADDRESS]);
2597 simp = wsi->stash->cis[CIS_ADDRESS];
2600 // n = lws_hdr_total_length(wsi, _WSI_TOKEN_CLIENT_ORIGIN);
2601 // simp = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_ORIGIN);
2603 if (n && simp && lws_add_http_header_by_token(wsi,
2610 if (/*!wsi->client_h2_alpn && */n && simp &&
2611 lws_add_http_header_by_token(wsi, WSI_TOKEN_HOST,
2616 if (wsi->flags & LCCSCF_HTTP_MULTIPART_MIME) {
2617 p1 = lws_http_multipart_headers(wsi, p);
2623 if (wsi->flags & LCCSCF_HTTP_X_WWW_FORM_URLENCODED) {
2624 if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE,
2628 lws_client_http_body_pending(wsi, 1);
2634 if (wsi->flags & LCCSCF_CACHE_COOKIES)
2635 lws_cookie_send_cookies(wsi, (char **)&p, (char *)end);
2638 if (wsi->a.protocol->callback(wsi,
2640 wsi->user_space, &p, lws_ptr_diff_size_t(end, p) - 12))
2643 if (lws_finalize_http_header(wsi, &p, end))
2650 if ((wsi->flags & LCCSCF_H2_QUIRK_NGHTTP2_END_STREAM) &&
2651 !(wsi->client_http_body_pending || lws_has_buffered_out(wsi)))
2657 n = lws_write(wsi, start, lws_ptr_diff_size_t(p, start), (enum lws_write_protocol)m);
2672 if (wsi->flags & LCCSCF_H2_MANUAL_RXFLOW) {
2673 n = wsi->txc.manual_initial_tx_credit;
2674 wsi->txc.manual = 1;
2677 if (lws_h2_update_peer_txcredit(wsi, wsi->mux.my_sid, n))
2680 lws_h2_state(wsi, LWS_H2_STATE_OPEN);
2681 lwsi_set_state(wsi, LRS_ESTABLISHED);
2683 if (wsi->flags & LCCSCF_HTTP_MULTIPART_MIME)
2684 lws_callback_on_writable(wsi);
2697 lws_h2_ws_handshake(struct lws *wsi)
2706 if (lws_add_http_header_status(wsi, HTTP_STATUS_OK, &p, end))
2709 if (lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL) > 64)
2712 if (wsi->proxied_ws_parent && wsi->child_list) {
2713 if (lws_hdr_simple_ptr(wsi, WSI_TOKEN_PROTOCOL)) {
2714 if (lws_add_http_header_by_token(wsi, WSI_TOKEN_PROTOCOL,
2715 (uint8_t *)lws_hdr_simple_ptr(wsi,
2717 (int)strlen(lws_hdr_simple_ptr(wsi,
2726 if (lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL) &&
2728 wsi->a.protocol->name && wsi->a.protocol->name[0]) {
2739 if (wsi->a.vhost && wsi->a.vhost->ss_handle &&
2740 wsi->a.vhost->ss_handle->policy->u.http.u.ws.subprotocol) {
2742 (lws_ss_handle_t *)wsi->a.opaque_user_data;
2744 lwsl_notice("%s: Server SS %s .wsi %s switching to ws protocol\n",
2745 __func__, lws_ss_tag(h), lws_wsi_tag(h->wsi));
2747 wsi->a.protocol = &protocol_secstream_ws;
2757 lws_mux_mark_immortal(wsi);
2759 if (lws_add_http_header_by_token(wsi, WSI_TOKEN_PROTOCOL,
2760 (unsigned char *)wsi->a.vhost->ss_handle->policy->
2762 (int)strlen(wsi->a.vhost->ss_handle->policy->
2768 if (lws_add_http_header_by_token(wsi, WSI_TOKEN_PROTOCOL,
2769 (unsigned char *)wsi->a.protocol->name,
2770 (int)strlen(wsi->a.protocol->name), &p, end))
2775 if (lws_finalize_http_header(wsi, &p, end))
2780 n = lws_write(wsi, start, m, LWS_WRITE_HTTP_HEADERS);
2792 lwsi_set_state(wsi, LRS_ESTABLISHED);
2793 wsi->lws_rx_parse_state = 0; // ==LWS_RXPS_NEW;
2795 uri_ptr = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_PATH);
2796 n = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_COLON_PATH);
2797 hit = lws_find_mount(wsi, uri_ptr, n);
2800 wsi->a.protocol->callback(wsi, LWS_CALLBACK_HTTP_PMO, wsi->user_space,
2804 lws_validity_confirmed(wsi);
2811 lws_read_h2(struct lws *wsi, unsigned char *buf, lws_filepos_t len)
2816 // wsi->wsistate, (int)len);
2819 * wsi here is always the network connection wsi, not a stream
2820 * wsi. Once we unpicked the framing we will find the right
2835 if (lws_is_flowcontrolled(wsi)) {
2836 lws_rxflow_cache(wsi, buf, 0, (size_t)len);
2845 * situation on the network wsi...
2849 * wsi in order to gain tx credit to send, which is
2852 * ALL network wsi-specific frames are sent by PPS
2855 * problem is when a stream wsi wants to send an, eg,
2857 * we will do now... the *stream wsi* must stall in a
2863 m = lws_h2_parser(wsi, buf, len, &body_chunk_len);
2866 lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
2885 lws_h2_client_stream_long_poll_rxonly(struct lws *wsi)
2888 if (!wsi->mux_substream)
2895 wsi->h2.long_poll = 1;
2896 wsi->h2.send_END_STREAM = 1;
2898 // lws_header_table_detach(wsi, 0);
2900 lws_callback_on_writable(wsi);