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

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

Issue 1003923002: Revert of Add IsAlternativeServiceBroken(), remove is_broken. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | net/http/http_server_properties.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 8767 matching lines...) Expand 10 before | Expand all | Expand 10 after
8778 MockRead(ASYNC, OK), 8778 MockRead(ASYNC, OK),
8779 }; 8779 };
8780 StaticSocketDataProvider second_data( 8780 StaticSocketDataProvider second_data(
8781 data_reads, arraysize(data_reads), NULL, 0); 8781 data_reads, arraysize(data_reads), NULL, 0);
8782 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 8782 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
8783 8783
8784 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8784 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8785 8785
8786 base::WeakPtr<HttpServerProperties> http_server_properties = 8786 base::WeakPtr<HttpServerProperties> http_server_properties =
8787 session->http_server_properties(); 8787 session->http_server_properties();
8788 const HostPortPair host_port_pair = HostPortPair::FromURL(request.url);
8789 // Port must be < 1024, or the header will be ignored (since initial port was 8788 // Port must be < 1024, or the header will be ignored (since initial port was
8790 // port 80 (another restricted port). 8789 // port 80 (another restricted port).
8791 http_server_properties->SetAlternateProtocol( 8790 http_server_properties->SetAlternateProtocol(
8792 host_port_pair, 666 /* port is ignored by MockConnect anyway */, 8791 HostPortPair::FromURL(request.url),
8792 666 /* port is ignored by MockConnect anyway */,
8793 AlternateProtocolFromNextProto(GetParam()), 1.0); 8793 AlternateProtocolFromNextProto(GetParam()), 1.0);
8794 8794
8795 scoped_ptr<HttpTransaction> trans( 8795 scoped_ptr<HttpTransaction> trans(
8796 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8796 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8797 TestCompletionCallback callback; 8797 TestCompletionCallback callback;
8798 8798
8799 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8799 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8800 EXPECT_EQ(ERR_IO_PENDING, rv); 8800 EXPECT_EQ(ERR_IO_PENDING, rv);
8801 EXPECT_EQ(OK, callback.WaitForResult()); 8801 EXPECT_EQ(OK, callback.WaitForResult());
8802 8802
8803 const HttpResponseInfo* response = trans->GetResponseInfo(); 8803 const HttpResponseInfo* response = trans->GetResponseInfo();
8804 ASSERT_TRUE(response != NULL); 8804 ASSERT_TRUE(response != NULL);
8805 ASSERT_TRUE(response->headers.get() != NULL); 8805 ASSERT_TRUE(response->headers.get() != NULL);
8806 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 8806 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
8807 8807
8808 std::string response_data; 8808 std::string response_data;
8809 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 8809 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
8810 EXPECT_EQ("hello world", response_data); 8810 EXPECT_EQ("hello world", response_data);
8811 8811
8812 const AlternateProtocolInfo alternate = 8812 const AlternateProtocolInfo alternate =
8813 http_server_properties->GetAlternateProtocol(host_port_pair); 8813 http_server_properties->GetAlternateProtocol(
8814 HostPortPair::FromURL(request.url));
8814 EXPECT_NE(UNINITIALIZED_ALTERNATE_PROTOCOL, alternate.protocol); 8815 EXPECT_NE(UNINITIALIZED_ALTERNATE_PROTOCOL, alternate.protocol);
8815 const AlternativeService alternative_service( 8816 EXPECT_TRUE(alternate.is_broken);
8816 alternate.protocol, host_port_pair.host(), alternate.port);
8817 EXPECT_TRUE(
8818 http_server_properties->IsAlternativeServiceBroken(alternative_service));
8819 } 8817 }
8820 8818
8821 TEST_P(HttpNetworkTransactionTest, 8819 TEST_P(HttpNetworkTransactionTest,
8822 AlternateProtocolPortRestrictedBlocked) { 8820 AlternateProtocolPortRestrictedBlocked) {
8823 // Ensure that we're not allowed to redirect traffic via an alternate 8821 // Ensure that we're not allowed to redirect traffic via an alternate
8824 // protocol to an unrestricted (port >= 1024) when the original traffic was 8822 // protocol to an unrestricted (port >= 1024) when the original traffic was
8825 // on a restricted port (port < 1024). Ensure that we can redirect in all 8823 // on a restricted port (port < 1024). Ensure that we can redirect in all
8826 // other cases. 8824 // other cases.
8827 session_deps_.use_alternate_protocols = true; 8825 session_deps_.use_alternate_protocols = true;
8828 8826
(...skipping 4953 matching lines...) Expand 10 before | Expand all | Expand 10 after
13782 ASSERT_TRUE(response); 13780 ASSERT_TRUE(response);
13783 ASSERT_TRUE(response->headers.get()); 13781 ASSERT_TRUE(response->headers.get());
13784 13782
13785 EXPECT_EQ(101, response->headers->response_code()); 13783 EXPECT_EQ(101, response->headers->response_code());
13786 13784
13787 trans.reset(); 13785 trans.reset();
13788 session->CloseAllConnections(); 13786 session->CloseAllConnections();
13789 } 13787 }
13790 13788
13791 } // namespace net 13789 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698