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

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

Issue 284913003: Remove DCHECK in HttpStreamParser::ReadResponseHeaders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really remove line Created 6 years, 7 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 | « no previous file | net/http/http_stream_parser.cc » ('j') | 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 10141 matching lines...) Expand 10 before | Expand all | Expand 10 after
10152 TestCompletionCallback callback; 10152 TestCompletionCallback callback;
10153 10153
10154 CapturingBoundNetLog log; 10154 CapturingBoundNetLog log;
10155 int rv = trans->Start(&request, callback.callback(), log.bound()); 10155 int rv = trans->Start(&request, callback.callback(), log.bound());
10156 EXPECT_EQ(ERR_IO_PENDING, rv); 10156 EXPECT_EQ(ERR_IO_PENDING, rv);
10157 trans.reset(); // Cancel the transaction here. 10157 trans.reset(); // Cancel the transaction here.
10158 10158
10159 base::MessageLoop::current()->RunUntilIdle(); 10159 base::MessageLoop::current()->RunUntilIdle();
10160 } 10160 }
10161 10161
10162 // Test that if a transaction is cancelled after receiving the headers, the
10163 // stream is drained properly and added back to the socket pool. The main
10164 // purpose of this test is to make sure that an HttpStreamParser can be read
10165 // from after the HttpNetworkTransaction and the objects it owns have been
10166 // deleted.
10167 // See http://crbug.com/368418
10168 TEST_P(HttpNetworkTransactionTest, CancelAfterHeaders) {
10169 MockRead data_reads[] = {
10170 MockRead(ASYNC, "HTTP/1.1 200 OK\r\n"),
10171 MockRead(ASYNC, "Content-Length: 2\r\n"),
10172 MockRead(ASYNC, "Connection: Keep-Alive\r\n\r\n"),
10173 MockRead(ASYNC, "1"),
10174 // 2 async reads are necessary to trigger a ReadResponseBody call after the
10175 // HttpNetworkTransaction has been deleted.
10176 MockRead(ASYNC, "2"),
10177 MockRead(SYNCHRONOUS, ERR_IO_PENDING), // Should never read this.
10178 };
10179 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0);
10180 session_deps_.socket_factory->AddSocketDataProvider(&data);
10181
10182 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10183
10184 {
10185 HttpRequestInfo request;
10186 request.method = "GET";
10187 request.url = GURL("http://www.google.com/");
10188 request.load_flags = 0;
10189
10190 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session);
10191 TestCompletionCallback callback;
10192
10193 int rv = trans.Start(&request, callback.callback(), BoundNetLog());
10194 EXPECT_EQ(ERR_IO_PENDING, rv);
10195 callback.WaitForResult();
10196
10197 const HttpResponseInfo* response = trans.GetResponseInfo();
10198 ASSERT_TRUE(response != NULL);
10199 EXPECT_TRUE(response->headers.get() != NULL);
10200 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
10201
10202 // The transaction and HttpRequestInfo are deleted.
10203 }
10204
10205 // Let the HttpResponseBodyDrainer drain the socket.
10206 base::MessageLoop::current()->RunUntilIdle();
10207
10208 // Socket should now be idle, waiting to be reused.
10209 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session));
10210 }
10211
10162 // Test a basic GET request through a proxy. 10212 // Test a basic GET request through a proxy.
10163 TEST_P(HttpNetworkTransactionTest, ProxyGet) { 10213 TEST_P(HttpNetworkTransactionTest, ProxyGet) {
10164 session_deps_.proxy_service.reset( 10214 session_deps_.proxy_service.reset(
10165 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 10215 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"));
10166 CapturingBoundNetLog log; 10216 CapturingBoundNetLog log;
10167 session_deps_.net_log = log.bound().net_log(); 10217 session_deps_.net_log = log.bound().net_log();
10168 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10218 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10169 10219
10170 HttpRequestInfo request; 10220 HttpRequestInfo request;
10171 request.method = "GET"; 10221 request.method = "GET";
(...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after
13086 EXPECT_EQ(ERR_IO_PENDING, rv); 13136 EXPECT_EQ(ERR_IO_PENDING, rv);
13087 13137
13088 rv = callback.WaitForResult(); 13138 rv = callback.WaitForResult();
13089 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 13139 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
13090 13140
13091 const HttpResponseInfo* response = trans->GetResponseInfo(); 13141 const HttpResponseInfo* response = trans->GetResponseInfo();
13092 EXPECT_TRUE(response == NULL); 13142 EXPECT_TRUE(response == NULL);
13093 } 13143 }
13094 13144
13095 } // namespace net 13145 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698