 Chromium Code Reviews
 Chromium Code Reviews Issue 7289006:
  Basic HTTP pipelining support  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 7289006:
  Basic HTTP pipelining support  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| (...skipping 8963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8974 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8974 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 
| 8975 EXPECT_TRUE(response->was_fetched_via_spdy); | 8975 EXPECT_TRUE(response->was_fetched_via_spdy); | 
| 8976 EXPECT_TRUE(response->was_npn_negotiated); | 8976 EXPECT_TRUE(response->was_npn_negotiated); | 
| 8977 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 8977 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 
| 8978 EXPECT_EQ("hello!", response_data); | 8978 EXPECT_EQ("hello!", response_data); | 
| 8979 | 8979 | 
| 8980 HttpStreamFactory::set_next_protos(""); | 8980 HttpStreamFactory::set_next_protos(""); | 
| 8981 HttpStreamFactory::set_use_alternate_protocols(false); | 8981 HttpStreamFactory::set_use_alternate_protocols(false); | 
| 8982 } | 8982 } | 
| 8983 | 8983 | 
| 8984 TEST_F(HttpNetworkTransactionTest, ReadPipelineEvictionFallback) { | |
| 8985 MockRead data_reads1[] = { | |
| 8986 MockRead(false, ERR_PIPELINE_EVICTION), | |
| 8987 }; | |
| 8988 MockRead data_reads2[] = { | |
| 8989 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | |
| 8990 MockRead("hello world"), | |
| 8991 MockRead(false, OK), | |
| 8992 }; | |
| 8993 SimpleGetHelperResult out; | |
| 8994 | |
| 8995 HttpRequestInfo request; | |
| 8996 request.method = "GET"; | |
| 8997 request.url = GURL("http://www.google.com/"); | |
| 8998 request.load_flags = 0; | |
| 8999 | |
| 9000 SessionDependencies session_deps; | |
| 9001 scoped_ptr<HttpTransaction> trans( | |
| 9002 new HttpNetworkTransaction(CreateSession(&session_deps))); | |
| 9003 | |
| 9004 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), NULL, 0); | |
| 9005 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), NULL, 0); | |
| 9006 session_deps.socket_factory.AddSocketDataProvider(&data1); | |
| 9007 session_deps.socket_factory.AddSocketDataProvider(&data2); | |
| 9008 | |
| 9009 TestCompletionCallback callback; | |
| 
mmenke
2011/09/15 19:28:16
You're duplicating a fair bit of code here.  I thi
 
James Simonsen
2011/09/17 01:23:02
Done.
 | |
| 9010 | |
| 9011 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | |
| 9012 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); | |
| 
mmenke
2011/09/15 19:28:16
nit:  Not needed, since you aren't validating even
 
James Simonsen
2011/09/17 01:23:02
Removed.
 | |
| 9013 int rv = trans->Start(&request, &callback, log.bound()); | |
| 9014 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 9015 | |
| 9016 out.rv = callback.WaitForResult(); | |
| 9017 | |
| 9018 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 9019 EXPECT_TRUE(response != NULL); | |
| 9020 | |
| 9021 EXPECT_TRUE(response->headers != NULL); | |
| 9022 out.status_line = response->headers->GetStatusLine(); | |
| 9023 | |
| 9024 rv = ReadTransaction(trans.get(), &out.response_data); | |
| 9025 EXPECT_EQ(OK, rv); | |
| 9026 | |
| 9027 EXPECT_EQ(OK, out.rv); | |
| 9028 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | |
| 9029 EXPECT_EQ("hello world", out.response_data); | |
| 9030 } | |
| 9031 | |
| 9032 TEST_F(HttpNetworkTransactionTest, SendPipelineEvictionFallback) { | |
| 9033 MockWrite data_writes1[] = { | |
| 9034 MockWrite(false, ERR_PIPELINE_EVICTION), | |
| 9035 }; | |
| 9036 MockWrite data_writes2[] = { | |
| 9037 MockWrite("GET / HTTP/1.1\r\n" | |
| 9038 "Host: www.google.com\r\n" | |
| 9039 "Connection: keep-alive\r\n\r\n"), | |
| 9040 }; | |
| 9041 MockRead data_reads2[] = { | |
| 9042 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | |
| 9043 MockRead("hello world"), | |
| 9044 MockRead(false, OK), | |
| 9045 }; | |
| 9046 SimpleGetHelperResult out; | |
| 9047 | |
| 9048 HttpRequestInfo request; | |
| 9049 request.method = "GET"; | |
| 9050 request.url = GURL("http://www.google.com/"); | |
| 9051 request.load_flags = 0; | |
| 9052 | |
| 9053 SessionDependencies session_deps; | |
| 9054 scoped_ptr<HttpTransaction> trans( | |
| 9055 new HttpNetworkTransaction(CreateSession(&session_deps))); | |
| 9056 | |
| 9057 StaticSocketDataProvider data1(NULL, 0, | |
| 9058 data_writes1, arraysize(data_writes1)); | |
| 9059 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | |
| 9060 data_writes2, arraysize(data_writes2)); | |
| 9061 session_deps.socket_factory.AddSocketDataProvider(&data1); | |
| 9062 session_deps.socket_factory.AddSocketDataProvider(&data2); | |
| 9063 | |
| 9064 TestCompletionCallback callback; | |
| 9065 | |
| 9066 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | |
| 9067 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); | |
| 
mmenke
2011/09/15 19:28:16
nit:  Not needed, since you aren't validating even
 
James Simonsen
2011/09/17 01:23:02
Removed.
 | |
| 9068 int rv = trans->Start(&request, &callback, log.bound()); | |
| 9069 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 9070 | |
| 9071 out.rv = callback.WaitForResult(); | |
| 9072 | |
| 9073 const HttpResponseInfo* response = trans->GetResponseInfo(); | |
| 9074 EXPECT_TRUE(response != NULL); | |
| 9075 EXPECT_TRUE(response->headers != NULL); | |
| 9076 out.status_line = response->headers->GetStatusLine(); | |
| 9077 | |
| 9078 rv = ReadTransaction(trans.get(), &out.response_data); | |
| 9079 EXPECT_EQ(OK, rv); | |
| 9080 | |
| 9081 EXPECT_EQ(OK, out.rv); | |
| 9082 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | |
| 9083 EXPECT_EQ("hello world", out.response_data); | |
| 9084 } | |
| 9085 | |
| 8984 } // namespace net | 9086 } // namespace net | 
| OLD | NEW |