summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_http_utils.cc
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-20 15:33:52 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-20 15:33:52 +0000
commit7213e7cddc25d53822bd7bcad1e56b700ed0723a (patch)
treef2ad70306305b8baf875f8220eb33722ce9e9854 /net/spdy/spdy_http_utils.cc
parent54e6e79cce665b06c965d58852f0c6362b9ba567 (diff)
downloadchromium_src-7213e7cddc25d53822bd7bcad1e56b700ed0723a.zip
chromium_src-7213e7cddc25d53822bd7bcad1e56b700ed0723a.tar.gz
chromium_src-7213e7cddc25d53822bd7bcad1e56b700ed0723a.tar.bz2
Move BuildRequestHeaders from HttpNetworkTransaction to
HttpUtil::BuildRequestHeaders, so that it can be used directly by SpdyHttpStream, removing the code duplication. Strip proxy-connection header from SPDY requests to be consistent with Connection header. BUG=none TEST=none Review URL: http://codereview.chromium.org/3831005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_http_utils.cc')
-rw-r--r--net/spdy/spdy_http_utils.cc51
1 files changed, 11 insertions, 40 deletions
diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc
index b2ef551..09ac79c 100644
--- a/net/spdy/spdy_http_utils.cc
+++ b/net/spdy/spdy_http_utils.cc
@@ -79,18 +79,16 @@ bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers,
return true;
}
-void CreateSpdyHeadersFromHttpRequest(
- const HttpRequestInfo& info, spdy::SpdyHeaderBlock* headers,
- bool direct) {
- // TODO(willchan): It's not really necessary to convert from
- // HttpRequestHeaders to spdy::SpdyHeaderBlock.
-
- static const char kHttpProtocolVersion[] = "HTTP/1.1";
-
- HttpRequestHeaders::Iterator it(info.extra_headers);
+void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
+ const HttpRequestHeaders& request_headers,
+ spdy::SpdyHeaderBlock* headers,
+ bool direct) {
+ HttpRequestHeaders::Iterator it(request_headers);
while (it.GetNext()) {
std::string name = StringToLowerASCII(it.name());
+ if (name == "connection" || name == "proxy-connection")
+ continue;
if (headers->find(name) == headers->end()) {
(*headers)[name] = it.value();
} else {
@@ -100,44 +98,17 @@ void CreateSpdyHeadersFromHttpRequest(
(*headers)[name] = new_value;
}
}
+ static const char kHttpProtocolVersion[] = "HTTP/1.1";
- // TODO(rch): Add Proxy headers here. (See http_network_transaction.cc)
- // TODO(rch): Add authentication headers here.
-
+ (*headers)["version"] = kHttpProtocolVersion;
(*headers)["method"] = info.method;
-
- // Handle content-length. This is the same as BuildRequestHeader in
- // http_network_transaction.cc.
- // TODO(lzheng): reduce the code duplication between spdy and http here.
- if (info.upload_data) {
- (*headers)["content-length"] =
- base::Int64ToString(info.upload_data->GetContentLength());
- } else if (info.method == "POST" || info.method == "PUT" ||
- info.method == "HEAD") {
- // An empty POST/PUT request still needs a content length. As for HEAD,
- // IE and Safari also add a content length header. Presumably it is to
- // support sending a HEAD request to an URL that only expects to be sent a
- // POST or some other method that normally would have a message body.
- (*headers)["content-length"] = "0";
- }
-
+ (*headers)["host"] = GetHostAndOptionalPort(info.url);
+ (*headers)["scheme"] = info.url.scheme();
if (direct)
(*headers)["url"] = HttpUtil::PathForRequest(info.url);
else
(*headers)["url"] = HttpUtil::SpecForRequest(info.url);
- (*headers)["host"] = GetHostAndOptionalPort(info.url);
- (*headers)["scheme"] = info.url.scheme();
- (*headers)["version"] = kHttpProtocolVersion;
- if (!info.referrer.is_empty())
- (*headers)["referer"] = info.referrer.spec();
- // Honor load flags that impact proxy caches.
- if (info.load_flags & LOAD_BYPASS_CACHE) {
- (*headers)["pragma"] = "no-cache";
- (*headers)["cache-control"] = "no-cache";
- } else if (info.load_flags & LOAD_VALIDATE_CACHE) {
- (*headers)["cache-control"] = "max-age=0";
- }
}
} // namespace net