| OLD | NEW |
| 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 <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 4766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4777 CreateMockWrite(req_get, 0), CreateMockWrite(req_get_authorization, 3), | 4777 CreateMockWrite(req_get, 0), CreateMockWrite(req_get_authorization, 3), |
| 4778 }; | 4778 }; |
| 4779 | 4779 |
| 4780 // The first response is a 407 proxy authentication challenge, and the second | 4780 // The first response is a 407 proxy authentication challenge, and the second |
| 4781 // response will be a 200 response since the second request includes a valid | 4781 // response will be a 200 response since the second request includes a valid |
| 4782 // Authorization header. | 4782 // Authorization header. |
| 4783 const char* const kExtraAuthenticationHeaders[] = { | 4783 const char* const kExtraAuthenticationHeaders[] = { |
| 4784 "proxy-authenticate", "Basic realm=\"MyRealm1\"" | 4784 "proxy-authenticate", "Basic realm=\"MyRealm1\"" |
| 4785 }; | 4785 }; |
| 4786 SpdySerializedFrame resp_authentication(spdy_util_.ConstructSpdyReplyError( | 4786 SpdySerializedFrame resp_authentication(spdy_util_.ConstructSpdyReplyError( |
| 4787 "407 Proxy Authentication Required", kExtraAuthenticationHeaders, | 4787 "407", kExtraAuthenticationHeaders, |
| 4788 arraysize(kExtraAuthenticationHeaders) / 2, 1)); | 4788 arraysize(kExtraAuthenticationHeaders) / 2, 1)); |
| 4789 SpdySerializedFrame body_authentication( | 4789 SpdySerializedFrame body_authentication( |
| 4790 spdy_util_.ConstructSpdyDataFrame(1, true)); | 4790 spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 4791 SpdySerializedFrame resp_data(spdy_util_.ConstructSpdyGetReply(NULL, 0, 3)); | 4791 SpdySerializedFrame resp_data(spdy_util_.ConstructSpdyGetReply(NULL, 0, 3)); |
| 4792 SpdySerializedFrame body_data(spdy_util_.ConstructSpdyDataFrame(3, true)); | 4792 SpdySerializedFrame body_data(spdy_util_.ConstructSpdyDataFrame(3, true)); |
| 4793 MockRead spdy_reads[] = { | 4793 MockRead spdy_reads[] = { |
| 4794 CreateMockRead(resp_authentication, 1), | 4794 CreateMockRead(resp_authentication, 1), |
| 4795 CreateMockRead(body_authentication, 2), | 4795 CreateMockRead(body_authentication, 2), |
| 4796 CreateMockRead(resp_data, 4), | 4796 CreateMockRead(resp_data, 4), |
| 4797 CreateMockRead(body_data, 5), | 4797 CreateMockRead(body_data, 5), |
| (...skipping 3068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7866 MockWrite data_writes[] = { | 7866 MockWrite data_writes[] = { |
| 7867 CreateMockWrite(conn, 0, SYNCHRONOUS), | 7867 CreateMockWrite(conn, 0, SYNCHRONOUS), |
| 7868 CreateMockWrite(goaway, 2, SYNCHRONOUS), | 7868 CreateMockWrite(goaway, 2, SYNCHRONOUS), |
| 7869 }; | 7869 }; |
| 7870 | 7870 |
| 7871 static const char* const kExtraHeaders[] = { | 7871 static const char* const kExtraHeaders[] = { |
| 7872 "location", | 7872 "location", |
| 7873 "http://login.example.com/", | 7873 "http://login.example.com/", |
| 7874 }; | 7874 }; |
| 7875 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError( | 7875 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError( |
| 7876 "302 Redirect", kExtraHeaders, arraysize(kExtraHeaders) / 2, 1)); | 7876 "302", kExtraHeaders, arraysize(kExtraHeaders) / 2, 1)); |
| 7877 MockRead data_reads[] = { | 7877 MockRead data_reads[] = { |
| 7878 CreateMockRead(resp, 1), MockRead(ASYNC, 0, 3), // EOF | 7878 CreateMockRead(resp, 1), MockRead(ASYNC, 0, 3), // EOF |
| 7879 }; | 7879 }; |
| 7880 | 7880 |
| 7881 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes, | 7881 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes, |
| 7882 arraysize(data_writes)); | 7882 arraysize(data_writes)); |
| 7883 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 7883 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| 7884 proxy_ssl.next_proto = kProtoHTTP2; | 7884 proxy_ssl.next_proto = kProtoHTTP2; |
| 7885 | 7885 |
| 7886 session_deps_.socket_factory->AddSocketDataProvider(&data); | 7886 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7962 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 7962 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
| 7963 MockWrite data_writes[] = { | 7963 MockWrite data_writes[] = { |
| 7964 CreateMockWrite(conn, 0), CreateMockWrite(rst, 3), | 7964 CreateMockWrite(conn, 0), CreateMockWrite(rst, 3), |
| 7965 }; | 7965 }; |
| 7966 | 7966 |
| 7967 static const char* const kExtraHeaders[] = { | 7967 static const char* const kExtraHeaders[] = { |
| 7968 "location", | 7968 "location", |
| 7969 "http://login.example.com/", | 7969 "http://login.example.com/", |
| 7970 }; | 7970 }; |
| 7971 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError( | 7971 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError( |
| 7972 "404 Not Found", kExtraHeaders, arraysize(kExtraHeaders) / 2, 1)); | 7972 "404", kExtraHeaders, arraysize(kExtraHeaders) / 2, 1)); |
| 7973 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame( | 7973 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame( |
| 7974 1, "The host does not exist", 23, true)); | 7974 1, "The host does not exist", 23, true)); |
| 7975 MockRead data_reads[] = { | 7975 MockRead data_reads[] = { |
| 7976 CreateMockRead(resp, 1), CreateMockRead(body, 2), | 7976 CreateMockRead(resp, 1), CreateMockRead(body, 2), |
| 7977 MockRead(ASYNC, 0, 4), // EOF | 7977 MockRead(ASYNC, 0, 4), // EOF |
| 7978 }; | 7978 }; |
| 7979 | 7979 |
| 7980 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes, | 7980 SequencedSocketData data(data_reads, arraysize(data_reads), data_writes, |
| 7981 arraysize(data_writes)); | 7981 arraysize(data_writes)); |
| 7982 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 7982 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| (...skipping 8518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16501 base::RunLoop().RunUntilIdle(); | 16501 base::RunLoop().RunUntilIdle(); |
| 16502 | 16502 |
| 16503 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 16503 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 16504 HttpRequestHeaders headers; | 16504 HttpRequestHeaders headers; |
| 16505 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 16505 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 16506 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 16506 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 16507 } | 16507 } |
| 16508 #endif // !defined(OS_IOS) | 16508 #endif // !defined(OS_IOS) |
| 16509 | 16509 |
| 16510 } // namespace net | 16510 } // namespace net |
| OLD | NEW |