From 1b63e6d478b75736cbcd75e3db98d3a86205ddbe Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 6 Sep 2015 15:21:36 +0900 Subject: [PATCH] nghttpx: Call request phase hook for pushed resource as well --- doc/nghttpx.h2r | 5 ++++- src/shrpx_http2_upstream.cc | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/nghttpx.h2r b/doc/nghttpx.h2r index 66d8dfde..c3e6dec5 100644 --- a/doc/nghttpx.h2r +++ b/doc/nghttpx.h2r @@ -289,7 +289,10 @@ and :rb:attr:`Nghttpx::Env#resp` respectively. method is noop. *uri* can be absolute URI, absolute path or relative path to the current request. For absolute or relative path, scheme and authority are inherited from the - current request. Currently, method is always GET. + current request. Currently, method is always GET. nghttpx + will issue request to backend servers to fulfill this request. + The request and response phase hooks will be called for pushed + resource as well. .. rb:class:: Response diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index b4acb275..8a3160f5 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -587,6 +587,20 @@ int on_frame_send_callback(nghttp2_session *session, const nghttp2_frame *frame, // downstream is in pending queue. auto ptr = downstream.get(); upstream->add_pending_downstream(std::move(downstream)); + +#ifdef HAVE_MRUBY + auto worker = handler->get_worker(); + auto mruby_ctx = worker->get_mruby_context(); + + if (mruby_ctx->run_on_request_proc(ptr) != 0) { + if (upstream->error_reply(ptr, 500) != 0) { + upstream->rst_stream(ptr, NGHTTP2_INTERNAL_ERROR); + return 0; + } + return 0; + } +#endif // HAVE_MRUBY + upstream->start_downstream(ptr); return 0;