summaryrefslogtreecommitdiffstats
path: root/net/spdy/spdy_http_stream.cc
diff options
context:
space:
mode:
authorlzheng@google.com <lzheng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 21:08:34 +0000
committerlzheng@google.com <lzheng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 21:08:34 +0000
commit6f8013422aeb79649086c0ee99b3fa453b3738af (patch)
tree88ee5593e3f06f367bd3f5c9d95ecaaf3f0b841a /net/spdy/spdy_http_stream.cc
parentdd9b904b47f8c529e20e9f4f87d8f019e2a594bc (diff)
downloadchromium_src-6f8013422aeb79649086c0ee99b3fa453b3738af.zip
chromium_src-6f8013422aeb79649086c0ee99b3fa453b3738af.tar.gz
chromium_src-6f8013422aeb79649086c0ee99b3fa453b3738af.tar.bz2
Add content-length to spdy post request header.
TEST=spdy_network_transaction_unittest.cc BUG=50545 Review URL: http://codereview.chromium.org/3023029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy/spdy_http_stream.cc')
-rw-r--r--net/spdy/spdy_http_stream.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index b723b4e9..2d9fe39 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -112,6 +112,22 @@ void CreateSpdyHeadersFromHttpRequest(
// TODO(mbelshe): Add authentication headers here.
(*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"] =
+ 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)["url"] = net::HttpUtil::PathForRequest(info.url);
(*headers)["host"] = net::GetHostAndOptionalPort(info.url);
(*headers)["scheme"] = info.url.scheme();