是不是和这个有关 static void
h2_init_con (request_st * const restrict h2r, connection * const restrict con)
{
h2con * const h2c = ck_calloc(1, sizeof(h2con));
con->hx = (hxcon *)h2c;
con->fn = &http_dispatch[HTTP_VERSION_2];
con->reqbody_read = h2_recv_reqbody;
con->read_idle_ts = log_monotonic_secs;
con->keep_alive_idle = h2r->conf.max_keep_alive_idle;
h2r->x.h2.rwin = 262144; /* h2 connection recv window (256k)*/
h2r->x.h2.swin = 65535; /* h2 connection send window */
h2r->x.h2.rwin_fudge = 0;
/* settings sent from peer */ /* initial values */
h2c->s_header_table_size = 4096; /* SETTINGS_HEADER_TABLE_SIZE */
h2c->s_enable_push = 1; /* SETTINGS_ENABLE_PUSH */
h2c->s_max_concurrent_streams= ~0u; /* SETTINGS_MAX_CONCURRENT_STREAMS */
h2c->s_initial_window_size = 65536; /* SETTINGS_INITIAL_WINDOW_SIZE */
h2c->s_max_frame_size = 16384; /* SETTINGS_MAX_FRAME_SIZE */
h2c->s_max_header_list_size = ~0u; /* SETTINGS_MAX_HEADER_LIST_SIZE */
h2c->sent_settings = log_monotonic_secs;/*(send SETTINGS below)*/
lshpack_dec_init(&h2c->decoder);
lshpack_enc_init(&h2c->encoder);
lshpack_enc_use_hist(&h2c->encoder, 1);
static const uint8_t h2settings[] = { /*(big-endian numbers)*/
/* SETTINGS */
0x00, 0x00, 0x1e /* frame length */ /* 5 * (6 bytes per setting) */
,H2_FTYPE_SETTINGS /* frame type */
,0x00 /* frame flags */
,0x00, 0x00, 0x00, 0x00 /* stream identifier */
,0x00, H2_SETTINGS_MAX_CONCURRENT_STREAMS
,0x00, 0x00, 0x00, 0x08 /* 8 */
#if 0 /* ? explicitly disable dynamic table ? (and adjust frame length) */
/* If this is sent, must wait until peer sends SETTINGS with ACK
* before disabling dynamic table in HPACK decoder */
/*(before calling lshpack_dec_set_max_capacity(&h2c->decoder, 0))*/
,0x00, H2_SETTINGS_HEADER_TABLE_SIZE
,0x00, 0x00, 0x00, 0x00 /* 0 */
#endif
#if 0 /* ? explicitly disable push ? (and adjust frame length) */
,0x00, H2_SETTINGS_ENABLE_PUSH
,0x00, 0x00, 0x00, 0x00 /* 0 */
#endif
,0x00, H2_SETTINGS_INITIAL_WINDOW_SIZE /*(must match in h2_init_stream())*/
,0x00, 0x01, 0x00, 0x00 /* 65536 *//*multiple of SETTINGS_MAX_FRAME_SIZE*/
#if 0 /* ? increase from default (16384) ? (and adjust frame length) */
,0x00, H2_SETTINGS_MAX_FRAME_SIZE
,0x00, 0x00, 0x80, 0x00 /* 32768 */
#endif
,0x00, H2_SETTINGS_MAX_HEADER_LIST_SIZE
,0x00, 0x00, 0xFF, 0xFF /* 65535 */
,0x00, H2_SETTINGS_ENABLE_CONNECT_PROTOCOL
,0x00, 0x00, 0x00, 0x01 /* 1 */
,0x00, H2_SETTINGS_NO_RFC7540_PRIORITIES
,0x00, 0x00, 0x00, 0x01 /* 1 */
/* WINDOW_UPDATE */
,0x00, 0x00, 0x04 /* frame length */
,H2_FTYPE_WINDOW_UPDATE /* frame type */
,0x00 /* frame flags */
,0x00, 0x00, 0x00, 0x00 /* stream identifier */
,0x00, 0x03, 0x00, 0x01 /* 196609 *//*(increase connection rwin to 256k)*/
};
chunkqueue_append_mem(con->write_queue,
(const char *)h2settings, sizeof(h2settings));
if (!h2_recv_client_connection_preface(con)) {
/*(alternatively, func ptr could be saved in an element in (h2con *))*/
con->plugin_ctx[0] = (void *)(uintptr_t)con->network_read;
con->network_read = h2_read_client_connection_preface;
/* note: no steps taken to reset con->network_read() on error
* as con->network_read() is always set in connection_accepted() */
}
buffer_string_prepare_copy(h2r->tmp_buf, 65535);
}