Index: net/spdy/spdy_http_utils.cc |
diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc |
index 448c82ffd3ca9a2fc06f947f706e6082c36f8956..8696842d1db92836b373bf5a3cedc764ff1420e7 100644 |
--- a/net/spdy/spdy_http_utils.cc |
+++ b/net/spdy/spdy_http_utils.cc |
@@ -14,12 +14,27 @@ |
#include "net/base/net_util.h" |
#include "net/http/http_request_headers.h" |
#include "net/http/http_request_info.h" |
-#include "net/http/http_response_headers.h" |
#include "net/http/http_response_info.h" |
#include "net/http/http_util.h" |
namespace net { |
+namespace { |
+ |
+void AddSpdyHeader(SpdyHeaderBlock* headers, |
+ const std::string& name, |
+ const std::string& value) { |
+ if (headers->find(name) == headers->end()) { |
+ (*headers)[name] = value; |
+ } else { |
+ std::string new_value = (*headers)[name]; |
+ new_value.append(1, '\0'); // +=() doesn't append 0's |
+ new_value += value; |
+ (*headers)[name] = new_value; |
Ryan Hamilton
2014/06/19 00:15:44
Would this work:
(*headers)[name] += "\0" + value
dmz
2014/06/19 21:17:02
No, but this does:
(*headers)[name] += '\0' + valu
|
+ } |
+} |
+} |
Ryan Hamilton
2014/06/19 00:15:44
newline before. Add a comment:
} // namespace
dmz
2014/06/19 21:17:02
Done.
|
+ |
bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers, |
SpdyMajorVersion protocol_version, |
HttpResponseInfo* response) { |
@@ -83,6 +98,30 @@ bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers, |
return true; |
} |
+void CreateSpdyHeadersFromHttpResponse( |
+ scoped_refptr<HttpResponseHeaders> response_headers, |
+ SpdyHeaderBlock* headers, |
+ SpdyMajorVersion protocol_version) { |
+ std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status"; |
+ std::string version_key = |
+ (protocol_version >= SPDY3) ? ":version" : "version"; |
+ |
+ std::string status_line = response_headers->GetStatusLine(); |
+ std::string::iterator after_version = |
+ std::find(status_line.begin(), status_line.end(), ' '); |
+ if (protocol_version < SPDY4) { |
+ (*headers)[version_key] = std::string(status_line.begin(), after_version); |
+ } |
+ (*headers)[status_key] = std::string(after_version + 1, status_line.end()); |
+ |
+ void* iter = NULL; |
+ std::string raw_name, value; |
+ while (response_headers->EnumerateHeaderLines(&iter, &raw_name, &value)) { |
+ std::string name = StringToLowerASCII(raw_name); |
+ AddSpdyHeader(headers, name, value); |
+ } |
+} |
+ |
void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, |
const HttpRequestHeaders& request_headers, |
SpdyHeaderBlock* headers, |
@@ -96,14 +135,7 @@ void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, |
name == "transfer-encoding" || name == "host") { |
continue; |
} |
- if (headers->find(name) == headers->end()) { |
- (*headers)[name] = it.value(); |
- } else { |
- std::string new_value = (*headers)[name]; |
- new_value.append(1, '\0'); // +=() doesn't append 0's |
- new_value += it.value(); |
- (*headers)[name] = new_value; |
- } |
+ AddSpdyHeader(headers, name, it.value()); |
} |
static const char kHttpProtocolVersion[] = "HTTP/1.1"; |