| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 (*block)[spdy_util_.GetMethodKey()] = "CONNECT"; | 291 (*block)[spdy_util_.GetMethodKey()] = "CONNECT"; |
| 292 (*block)[spdy_util_.GetHostKey()] = kOriginHostPort; | 292 (*block)[spdy_util_.GetHostKey()] = kOriginHostPort; |
| 293 (*block)["user-agent"] = kUserAgent; | 293 (*block)["user-agent"] = kUserAgent; |
| 294 } | 294 } |
| 295 | 295 |
| 296 void SpdyProxyClientSocketTest::PopulateConnectReplyIR(SpdyHeaderBlock* block, | 296 void SpdyProxyClientSocketTest::PopulateConnectReplyIR(SpdyHeaderBlock* block, |
| 297 const char* status) { | 297 const char* status) { |
| 298 (*block)[spdy_util_.GetStatusKey()] = status; | 298 (*block)[spdy_util_.GetStatusKey()] = status; |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Constructs a standard SPDY SYN_STREAM frame for a CONNECT request. | 301 // Constructs a standard SPDY HEADERS frame for a CONNECT request. |
| 302 SpdySerializedFrame SpdyProxyClientSocketTest::ConstructConnectRequestFrame() { | 302 SpdySerializedFrame SpdyProxyClientSocketTest::ConstructConnectRequestFrame() { |
| 303 SpdyHeaderBlock block; | 303 SpdyHeaderBlock block; |
| 304 PopulateConnectRequestIR(&block); | 304 PopulateConnectRequestIR(&block); |
| 305 return spdy_util_.ConstructSpdySyn(kStreamId, std::move(block), LOWEST, | 305 return spdy_util_.ConstructSpdyHeaders(kStreamId, std::move(block), LOWEST, |
| 306 false); | 306 false); |
| 307 } | 307 } |
| 308 | 308 |
| 309 // Constructs a SPDY SYN_STREAM frame for a CONNECT request which includes | 309 // Constructs a SPDY HEADERS frame for a CONNECT request which includes |
| 310 // Proxy-Authorization headers. | 310 // Proxy-Authorization headers. |
| 311 SpdySerializedFrame | 311 SpdySerializedFrame |
| 312 SpdyProxyClientSocketTest::ConstructConnectAuthRequestFrame() { | 312 SpdyProxyClientSocketTest::ConstructConnectAuthRequestFrame() { |
| 313 SpdyHeaderBlock block; | 313 SpdyHeaderBlock block; |
| 314 PopulateConnectRequestIR(&block); | 314 PopulateConnectRequestIR(&block); |
| 315 block["proxy-authorization"] = "Basic Zm9vOmJhcg=="; | 315 block["proxy-authorization"] = "Basic Zm9vOmJhcg=="; |
| 316 return spdy_util_.ConstructSpdySyn(kStreamId, std::move(block), LOWEST, | 316 return spdy_util_.ConstructSpdyHeaders(kStreamId, std::move(block), LOWEST, |
| 317 false); | 317 false); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY CONNECT. | 320 // Constructs a standard SPDY HEADERS frame to match the SPDY CONNECT. |
| 321 SpdySerializedFrame SpdyProxyClientSocketTest::ConstructConnectReplyFrame() { | 321 SpdySerializedFrame SpdyProxyClientSocketTest::ConstructConnectReplyFrame() { |
| 322 SpdyHeaderBlock block; | 322 SpdyHeaderBlock block; |
| 323 PopulateConnectReplyIR(&block, "200"); | 323 PopulateConnectReplyIR(&block, "200"); |
| 324 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); | 324 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); |
| 325 } | 325 } |
| 326 | 326 |
| 327 // Constructs a standard SPDY SYN_REPLY frame to match the SPDY CONNECT, | 327 // Constructs a standard SPDY HEADERS frame to match the SPDY CONNECT, |
| 328 // including Proxy-Authenticate headers. | 328 // including Proxy-Authenticate headers. |
| 329 SpdySerializedFrame | 329 SpdySerializedFrame |
| 330 SpdyProxyClientSocketTest::ConstructConnectAuthReplyFrame() { | 330 SpdyProxyClientSocketTest::ConstructConnectAuthReplyFrame() { |
| 331 SpdyHeaderBlock block; | 331 SpdyHeaderBlock block; |
| 332 PopulateConnectReplyIR(&block, "407"); | 332 PopulateConnectReplyIR(&block, "407"); |
| 333 block["proxy-authenticate"] = "Basic realm=\"MyRealm1\""; | 333 block["proxy-authenticate"] = "Basic realm=\"MyRealm1\""; |
| 334 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); | 334 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Constructs a SPDY SYN_REPLY frame with an HTTP 302 redirect. | 337 // Constructs a SPDY HEADERS frame with an HTTP 302 redirect. |
| 338 SpdySerializedFrame | 338 SpdySerializedFrame |
| 339 SpdyProxyClientSocketTest::ConstructConnectRedirectReplyFrame() { | 339 SpdyProxyClientSocketTest::ConstructConnectRedirectReplyFrame() { |
| 340 SpdyHeaderBlock block; | 340 SpdyHeaderBlock block; |
| 341 PopulateConnectReplyIR(&block, "302"); | 341 PopulateConnectReplyIR(&block, "302"); |
| 342 block["location"] = kRedirectUrl; | 342 block["location"] = kRedirectUrl; |
| 343 block["set-cookie"] = "foo=bar"; | 343 block["set-cookie"] = "foo=bar"; |
| 344 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); | 344 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); |
| 345 } | 345 } |
| 346 | 346 |
| 347 // Constructs a SPDY SYN_REPLY frame with an HTTP 500 error. | 347 // Constructs a SPDY HEADERS frame with an HTTP 500 error. |
| 348 SpdySerializedFrame | 348 SpdySerializedFrame |
| 349 SpdyProxyClientSocketTest::ConstructConnectErrorReplyFrame() { | 349 SpdyProxyClientSocketTest::ConstructConnectErrorReplyFrame() { |
| 350 SpdyHeaderBlock block; | 350 SpdyHeaderBlock block; |
| 351 PopulateConnectReplyIR(&block, "500"); | 351 PopulateConnectReplyIR(&block, "500"); |
| 352 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); | 352 return spdy_util_.ConstructSpdyReply(kStreamId, std::move(block)); |
| 353 } | 353 } |
| 354 | 354 |
| 355 SpdySerializedFrame SpdyProxyClientSocketTest::ConstructBodyFrame( | 355 SpdySerializedFrame SpdyProxyClientSocketTest::ConstructBodyFrame( |
| 356 const char* data, | 356 const char* data, |
| 357 int length) { | 357 int length) { |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 | 1343 |
| 1344 EXPECT_FALSE(sock_.get()); | 1344 EXPECT_FALSE(sock_.get()); |
| 1345 EXPECT_TRUE(read_callback.have_result()); | 1345 EXPECT_TRUE(read_callback.have_result()); |
| 1346 EXPECT_FALSE(write_callback_.have_result()); | 1346 EXPECT_FALSE(write_callback_.have_result()); |
| 1347 | 1347 |
| 1348 // Let the RST_STREAM write while |rst| is in-scope. | 1348 // Let the RST_STREAM write while |rst| is in-scope. |
| 1349 base::RunLoop().RunUntilIdle(); | 1349 base::RunLoop().RunUntilIdle(); |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 } // namespace net | 1352 } // namespace net |
| OLD | NEW |