diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index 9494f5a2..f5a2d7ad 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -389,6 +389,19 @@ bool HttpDownstreamConnection::get_output_buffer_full() return evbuffer_get_length(output) >= OUTBUF_MAX_THRES; } +namespace { +int htp_msg_begincb(http_parser *htp) +{ + auto downstream = static_cast(htp->data); + + if(downstream->get_response_state() != Downstream::INITIAL) { + return -1; + } + + return 0; +} +} // namespace + namespace { int htp_hdrs_completecb(http_parser *htp) { @@ -498,7 +511,7 @@ int htp_msg_completecb(http_parser *htp) namespace { http_parser_settings htp_hooks = { - nullptr, // http_cb on_message_begin; + htp_msg_begincb, // http_cb on_message_begin; nullptr, // http_data_cb on_url; nullptr, // http_data_cb on_status; htp_hdr_keycb, // http_data_cb on_header_field;