Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 303443011: Retry requests on reused sockets when receiving 408 responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 TEST_P(HttpNetworkTransactionTest, KeepAliveConnectionReset) { 1432 TEST_P(HttpNetworkTransactionTest, KeepAliveConnectionReset) {
1433 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); 1433 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET);
1434 KeepAliveConnectionResendRequestTest(NULL, &read_failure); 1434 KeepAliveConnectionResendRequestTest(NULL, &read_failure);
1435 } 1435 }
1436 1436
1437 TEST_P(HttpNetworkTransactionTest, KeepAliveConnectionEOF) { 1437 TEST_P(HttpNetworkTransactionTest, KeepAliveConnectionEOF) {
1438 MockRead read_failure(SYNCHRONOUS, OK); // EOF 1438 MockRead read_failure(SYNCHRONOUS, OK); // EOF
1439 KeepAliveConnectionResendRequestTest(NULL, &read_failure); 1439 KeepAliveConnectionResendRequestTest(NULL, &read_failure);
1440 } 1440 }
1441 1441
1442 // Make sure that on a 408 response (Request Timeout), the request is retried,
1443 // if the socket was a reused keep alive socket.
1444 TEST_P(HttpNetworkTransactionTest, KeepAlive408) {
1445 MockRead read_failure(SYNCHRONOUS,
1446 "HTTP/1.1 408 Request Timeout\r\n"
1447 "Connection: Keep-Alive\r\n"
1448 "Content-Length: 6\r\n\r\n"
1449 "Pickle");
1450 KeepAliveConnectionResendRequestTest(NULL, &read_failure);
1451 }
1452
1442 TEST_P(HttpNetworkTransactionTest, 1453 TEST_P(HttpNetworkTransactionTest,
1443 PreconnectErrorNotConnectedOnWrite) { 1454 PreconnectErrorNotConnectedOnWrite) {
1444 MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED); 1455 MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED);
1445 PreconnectErrorResendRequestTest(&write_failure, NULL, false); 1456 PreconnectErrorResendRequestTest(&write_failure, NULL, false);
1446 } 1457 }
1447 1458
1448 TEST_P(HttpNetworkTransactionTest, PreconnectErrorReset) { 1459 TEST_P(HttpNetworkTransactionTest, PreconnectErrorReset) {
1449 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); 1460 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET);
1450 PreconnectErrorResendRequestTest(NULL, &read_failure, false); 1461 PreconnectErrorResendRequestTest(NULL, &read_failure, false);
1451 } 1462 }
1452 1463
1453 TEST_P(HttpNetworkTransactionTest, PreconnectErrorEOF) { 1464 TEST_P(HttpNetworkTransactionTest, PreconnectErrorEOF) {
1454 MockRead read_failure(SYNCHRONOUS, OK); // EOF 1465 MockRead read_failure(SYNCHRONOUS, OK); // EOF
1455 PreconnectErrorResendRequestTest(NULL, &read_failure, false); 1466 PreconnectErrorResendRequestTest(NULL, &read_failure, false);
1456 } 1467 }
1457 1468
1458 TEST_P(HttpNetworkTransactionTest, PreconnectErrorAsyncEOF) { 1469 TEST_P(HttpNetworkTransactionTest, PreconnectErrorAsyncEOF) {
1459 MockRead read_failure(ASYNC, OK); // EOF 1470 MockRead read_failure(ASYNC, OK); // EOF
1460 PreconnectErrorResendRequestTest(NULL, &read_failure, false); 1471 PreconnectErrorResendRequestTest(NULL, &read_failure, false);
1461 } 1472 }
1462 1473
1474 // Make sure that on a 408 response (Request Timeout), the request is retried,
1475 // if the socket was a preconnected (UNUSED_IDLE) socket.
1476 TEST_P(HttpNetworkTransactionTest, RetryOnIdle408) {
1477 MockRead read_failure(SYNCHRONOUS,
1478 "HTTP/1.1 408 Request Timeout\r\n"
1479 "Connection: Keep-Alive\r\n"
1480 "Content-Length: 6\r\n\r\n"
1481 "Pickle");
1482 KeepAliveConnectionResendRequestTest(NULL, &read_failure);
1483 PreconnectErrorResendRequestTest(NULL, &read_failure, false);
1484 }
1485
1463 TEST_P(HttpNetworkTransactionTest, 1486 TEST_P(HttpNetworkTransactionTest,
1464 SpdyPreconnectErrorNotConnectedOnWrite) { 1487 SpdyPreconnectErrorNotConnectedOnWrite) {
1465 MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED); 1488 MockWrite write_failure(ASYNC, ERR_SOCKET_NOT_CONNECTED);
1466 PreconnectErrorResendRequestTest(&write_failure, NULL, true); 1489 PreconnectErrorResendRequestTest(&write_failure, NULL, true);
1467 } 1490 }
1468 1491
1469 TEST_P(HttpNetworkTransactionTest, SpdyPreconnectErrorReset) { 1492 TEST_P(HttpNetworkTransactionTest, SpdyPreconnectErrorReset) {
1470 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET); 1493 MockRead read_failure(ASYNC, ERR_CONNECTION_RESET);
1471 PreconnectErrorResendRequestTest(NULL, &read_failure, true); 1494 PreconnectErrorResendRequestTest(NULL, &read_failure, true);
1472 } 1495 }
(...skipping 11607 matching lines...) Expand 10 before | Expand all | Expand 10 after
13080 EXPECT_EQ(ERR_IO_PENDING, rv); 13103 EXPECT_EQ(ERR_IO_PENDING, rv);
13081 13104
13082 rv = callback.WaitForResult(); 13105 rv = callback.WaitForResult();
13083 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 13106 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
13084 13107
13085 const HttpResponseInfo* response = trans->GetResponseInfo(); 13108 const HttpResponseInfo* response = trans->GetResponseInfo();
13086 EXPECT_TRUE(response == NULL); 13109 EXPECT_TRUE(response == NULL);
13087 } 13110 }
13088 13111
13089 } // namespace net 13112 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698