nghttpx: Replace \r\n in the header field to SPC in http downstream

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-24 23:27:45 +09:00
parent 091f38a99d
commit 556212a602
3 changed files with 12 additions and 0 deletions

View File

@ -122,6 +122,15 @@ void capitalize(std::string& s, size_t offset)
} }
} }
void sanitize_header_value(std::string& s, size_t offset)
{
for(size_t i = offset, eoi = s.size(); i < eoi; ++i) {
if(s[i] == '\r' || s[i] == '\n') {
s[i] = ' ';
}
}
}
std::string colorizeHeaders(const char *hdrs) std::string colorizeHeaders(const char *hdrs)
{ {
std::string nhdrs; std::string nhdrs;

View File

@ -41,6 +41,8 @@ std::string create_via_header_value(int major, int minor);
void capitalize(std::string& s, size_t offset); void capitalize(std::string& s, size_t offset);
void sanitize_header_value(std::string& s, size_t offset);
// Adds ANSI color codes to HTTP headers |hdrs|. // Adds ANSI color codes to HTTP headers |hdrs|.
std::string colorizeHeaders(const char *hdrs); std::string colorizeHeaders(const char *hdrs);

View File

@ -160,6 +160,7 @@ int HttpDownstreamConnection::push_request_headers()
http::capitalize(hdrs, hdrs.size()-(*i).first.size()); http::capitalize(hdrs, hdrs.size()-(*i).first.size());
hdrs += ": "; hdrs += ": ";
hdrs += (*i).second; hdrs += (*i).second;
http::sanitize_header_value(hdrs, hdrs.size()-(*i).second.size());
hdrs += "\r\n"; hdrs += "\r\n";
} }
if(downstream_->get_request_connection_close()) { if(downstream_->get_request_connection_close()) {