nghttpx: Don't forward request if response was commited in mruby hook
This commit is contained in:
parent
f0d41a5ac2
commit
e436caf0bb
|
@ -307,6 +307,8 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
downstream->set_request_http2_expect_body(true);
|
downstream->set_request_http2_expect_body(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downstream->inspect_http2_request();
|
||||||
|
|
||||||
auto upstream = downstream->get_upstream();
|
auto upstream = downstream->get_upstream();
|
||||||
auto handler = upstream->get_client_handler();
|
auto handler = upstream->get_client_handler();
|
||||||
auto worker = handler->get_worker();
|
auto worker = handler->get_worker();
|
||||||
|
@ -314,8 +316,6 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
|
|
||||||
mruby_ctx->run_on_request_proc(downstream);
|
mruby_ctx->run_on_request_proc(downstream);
|
||||||
|
|
||||||
downstream->inspect_http2_request();
|
|
||||||
|
|
||||||
downstream->set_request_state(Downstream::HEADER_COMPLETE);
|
downstream->set_request_state(Downstream::HEADER_COMPLETE);
|
||||||
if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
|
if (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
|
||||||
downstream->disable_upstream_rtimer();
|
downstream->disable_upstream_rtimer();
|
||||||
|
@ -323,6 +323,10 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
|
||||||
downstream->set_request_state(Downstream::MSG_COMPLETE);
|
downstream->set_request_state(Downstream::MSG_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (downstream->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
start_downstream(downstream);
|
start_downstream(downstream);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -277,8 +277,6 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
auto worker = handler->get_worker();
|
auto worker = handler->get_worker();
|
||||||
auto mruby_ctx = worker->get_mruby_context();
|
auto mruby_ctx = worker->get_mruby_context();
|
||||||
|
|
||||||
mruby_ctx->run_on_request_proc(downstream);
|
|
||||||
|
|
||||||
downstream->inspect_http1_request();
|
downstream->inspect_http1_request();
|
||||||
|
|
||||||
if (downstream->get_request_method() != HTTP_CONNECT) {
|
if (downstream->get_request_method() != HTTP_CONNECT) {
|
||||||
|
@ -312,6 +310,14 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mruby_ctx->run_on_request_proc(downstream);
|
||||||
|
|
||||||
|
downstream->set_request_state(Downstream::HEADER_COMPLETE);
|
||||||
|
|
||||||
|
if (downstream->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
rv = downstream->attach_downstream_connection(
|
rv = downstream->attach_downstream_connection(
|
||||||
upstream->get_client_handler()->get_downstream_connection(downstream));
|
upstream->get_client_handler()->get_downstream_connection(downstream));
|
||||||
|
|
||||||
|
@ -327,8 +333,6 @@ int htp_hdrs_completecb(http_parser *htp) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
downstream->set_request_state(Downstream::HEADER_COMPLETE);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "shrpx_downstream.h"
|
#include "shrpx_downstream.h"
|
||||||
#include "shrpx_config.h"
|
#include "shrpx_config.h"
|
||||||
#include "shrpx_mruby_module.h"
|
#include "shrpx_mruby_module.h"
|
||||||
|
#include "shrpx_downstream_connection.h"
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
|
|
||||||
namespace shrpx {
|
namespace shrpx {
|
||||||
|
@ -77,6 +78,10 @@ int run_request_proc(mrb_state *mrb, Downstream *downstream, RProc *proc) {
|
||||||
downstream->index_request_headers();
|
downstream->index_request_headers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (downstream->get_response_state() == Downstream::MSG_COMPLETE) {
|
||||||
|
downstream->pop_downstream_connection();
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in New Issue