static void encode_data_header_and_consume_window(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, uint8_t *header, size_t length, int eos) { assert(header != NULL); h2o_http2_encode_frame_header(header, length, H2O_HTTP2_FRAME_TYPE_DATA, eos ? H2O_HTTP2_FRAME_FLAG_END_STREAM : 0, stream->stream_id); h2o_http2_window_consume_window(&conn->_write.window, length); h2o_http2_window_consume_window(&stream->output_window, length); }
static void commit_data_header(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, h2o_buffer_t **outbuf, size_t length, h2o_send_state_t send_state) { assert(outbuf != NULL); /* send a DATA frame if there's data or the END_STREAM flag to send */ if (length || send_state == H2O_SEND_STATE_FINAL) { h2o_http2_encode_frame_header((void *)((*outbuf)->bytes + (*outbuf)->size), length, H2O_HTTP2_FRAME_TYPE_DATA, send_state == H2O_SEND_STATE_FINAL ? H2O_HTTP2_FRAME_FLAG_END_STREAM : 0, stream->stream_id); h2o_http2_window_consume_window(&conn->_write.window, length); h2o_http2_window_consume_window(&stream->output_window, length); (*outbuf)->size += length + H2O_HTTP2_FRAME_HEADER_SIZE; } /* send a RST_STREAM if there's an error */ if (send_state == H2O_SEND_STATE_ERROR) { h2o_http2_encode_rst_stream_frame(outbuf, stream->stream_id, -H2O_HTTP2_ERROR_PROTOCOL); } }