From 9653ae98a6ab97e37548149afa6f8434c662c851 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 4 Jun 2016 17:23:21 +0900 Subject: [PATCH] nghttpx: Send 100-continue for API request --- src/shrpx_https_upstream.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 1dff8cd6..84973546 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -411,6 +411,23 @@ int htp_hdrs_completecb(http_parser *htp) { return -1; } + auto faddr = handler->get_upstream_addr(); + + if (faddr->api) { + // Normally, we forward expect: 100-continue to backend server, + // and let them decide whether responds with 100 Continue or not. + // For API endpoint, we have no backend, so just send 100 Continue + // here to make the client happy. + auto expect = req.fs.header(http2::HD_EXPECT); + if (expect && + util::strieq(expect->value, StringRef::from_lit("100-continue"))) { + auto output = downstream->get_response_buf(); + constexpr auto res = StringRef::from_lit("HTTP/1.1 100 Continue\r\n\r\n"); + output->append(res); + handler->signal_write(); + } + } + return 0; } } // namespace