| 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/spdy/spdy_proxy_client_socket.h" | 5 #include "net/spdy/spdy_proxy_client_socket.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 0, | 330 0, |
| 331 DATA_FLAG_NONE | 331 DATA_FLAG_NONE |
| 332 }; | 332 }; |
| 333 const char* const kConnectHeaders[] = { | 333 const char* const kConnectHeaders[] = { |
| 334 "method", "CONNECT", | 334 "method", "CONNECT", |
| 335 "url", kOriginHostPort, | 335 "url", kOriginHostPort, |
| 336 "host", kOriginHost, | 336 "host", kOriginHost, |
| 337 "user-agent", kUserAgent, | 337 "user-agent", kUserAgent, |
| 338 "version", "HTTP/1.1", | 338 "version", "HTTP/1.1", |
| 339 }; | 339 }; |
| 340 return ConstructSpdyPacket( | 340 return ConstructSpdyFrame( |
| 341 kSynStartHeader, NULL, 0, kConnectHeaders, arraysize(kConnectHeaders)/2); | 341 kSynStartHeader, NULL, 0, kConnectHeaders, arraysize(kConnectHeaders)/2); |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Constructs a SPDY SYN_STREAM frame for a CONNECT request which includes | 344 // Constructs a SPDY SYN_STREAM frame for a CONNECT request which includes |
| 345 // Proxy-Authorization headers. | 345 // Proxy-Authorization headers. |
| 346 SpdyFrame* | 346 SpdyFrame* |
| 347 SpdyProxyClientSocketSpdy2Test::ConstructConnectAuthRequestFrame() { | 347 SpdyProxyClientSocketSpdy2Test::ConstructConnectAuthRequestFrame() { |
| 348 const SpdyHeaderInfo kSynStartHeader = { | 348 const SpdyHeaderInfo kSynStartHeader = { |
| 349 SYN_STREAM, | 349 SYN_STREAM, |
| 350 kStreamId, | 350 kStreamId, |
| 351 0, | 351 0, |
| 352 net::ConvertRequestPriorityToSpdyPriority(LOWEST, 2), | 352 net::ConvertRequestPriorityToSpdyPriority(LOWEST, 2), |
| 353 CONTROL_FLAG_NONE, | 353 CONTROL_FLAG_NONE, |
| 354 false, | 354 false, |
| 355 RST_STREAM_INVALID, | 355 RST_STREAM_INVALID, |
| 356 NULL, | 356 NULL, |
| 357 0, | 357 0, |
| 358 DATA_FLAG_NONE | 358 DATA_FLAG_NONE |
| 359 }; | 359 }; |
| 360 const char* const kConnectHeaders[] = { | 360 const char* const kConnectHeaders[] = { |
| 361 "method", "CONNECT", | 361 "method", "CONNECT", |
| 362 "url", kOriginHostPort, | 362 "url", kOriginHostPort, |
| 363 "host", kOriginHost, | 363 "host", kOriginHost, |
| 364 "user-agent", kUserAgent, | 364 "user-agent", kUserAgent, |
| 365 "version", "HTTP/1.1", | 365 "version", "HTTP/1.1", |
| 366 "proxy-authorization", "Basic Zm9vOmJhcg==", | 366 "proxy-authorization", "Basic Zm9vOmJhcg==", |
| 367 }; | 367 }; |
| 368 return ConstructSpdyPacket( | 368 return ConstructSpdyFrame( |
| 369 kSynStartHeader, NULL, 0, kConnectHeaders, arraysize(kConnectHeaders)/2); | 369 kSynStartHeader, NULL, 0, kConnectHeaders, arraysize(kConnectHeaders)/2); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY CONNECT. | 372 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY CONNECT. |
| 373 SpdyFrame* SpdyProxyClientSocketSpdy2Test::ConstructConnectReplyFrame() { | 373 SpdyFrame* SpdyProxyClientSocketSpdy2Test::ConstructConnectReplyFrame() { |
| 374 const char* const kStandardReplyHeaders[] = { | 374 const char* const kStandardReplyHeaders[] = { |
| 375 "status", "200 Connection Established", | 375 "status", "200 Connection Established", |
| 376 "version", "HTTP/1.1" | 376 "version", "HTTP/1.1" |
| 377 }; | 377 }; |
| 378 return ConstructSpdyControlFrame(NULL, | 378 return ConstructSpdyControlFrame(NULL, |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 write_callback_.callback())); | 1407 write_callback_.callback())); |
| 1408 | 1408 |
| 1409 Run(2); | 1409 Run(2); |
| 1410 | 1410 |
| 1411 EXPECT_FALSE(sock_.get()); | 1411 EXPECT_FALSE(sock_.get()); |
| 1412 EXPECT_TRUE(read_callback.have_result()); | 1412 EXPECT_TRUE(read_callback.have_result()); |
| 1413 EXPECT_FALSE(write_callback_.have_result()); | 1413 EXPECT_FALSE(write_callback_.have_result()); |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 } // namespace net | 1416 } // namespace net |
| OLD | NEW |