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

This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-17 16:34:56 +09:00
parent e255468bdf
commit 919e9eee63
3 changed files with 9 additions and 2 deletions

View File

@ -662,7 +662,7 @@ void Downstream::inspect_http1_request() {
auto transfer_encoding = req_.fs.header(http2::HD_TRANSFER_ENCODING);
if (transfer_encoding) {
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;
}
}
@ -672,7 +672,7 @@ void Downstream::inspect_http1_response() {
auto transfer_encoding = resp_.fs.header(http2::HD_TRANSFER_ENCODING);
if (transfer_encoding) {
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;
}
}

View File

@ -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));
}
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);
template <typename InputIt> bool strieq(const char *a, InputIt b, size_t bn) {

View File

@ -374,6 +374,9 @@ void test_util_ends_with(void) {
CU_ASSERT(util::iends_with("foo", ""));
CU_ASSERT(util::iends_with("oFoo", "fOO"));
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) {