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

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

Issue 882973006: Lint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | net/http/http_server_properties_impl.cc » ('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 7598 matching lines...) Expand 10 before | Expand all | Expand 10 after
7609 7609
7610 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( 7610 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests(
7611 NextProto next_proto, 7611 NextProto next_proto,
7612 SpdySessionDependencies* session_deps_) { 7612 SpdySessionDependencies* session_deps_) {
7613 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps_)); 7613 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps_));
7614 7614
7615 base::WeakPtr<HttpServerProperties> http_server_properties = 7615 base::WeakPtr<HttpServerProperties> http_server_properties =
7616 session->http_server_properties(); 7616 session->http_server_properties();
7617 http_server_properties->SetAlternateProtocol( 7617 http_server_properties->SetAlternateProtocol(
7618 HostPortPair("host.with.alternate", 80), 443, 7618 HostPortPair("host.with.alternate", 80), 443,
7619 AlternateProtocolFromNextProto(next_proto), 1); 7619 AlternateProtocolFromNextProto(next_proto), 1.0);
Ryan Hamilton 2015/01/30 17:29:14 I'm not clear why this change is needed. The compi
7620 7620
7621 return session; 7621 return session;
7622 } 7622 }
7623 7623
7624 int GroupNameTransactionHelper( 7624 int GroupNameTransactionHelper(
7625 const std::string& url, 7625 const std::string& url,
7626 const scoped_refptr<HttpNetworkSession>& session) { 7626 const scoped_refptr<HttpNetworkSession>& session) {
7627 HttpRequestInfo request; 7627 HttpRequestInfo request;
7628 request.method = "GET"; 7628 request.method = "GET";
7629 request.url = GURL(url); 7629 request.url = GURL(url);
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
8557 8557
8558 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8558 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8559 8559
8560 base::WeakPtr<HttpServerProperties> http_server_properties = 8560 base::WeakPtr<HttpServerProperties> http_server_properties =
8561 session->http_server_properties(); 8561 session->http_server_properties();
8562 // Port must be < 1024, or the header will be ignored (since initial port was 8562 // Port must be < 1024, or the header will be ignored (since initial port was
8563 // port 80 (another restricted port). 8563 // port 80 (another restricted port).
8564 http_server_properties->SetAlternateProtocol( 8564 http_server_properties->SetAlternateProtocol(
8565 HostPortPair::FromURL(request.url), 8565 HostPortPair::FromURL(request.url),
8566 666 /* port is ignored by MockConnect anyway */, 8566 666 /* port is ignored by MockConnect anyway */,
8567 AlternateProtocolFromNextProto(GetParam()), 1); 8567 AlternateProtocolFromNextProto(GetParam()), 1.0);
8568 8568
8569 scoped_ptr<HttpTransaction> trans( 8569 scoped_ptr<HttpTransaction> trans(
8570 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8570 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8571 TestCompletionCallback callback; 8571 TestCompletionCallback callback;
8572 8572
8573 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8573 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8574 EXPECT_EQ(ERR_IO_PENDING, rv); 8574 EXPECT_EQ(ERR_IO_PENDING, rv);
8575 EXPECT_EQ(OK, callback.WaitForResult()); 8575 EXPECT_EQ(OK, callback.WaitForResult());
8576 8576
8577 const HttpResponseInfo* response = trans->GetResponseInfo(); 8577 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8618 data_reads, arraysize(data_reads), NULL, 0); 8618 data_reads, arraysize(data_reads), NULL, 0);
8619 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 8619 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
8620 8620
8621 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8621 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8622 8622
8623 base::WeakPtr<HttpServerProperties> http_server_properties = 8623 base::WeakPtr<HttpServerProperties> http_server_properties =
8624 session->http_server_properties(); 8624 session->http_server_properties();
8625 const int kUnrestrictedAlternatePort = 1024; 8625 const int kUnrestrictedAlternatePort = 1024;
8626 http_server_properties->SetAlternateProtocol( 8626 http_server_properties->SetAlternateProtocol(
8627 HostPortPair::FromURL(restricted_port_request.url), 8627 HostPortPair::FromURL(restricted_port_request.url),
8628 kUnrestrictedAlternatePort, 8628 kUnrestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
8629 AlternateProtocolFromNextProto(GetParam()), 1); 8629 1.0);
8630 8630
8631 scoped_ptr<HttpTransaction> trans( 8631 scoped_ptr<HttpTransaction> trans(
8632 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8632 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8633 TestCompletionCallback callback; 8633 TestCompletionCallback callback;
8634 8634
8635 int rv = trans->Start( 8635 int rv = trans->Start(
8636 &restricted_port_request, 8636 &restricted_port_request,
8637 callback.callback(), BoundNetLog()); 8637 callback.callback(), BoundNetLog());
8638 EXPECT_EQ(ERR_IO_PENDING, rv); 8638 EXPECT_EQ(ERR_IO_PENDING, rv);
8639 // Invalid change to unrestricted port should fail. 8639 // Invalid change to unrestricted port should fail.
(...skipping 29 matching lines...) Expand all
8669 data_reads, arraysize(data_reads), NULL, 0); 8669 data_reads, arraysize(data_reads), NULL, 0);
8670 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 8670 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
8671 8671
8672 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8672 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8673 8673
8674 base::WeakPtr<HttpServerProperties> http_server_properties = 8674 base::WeakPtr<HttpServerProperties> http_server_properties =
8675 session->http_server_properties(); 8675 session->http_server_properties();
8676 const int kUnrestrictedAlternatePort = 1024; 8676 const int kUnrestrictedAlternatePort = 1024;
8677 http_server_properties->SetAlternateProtocol( 8677 http_server_properties->SetAlternateProtocol(
8678 HostPortPair::FromURL(restricted_port_request.url), 8678 HostPortPair::FromURL(restricted_port_request.url),
8679 kUnrestrictedAlternatePort, 8679 kUnrestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
8680 AlternateProtocolFromNextProto(GetParam()), 1); 8680 1.0);
8681 8681
8682 scoped_ptr<HttpTransaction> trans( 8682 scoped_ptr<HttpTransaction> trans(
8683 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8683 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8684 TestCompletionCallback callback; 8684 TestCompletionCallback callback;
8685 8685
8686 EXPECT_EQ(ERR_IO_PENDING, trans->Start( 8686 EXPECT_EQ(ERR_IO_PENDING, trans->Start(
8687 &restricted_port_request, 8687 &restricted_port_request,
8688 callback.callback(), BoundNetLog())); 8688 callback.callback(), BoundNetLog()));
8689 // Change to unrestricted port should succeed. 8689 // Change to unrestricted port should succeed.
8690 EXPECT_EQ(OK, callback.WaitForResult()); 8690 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 26 matching lines...) Expand all
8717 data_reads, arraysize(data_reads), NULL, 0); 8717 data_reads, arraysize(data_reads), NULL, 0);
8718 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 8718 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
8719 8719
8720 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8720 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8721 8721
8722 base::WeakPtr<HttpServerProperties> http_server_properties = 8722 base::WeakPtr<HttpServerProperties> http_server_properties =
8723 session->http_server_properties(); 8723 session->http_server_properties();
8724 const int kRestrictedAlternatePort = 80; 8724 const int kRestrictedAlternatePort = 80;
8725 http_server_properties->SetAlternateProtocol( 8725 http_server_properties->SetAlternateProtocol(
8726 HostPortPair::FromURL(restricted_port_request.url), 8726 HostPortPair::FromURL(restricted_port_request.url),
8727 kRestrictedAlternatePort, 8727 kRestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
8728 AlternateProtocolFromNextProto(GetParam()), 1); 8728 1.0);
8729 8729
8730 scoped_ptr<HttpTransaction> trans( 8730 scoped_ptr<HttpTransaction> trans(
8731 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8731 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8732 TestCompletionCallback callback; 8732 TestCompletionCallback callback;
8733 8733
8734 int rv = trans->Start( 8734 int rv = trans->Start(
8735 &restricted_port_request, 8735 &restricted_port_request,
8736 callback.callback(), BoundNetLog()); 8736 callback.callback(), BoundNetLog());
8737 EXPECT_EQ(ERR_IO_PENDING, rv); 8737 EXPECT_EQ(ERR_IO_PENDING, rv);
8738 // Valid change to restricted port should pass. 8738 // Valid change to restricted port should pass.
(...skipping 27 matching lines...) Expand all
8766 data_reads, arraysize(data_reads), NULL, 0); 8766 data_reads, arraysize(data_reads), NULL, 0);
8767 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 8767 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
8768 8768
8769 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8769 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8770 8770
8771 base::WeakPtr<HttpServerProperties> http_server_properties = 8771 base::WeakPtr<HttpServerProperties> http_server_properties =
8772 session->http_server_properties(); 8772 session->http_server_properties();
8773 const int kRestrictedAlternatePort = 80; 8773 const int kRestrictedAlternatePort = 80;
8774 http_server_properties->SetAlternateProtocol( 8774 http_server_properties->SetAlternateProtocol(
8775 HostPortPair::FromURL(unrestricted_port_request.url), 8775 HostPortPair::FromURL(unrestricted_port_request.url),
8776 kRestrictedAlternatePort, 8776 kRestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
8777 AlternateProtocolFromNextProto(GetParam()), 1); 8777 1.0);
8778 8778
8779 scoped_ptr<HttpTransaction> trans( 8779 scoped_ptr<HttpTransaction> trans(
8780 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8780 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8781 TestCompletionCallback callback; 8781 TestCompletionCallback callback;
8782 8782
8783 int rv = trans->Start( 8783 int rv = trans->Start(
8784 &unrestricted_port_request, callback.callback(), BoundNetLog()); 8784 &unrestricted_port_request, callback.callback(), BoundNetLog());
8785 EXPECT_EQ(ERR_IO_PENDING, rv); 8785 EXPECT_EQ(ERR_IO_PENDING, rv);
8786 // Valid change to restricted port should pass. 8786 // Valid change to restricted port should pass.
8787 EXPECT_EQ(OK, callback.WaitForResult()); 8787 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 26 matching lines...) Expand all
8814 data_reads, arraysize(data_reads), NULL, 0); 8814 data_reads, arraysize(data_reads), NULL, 0);
8815 session_deps_.socket_factory->AddSocketDataProvider(&second_data); 8815 session_deps_.socket_factory->AddSocketDataProvider(&second_data);
8816 8816
8817 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8817 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8818 8818
8819 base::WeakPtr<HttpServerProperties> http_server_properties = 8819 base::WeakPtr<HttpServerProperties> http_server_properties =
8820 session->http_server_properties(); 8820 session->http_server_properties();
8821 const int kUnrestrictedAlternatePort = 1024; 8821 const int kUnrestrictedAlternatePort = 1024;
8822 http_server_properties->SetAlternateProtocol( 8822 http_server_properties->SetAlternateProtocol(
8823 HostPortPair::FromURL(unrestricted_port_request.url), 8823 HostPortPair::FromURL(unrestricted_port_request.url),
8824 kUnrestrictedAlternatePort, 8824 kUnrestrictedAlternatePort, AlternateProtocolFromNextProto(GetParam()),
8825 AlternateProtocolFromNextProto(GetParam()), 1); 8825 1.0);
8826 8826
8827 scoped_ptr<HttpTransaction> trans( 8827 scoped_ptr<HttpTransaction> trans(
8828 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8828 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8829 TestCompletionCallback callback; 8829 TestCompletionCallback callback;
8830 8830
8831 int rv = trans->Start( 8831 int rv = trans->Start(
8832 &unrestricted_port_request, callback.callback(), BoundNetLog()); 8832 &unrestricted_port_request, callback.callback(), BoundNetLog());
8833 EXPECT_EQ(ERR_IO_PENDING, rv); 8833 EXPECT_EQ(ERR_IO_PENDING, rv);
8834 // Valid change to an unrestricted port should pass. 8834 // Valid change to an unrestricted port should pass.
8835 EXPECT_EQ(OK, callback.WaitForResult()); 8835 EXPECT_EQ(OK, callback.WaitForResult());
(...skipping 20 matching lines...) Expand all
8856 StaticSocketDataProvider data( 8856 StaticSocketDataProvider data(
8857 data_reads, arraysize(data_reads), NULL, 0); 8857 data_reads, arraysize(data_reads), NULL, 0);
8858 session_deps_.socket_factory->AddSocketDataProvider(&data); 8858 session_deps_.socket_factory->AddSocketDataProvider(&data);
8859 8859
8860 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8860 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8861 8861
8862 base::WeakPtr<HttpServerProperties> http_server_properties = 8862 base::WeakPtr<HttpServerProperties> http_server_properties =
8863 session->http_server_properties(); 8863 session->http_server_properties();
8864 const int kUnsafePort = 7; 8864 const int kUnsafePort = 7;
8865 http_server_properties->SetAlternateProtocol( 8865 http_server_properties->SetAlternateProtocol(
8866 HostPortPair::FromURL(request.url), 8866 HostPortPair::FromURL(request.url), kUnsafePort,
8867 kUnsafePort, 8867 AlternateProtocolFromNextProto(GetParam()), 1.0);
8868 AlternateProtocolFromNextProto(GetParam()), 1);
8869 8868
8870 scoped_ptr<HttpTransaction> trans( 8869 scoped_ptr<HttpTransaction> trans(
8871 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8870 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8872 TestCompletionCallback callback; 8871 TestCompletionCallback callback;
8873 8872
8874 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); 8873 int rv = trans->Start(&request, callback.callback(), BoundNetLog());
8875 EXPECT_EQ(ERR_IO_PENDING, rv); 8874 EXPECT_EQ(ERR_IO_PENDING, rv);
8876 // The HTTP request should succeed. 8875 // The HTTP request should succeed.
8877 EXPECT_EQ(OK, callback.WaitForResult()); 8876 EXPECT_EQ(OK, callback.WaitForResult());
8878 8877
(...skipping 4677 matching lines...) Expand 10 before | Expand all | Expand 10 after
13556 ASSERT_TRUE(response); 13555 ASSERT_TRUE(response);
13557 ASSERT_TRUE(response->headers.get()); 13556 ASSERT_TRUE(response->headers.get());
13558 13557
13559 EXPECT_EQ(101, response->headers->response_code()); 13558 EXPECT_EQ(101, response->headers->response_code());
13560 13559
13561 trans.reset(); 13560 trans.reset();
13562 session->CloseAllConnections(); 13561 session->CloseAllConnections();
13563 } 13562 }
13564 13563
13565 } // namespace net 13564 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698