diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 03:49:14 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 03:49:14 +0000 |
commit | 3a2d366b664bb0c13f4427f3ed6a3b6af6e77451 (patch) | |
tree | 6d6610f3f16bac1c3d774b85969de634f1b72972 /net/http | |
parent | de412917b254482842408c79b01f2962c5888ee2 (diff) | |
download | chromium_src-3a2d366b664bb0c13f4427f3ed6a3b6af6e77451.zip chromium_src-3a2d366b664bb0c13f4427f3ed6a3b6af6e77451.tar.gz chromium_src-3a2d366b664bb0c13f4427f3ed6a3b6af6e77451.tar.bz2 |
Treat all 1xx the same as a 100 (continue).
BUG=8440
Review URL: http://codereview.chromium.org/53111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12634 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_network_transaction.cc | 7 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 44 |
2 files changed, 49 insertions, 2 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index c7ea56f..fc43066 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -1041,9 +1041,11 @@ int HttpNetworkTransaction::DidReadResponseHeaders() { // Check for an intermediate 100 Continue response. An origin server is // allowed to send this response even if we didn't ask for it, so we just // need to skip over it. - if (headers->response_code() == 100) { + // We treat any other 1xx in this same way (although in practice getting + // a 1xx that isn't a 100 is rare). + if (headers->response_code() / 100 == 1) { header_buf_len_ -= header_buf_body_offset_; - // If we've already received some bytes after the 100 Continue response, + // If we've already received some bytes after the 1xx response, // move them to the beginning of header_buf_. if (header_buf_len_) { memmove(header_buf_.get(), header_buf_.get() + header_buf_body_offset_, @@ -1071,6 +1073,7 @@ int HttpNetworkTransaction::DidReadResponseHeaders() { // MUST NOT include a message-body. All other responses do include a // message-body, although it MAY be of zero length. switch (response_.headers->response_code()) { + // Note that 1xx was already handled earlier. case 204: // No Content case 205: // Reset Content case 304: // Not Modified diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 20e845e..a9fa974 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -598,6 +598,50 @@ TEST_F(HttpNetworkTransactionTest, Ignores100) { EXPECT_EQ("hello world", response_data); } +// This test is almost the same as Ignores100 above, but the response contains +// a 102 instead of a 100. Also, instead of HTTP/1.0 the response is +// HTTP/1.1. +TEST_F(HttpNetworkTransactionTest, Ignores1xx) { + scoped_ptr<net::ProxyService> proxy_service(CreateNullProxyService()); + scoped_ptr<net::HttpTransaction> trans(new net::HttpNetworkTransaction( + CreateSession(proxy_service.get()), &mock_socket_factory)); + + net::HttpRequestInfo request; + request.method = "GET"; + request.url = GURL("http://www.foo.com/"); + request.load_flags = 0; + + MockRead data_reads[] = { + MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"), + MockRead("HTTP/1.1 200 OK\r\n\r\n"), + MockRead("hello world"), + MockRead(false, net::OK), + }; + MockSocket data; + data.reads = data_reads; + mock_sockets[0] = &data; + mock_sockets[1] = NULL; + + TestCompletionCallback callback; + + int rv = trans->Start(&request, &callback); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + + rv = callback.WaitForResult(); + EXPECT_EQ(net::OK, rv); + + const net::HttpResponseInfo* response = trans->GetResponseInfo(); + EXPECT_TRUE(response != NULL); + + EXPECT_TRUE(response->headers != NULL); + EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); + + std::string response_data; + rv = ReadTransaction(trans.get(), &response_data); + EXPECT_EQ(net::OK, rv); + EXPECT_EQ("hello world", response_data); +} + // read_failure specifies a read failure that should cause the network // transaction to resend the request. void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( |