Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 2675593002: Spdy{RstStream,GoAway}Status -> SpdyErrorCode. (Closed)
Patch Set: Merged master, which includes 145087791. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5011 matching lines...) Expand 10 before | Expand all | Expand 10 after
5022 BoundTestNetLog log; 5022 BoundTestNetLog log;
5023 session_deps_.net_log = log.bound().net_log(); 5023 session_deps_.net_log = log.bound().net_log();
5024 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5024 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5025 5025
5026 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 5026 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
5027 5027
5028 // CONNECT to www.example.org:443 via SPDY 5028 // CONNECT to www.example.org:443 via SPDY
5029 SpdySerializedFrame connect(spdy_util_.ConstructSpdyConnect( 5029 SpdySerializedFrame connect(spdy_util_.ConstructSpdyConnect(
5030 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 5030 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
5031 SpdySerializedFrame get( 5031 SpdySerializedFrame get(
5032 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 5032 spdy_util_.ConstructSpdyRstStream(1, ERROR_CODE_CANCEL));
5033 5033
5034 MockWrite spdy_writes[] = { 5034 MockWrite spdy_writes[] = {
5035 CreateMockWrite(connect, 0), CreateMockWrite(get, 2), 5035 CreateMockWrite(connect, 0), CreateMockWrite(get, 2),
5036 }; 5036 };
5037 5037
5038 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError(1)); 5038 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError(1));
5039 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); 5039 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true));
5040 MockRead spdy_reads[] = { 5040 MockRead spdy_reads[] = {
5041 CreateMockRead(resp, 1, ASYNC), MockRead(ASYNC, 0, 3), 5041 CreateMockRead(resp, 1, ASYNC), MockRead(ASYNC, 0, 3),
5042 }; 5042 };
(...skipping 2814 matching lines...) Expand 10 before | Expand all | Expand 10 after
7857 TEST_F(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) { 7857 TEST_F(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) {
7858 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70"); 7858 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
7859 7859
7860 HttpRequestInfo request; 7860 HttpRequestInfo request;
7861 request.method = "GET"; 7861 request.method = "GET";
7862 request.url = GURL("https://www.example.org/"); 7862 request.url = GURL("https://www.example.org/");
7863 7863
7864 SpdySerializedFrame conn(spdy_util_.ConstructSpdyConnect( 7864 SpdySerializedFrame conn(spdy_util_.ConstructSpdyConnect(
7865 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 7865 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
7866 SpdySerializedFrame goaway( 7866 SpdySerializedFrame goaway(
7867 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 7867 spdy_util_.ConstructSpdyRstStream(1, ERROR_CODE_CANCEL));
7868 MockWrite data_writes[] = { 7868 MockWrite data_writes[] = {
7869 CreateMockWrite(conn, 0, SYNCHRONOUS), 7869 CreateMockWrite(conn, 0, SYNCHRONOUS),
7870 CreateMockWrite(goaway, 2, SYNCHRONOUS), 7870 CreateMockWrite(goaway, 2, SYNCHRONOUS),
7871 }; 7871 };
7872 7872
7873 static const char* const kExtraHeaders[] = { 7873 static const char* const kExtraHeaders[] = {
7874 "location", 7874 "location",
7875 "http://login.example.com/", 7875 "http://login.example.com/",
7876 }; 7876 };
7877 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError( 7877 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
7954 TEST_F(HttpNetworkTransactionTest, ErrorResponseToHttpsConnectViaSpdyProxy) { 7954 TEST_F(HttpNetworkTransactionTest, ErrorResponseToHttpsConnectViaSpdyProxy) {
7955 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70"); 7955 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
7956 7956
7957 HttpRequestInfo request; 7957 HttpRequestInfo request;
7958 request.method = "GET"; 7958 request.method = "GET";
7959 request.url = GURL("https://www.example.org/"); 7959 request.url = GURL("https://www.example.org/");
7960 7960
7961 SpdySerializedFrame conn(spdy_util_.ConstructSpdyConnect( 7961 SpdySerializedFrame conn(spdy_util_.ConstructSpdyConnect(
7962 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 7962 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
7963 SpdySerializedFrame rst( 7963 SpdySerializedFrame rst(
7964 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 7964 spdy_util_.ConstructSpdyRstStream(1, ERROR_CODE_CANCEL));
7965 MockWrite data_writes[] = { 7965 MockWrite data_writes[] = {
7966 CreateMockWrite(conn, 0), CreateMockWrite(rst, 3), 7966 CreateMockWrite(conn, 0), CreateMockWrite(rst, 3),
7967 }; 7967 };
7968 7968
7969 static const char* const kExtraHeaders[] = { 7969 static const char* const kExtraHeaders[] = {
7970 "location", 7970 "location",
7971 "http://login.example.com/", 7971 "http://login.example.com/",
7972 }; 7972 };
7973 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError( 7973 SpdySerializedFrame resp(spdy_util_.ConstructSpdyReplyError(
7974 "404", kExtraHeaders, arraysize(kExtraHeaders) / 2, 1)); 7974 "404", kExtraHeaders, arraysize(kExtraHeaders) / 2, 1));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
8014 session_deps_.proxy_service = 8014 session_deps_.proxy_service =
8015 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70"); 8015 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70");
8016 BoundTestNetLog log; 8016 BoundTestNetLog log;
8017 session_deps_.net_log = log.bound().net_log(); 8017 session_deps_.net_log = log.bound().net_log();
8018 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8018 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8019 8019
8020 // Since we have proxy, should try to establish tunnel. 8020 // Since we have proxy, should try to establish tunnel.
8021 SpdySerializedFrame req(spdy_util_.ConstructSpdyConnect( 8021 SpdySerializedFrame req(spdy_util_.ConstructSpdyConnect(
8022 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 8022 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
8023 SpdySerializedFrame rst( 8023 SpdySerializedFrame rst(
8024 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 8024 spdy_util_.ConstructSpdyRstStream(1, ERROR_CODE_CANCEL));
8025 spdy_util_.UpdateWithStreamDestruction(1); 8025 spdy_util_.UpdateWithStreamDestruction(1);
8026 8026
8027 // After calling trans.RestartWithAuth(), this is the request we should 8027 // After calling trans.RestartWithAuth(), this is the request we should
8028 // be issuing -- the final header line contains the credentials. 8028 // be issuing -- the final header line contains the credentials.
8029 const char* const kAuthCredentials[] = { 8029 const char* const kAuthCredentials[] = {
8030 "proxy-authorization", "Basic Zm9vOmJhcg==", 8030 "proxy-authorization", "Basic Zm9vOmJhcg==",
8031 }; 8031 };
8032 SpdySerializedFrame connect2(spdy_util_.ConstructSpdyConnect( 8032 SpdySerializedFrame connect2(spdy_util_.ConstructSpdyConnect(
8033 kAuthCredentials, arraysize(kAuthCredentials) / 2, 3, LOWEST, 8033 kAuthCredentials, arraysize(kAuthCredentials) / 2, 3, LOWEST,
8034 HostPortPair("www.example.org", 443))); 8034 HostPortPair("www.example.org", 443)));
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
8274 8274
8275 // Enable cross-origin push. 8275 // Enable cross-origin push.
8276 session_deps_.proxy_delegate = std::move(proxy_delegate); 8276 session_deps_.proxy_delegate = std::move(proxy_delegate);
8277 8277
8278 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8278 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8279 8279
8280 SpdySerializedFrame stream1_syn( 8280 SpdySerializedFrame stream1_syn(
8281 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST)); 8281 spdy_util_.ConstructSpdyGet("http://www.example.org/", 1, LOWEST));
8282 8282
8283 SpdySerializedFrame push_rst( 8283 SpdySerializedFrame push_rst(
8284 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); 8284 spdy_util_.ConstructSpdyRstStream(2, ERROR_CODE_REFUSED_STREAM));
8285 8285
8286 MockWrite spdy_writes[] = { 8286 MockWrite spdy_writes[] = {
8287 CreateMockWrite(stream1_syn, 0, ASYNC), CreateMockWrite(push_rst, 3), 8287 CreateMockWrite(stream1_syn, 0, ASYNC), CreateMockWrite(push_rst, 3),
8288 }; 8288 };
8289 8289
8290 SpdySerializedFrame stream1_reply( 8290 SpdySerializedFrame stream1_reply(
8291 spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); 8291 spdy_util_.ConstructSpdyGetReply(NULL, 0, 1));
8292 8292
8293 SpdySerializedFrame stream1_body(spdy_util_.ConstructSpdyDataFrame(1, true)); 8293 SpdySerializedFrame stream1_body(spdy_util_.ConstructSpdyDataFrame(1, true));
8294 8294
(...skipping 8299 matching lines...) Expand 10 before | Expand all | Expand 10 after
16594 ASSERT_THAT(rv, IsOk()); 16594 ASSERT_THAT(rv, IsOk());
16595 16595
16596 const HttpResponseInfo* response = trans.GetResponseInfo(); 16596 const HttpResponseInfo* response = trans.GetResponseInfo();
16597 ASSERT_TRUE(response); 16597 ASSERT_TRUE(response);
16598 ASSERT_TRUE(response->headers); 16598 ASSERT_TRUE(response->headers);
16599 EXPECT_EQ("HTTP/1.1 101 Switching Protocols", 16599 EXPECT_EQ("HTTP/1.1 101 Switching Protocols",
16600 response->headers->GetStatusLine()); 16600 response->headers->GetStatusLine());
16601 } 16601 }
16602 16602
16603 } // namespace net 16603 } // namespace net
OLDNEW
« no previous file with comments | « net/http/bidirectional_stream_unittest.cc ('k') | net/http/http_proxy_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698