Revert "nghttpx: Don't capitalize h1 header fields"
This reverts commit f994664934
.
This commit is contained in:
parent
c78528d54b
commit
4bf3cb2cc0
13
src/http2.cc
13
src/http2.cc
|
@ -238,6 +238,17 @@ 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) {
|
||||
|
@ -406,7 +417,7 @@ void build_http1_headers_from_headers(DefaultMemchunks *buf,
|
|||
case HD_X_FORWARDED_PROTO:
|
||||
continue;
|
||||
}
|
||||
buf->append(kv.name);
|
||||
capitalize(buf, kv.name);
|
||||
buf->append(": ");
|
||||
buf->append(kv.value);
|
||||
buf->append("\r\n");
|
||||
|
|
|
@ -101,6 +101,8 @@ 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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -896,7 +896,7 @@ int HttpsUpstream::send_reply(Downstream *downstream, const uint8_t *body,
|
|||
if (kv.name.empty() || kv.name[0] == ':') {
|
||||
continue;
|
||||
}
|
||||
output->append(kv.name);
|
||||
http2::capitalize(output, kv.name);
|
||||
output->append(": ");
|
||||
output->append(kv.value);
|
||||
output->append("\r\n");
|
||||
|
|
Loading…
Reference in New Issue