OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 struct SimpleGetHelperResult { | 170 struct SimpleGetHelperResult { |
171 int rv; | 171 int rv; |
172 std::string status_line; | 172 std::string status_line; |
173 std::string response_data; | 173 std::string response_data; |
174 }; | 174 }; |
175 | 175 |
176 virtual void SetUp() { | 176 virtual void SetUp() { |
177 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); | 177 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); |
178 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 178 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
179 MessageLoop::current()->RunAllPending(); | 179 MessageLoop::current()->RunAllPending(); |
180 spdy::SpdyFramer::set_enable_compression_default(false); | |
181 } | 180 } |
182 | 181 |
183 virtual void TearDown() { | 182 virtual void TearDown() { |
184 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 183 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
185 MessageLoop::current()->RunAllPending(); | 184 MessageLoop::current()->RunAllPending(); |
186 spdy::SpdyFramer::set_enable_compression_default(true); | |
187 // Empty the current queue. | 185 // Empty the current queue. |
188 MessageLoop::current()->RunAllPending(); | 186 MessageLoop::current()->RunAllPending(); |
189 PlatformTest::TearDown(); | 187 PlatformTest::TearDown(); |
190 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 188 NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
191 MessageLoop::current()->RunAllPending(); | 189 MessageLoop::current()->RunAllPending(); |
192 } | 190 } |
193 | 191 |
194 // Either |write_failure| specifies a write failure or |read_failure| | 192 // Either |write_failure| specifies a write failure or |read_failure| |
195 // specifies a read failure when using a reused socket. In either case, the | 193 // specifies a read failure when using a reused socket. In either case, the |
196 // failure should cause the network transaction to resend the request, and the | 194 // failure should cause the network transaction to resend the request, and the |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 size_t reads_count) { | 264 size_t reads_count) { |
267 StaticSocketDataProvider reads(data_reads, reads_count, NULL, 0); | 265 StaticSocketDataProvider reads(data_reads, reads_count, NULL, 0); |
268 StaticSocketDataProvider* data[] = { &reads }; | 266 StaticSocketDataProvider* data[] = { &reads }; |
269 return SimpleGetHelperForData(data, 1); | 267 return SimpleGetHelperForData(data, 1); |
270 } | 268 } |
271 | 269 |
272 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, | 270 void ConnectStatusHelperWithExpectedStatus(const MockRead& status, |
273 int expected_status); | 271 int expected_status); |
274 | 272 |
275 void ConnectStatusHelper(const MockRead& status); | 273 void ConnectStatusHelper(const MockRead& status); |
| 274 |
| 275 private: |
| 276 SpdyTestStateHelper spdy_state_; |
276 }; | 277 }; |
277 | 278 |
278 namespace { | 279 namespace { |
279 | 280 |
280 // Fill |str| with a long header list that consumes >= |size| bytes. | 281 // Fill |str| with a long header list that consumes >= |size| bytes. |
281 void FillLargeHeadersString(std::string* str, int size) { | 282 void FillLargeHeadersString(std::string* str, int size) { |
282 const char* row = | 283 const char* row = |
283 "SomeHeaderName: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n"; | 284 "SomeHeaderName: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n"; |
284 const int sizeof_row = strlen(row); | 285 const int sizeof_row = strlen(row); |
285 const int num_rows = static_cast<int>( | 286 const int num_rows = static_cast<int>( |
(...skipping 9094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9380 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9381 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
9381 | 9382 |
9382 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9383 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
9383 | 9384 |
9384 EXPECT_EQ(OK, out.rv); | 9385 EXPECT_EQ(OK, out.rv); |
9385 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9386 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
9386 EXPECT_EQ("hello world", out.response_data); | 9387 EXPECT_EQ("hello world", out.response_data); |
9387 } | 9388 } |
9388 | 9389 |
9389 } // namespace net | 9390 } // namespace net |
OLD | NEW |