From f9946649345ee4500292531a6eb0f62474131f5d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 11 Feb 2017 18:41:52 +0900 Subject: [PATCH] nghttpx: Don't capitalize h1 header fields --- src/http2.cc | 13 +------------ src/http2.h | 2 -- src/http2_test.cc | 18 +++++++++--------- src/shrpx_https_upstream.cc | 2 +- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/http2.cc b/src/http2.cc index 04dfb7ad..89605192 100644 --- a/src/http2.cc +++ b/src/http2.cc @@ -238,17 +238,6 @@ StringRef stringify_status(BlockAllocator &balloc, unsigned int status_code) { } } -void capitalize(DefaultMemchunks *buf, const StringRef &s) { - buf->append(util::upcase(s[0])); - for (size_t i = 1; i < s.size(); ++i) { - if (s[i - 1] == '-') { - buf->append(util::upcase(s[i])); - } else { - buf->append(s[i]); - } - } -} - bool lws(const char *value) { for (; *value; ++value) { switch (*value) { @@ -417,7 +406,7 @@ void build_http1_headers_from_headers(DefaultMemchunks *buf, case HD_X_FORWARDED_PROTO: continue; } - capitalize(buf, kv.name); + buf->append(kv.name); buf->append(": "); buf->append(kv.value); buf->append("\r\n"); diff --git a/src/http2.h b/src/http2.h index 9859930b..dffe5bbb 100644 --- a/src/http2.h +++ b/src/http2.h @@ -101,8 +101,6 @@ StringRef get_reason_phrase(unsigned int status_code); // Returns string version of |status_code|. (e.g., "404") StringRef stringify_status(BlockAllocator &balloc, unsigned int status_code); -void capitalize(DefaultMemchunks *buf, const StringRef &s); - // Returns true if |value| is LWS bool lws(const char *value); diff --git a/src/http2_test.cc b/src/http2_test.cc index d2be6230..a7fbf7c2 100644 --- a/src/http2_test.cc +++ b/src/http2_test.cc @@ -187,15 +187,15 @@ void test_http2_build_http1_headers_from_headers(void) { DefaultMemchunks buf(&pool); http2::build_http1_headers_from_headers(&buf, headers); auto hdrs = std::string(buf.head->pos, buf.head->last); - CU_ASSERT("Alpha: 0\r\n" - "Bravo: 1\r\n" - "Delta: 4\r\n" - "Expect: 5\r\n" - "Foxtrot: 6\r\n" - "Tango: 7\r\n" - "Te: 8\r\n" - "Te: 9\r\n" - "Zulu: 12\r\n" == hdrs); + CU_ASSERT("alpha: 0\r\n" + "bravo: 1\r\n" + "delta: 4\r\n" + "expect: 5\r\n" + "foxtrot: 6\r\n" + "tango: 7\r\n" + "te: 8\r\n" + "te: 9\r\n" + "zulu: 12\r\n" == hdrs); } void test_http2_lws(void) { diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index 7c1cc4ae..e70761c7 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -890,7 +890,7 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body, if (kv.name.empty() || kv.name[0] == ':') { continue; } - http2::capitalize(output, kv.name); + output->append(kv.name); output->append(": "); output->append(kv.value); output->append("\r\n");