From e08df2840cf1f76d626cf2c6cdf43b6a6ddaa716 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 3 Jul 2014 20:57:07 +0900 Subject: [PATCH] nghttpx: Disallow 2nd message in http downstream --- src/shrpx_http_downstream_connection.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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;