Commit 919e9eee authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: It is enough to check "chunked" in the suffix

parent e255468b
...@@ -662,7 +662,7 @@ void Downstream::inspect_http1_request() { ...@@ -662,7 +662,7 @@ void Downstream::inspect_http1_request() {
auto transfer_encoding = req_.fs.header(http2::HD_TRANSFER_ENCODING); auto transfer_encoding = req_.fs.header(http2::HD_TRANSFER_ENCODING);
if (transfer_encoding) { if (transfer_encoding) {
req_.fs.content_length = -1; req_.fs.content_length = -1;
if (util::strifind(transfer_encoding->value.c_str(), "chunked")) { if (util::iends_with_l(transfer_encoding->value, "chunked")) {
chunked_request_ = true; chunked_request_ = true;
} }
} }
...@@ -672,7 +672,7 @@ void Downstream::inspect_http1_response() { ...@@ -672,7 +672,7 @@ void Downstream::inspect_http1_response() {
auto transfer_encoding = resp_.fs.header(http2::HD_TRANSFER_ENCODING); auto transfer_encoding = resp_.fs.header(http2::HD_TRANSFER_ENCODING);
if (transfer_encoding) { if (transfer_encoding) {
resp_.fs.content_length = -1; resp_.fs.content_length = -1;
if (util::strifind(transfer_encoding->value.c_str(), "chunked")) { if (util::iends_with_l(transfer_encoding->value, "chunked")) {
chunked_response_ = true; chunked_response_ = true;
} }
} }
......
...@@ -238,6 +238,10 @@ inline bool iends_with(const std::string &a, const std::string &b) { ...@@ -238,6 +238,10 @@ inline bool iends_with(const std::string &a, const std::string &b) {
return iends_with(std::begin(a), std::end(a), std::begin(b), std::end(b)); return iends_with(std::begin(a), std::end(a), std::begin(b), std::end(b));
} }
template <size_t N> bool iends_with_l(const std::string &a, const char(&b)[N]) {
return iends_with(std::begin(a), std::end(a), b, b + N - 1);
}
int strcompare(const char *a, const uint8_t *b, size_t n); int strcompare(const char *a, const uint8_t *b, size_t n);
template <typename InputIt> bool strieq(const char *a, InputIt b, size_t bn) { template <typename InputIt> bool strieq(const char *a, InputIt b, size_t bn) {
......
...@@ -374,6 +374,9 @@ void test_util_ends_with(void) { ...@@ -374,6 +374,9 @@ void test_util_ends_with(void) {
CU_ASSERT(util::iends_with("foo", "")); CU_ASSERT(util::iends_with("foo", ""));
CU_ASSERT(util::iends_with("oFoo", "fOO")); CU_ASSERT(util::iends_with("oFoo", "fOO"));
CU_ASSERT(!util::iends_with("ofoo", "fo")); CU_ASSERT(!util::iends_with("ofoo", "fo"));
CU_ASSERT(util::iends_with_l("oFoo", "fOO"));
CU_ASSERT(!util::iends_with_l("ofoo", "fo"));
} }
void test_util_parse_http_date(void) { void test_util_parse_http_date(void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment