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

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

Issue 1585041: SSL fixes for sites with buggy DEFLATE support. (Closed)
Patch Set: ... Created 10 years, 8 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 | « net/http/http_network_transaction.cc ('k') | net/socket/ssl_client_socket_nss.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <math.h> // ceil 5 #include <math.h> // ceil
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 4868 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 // did not complete correctly. 4879 // did not complete correctly.
4880 EXPECT_FALSE(response->auth_challenge.get() == NULL); 4880 EXPECT_FALSE(response->auth_challenge.get() == NULL);
4881 4881
4882 EXPECT_EQ(L"myserver:80", response->auth_challenge->host_and_port); 4882 EXPECT_EQ(L"myserver:80", response->auth_challenge->host_and_port);
4883 EXPECT_EQ(L"", response->auth_challenge->realm); 4883 EXPECT_EQ(L"", response->auth_challenge->realm);
4884 EXPECT_EQ(L"mock", response->auth_challenge->scheme); 4884 EXPECT_EQ(L"mock", response->auth_challenge->scheme);
4885 auth_handler->ResetResolveExpectation(); 4885 auth_handler->ResetResolveExpectation();
4886 } 4886 }
4887 } 4887 }
4888 4888
4889 struct TLSCompressionFailureSocketDataProvider : public SocketDataProvider {
wtc 2010/04/20 21:31:07 Why is this class defined as a 'struct'? Nit: thi
4890 public:
4891 TLSCompressionFailureSocketDataProvider(bool fail_all)
4892 : fail_all_(fail_all) {
4893 }
4894
4895 virtual MockRead GetNextRead() {
4896 if (fail_all_)
4897 return MockRead(false /* async */, ERR_SSL_DECOMPRESSION_FAILURE_ALERT);
4898
4899 return MockRead(false /* async */,
4900 "HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nok.\r\n");
4901 }
4902
4903 virtual MockWriteResult OnWrite(const std::string& data) {
4904 return MockWriteResult(false /* async */, data.size());
4905 }
4906
4907 void Reset() {
4908 }
4909
4910 private:
4911 const bool fail_all_;
4912 };
4913
4914 // Test that we restart a connection when we see a decompression failure from
4915 // the peer during the handshake. (In the real world we'll restart with SSLv3
4916 // and we won't offer DEFLATE in that case.)
4917 TEST_F(HttpNetworkTransactionTest, RestartAfterTLSDecompressionFailure) {
4918 HttpRequestInfo request;
4919 request.method = "GET";
4920 request.url = GURL("https://tlsdecompressionfailure.example.com/");
4921 request.load_flags = 0;
4922
4923 SessionDependencies session_deps;
4924 TLSCompressionFailureSocketDataProvider socket_data_provider1(
4925 false /* fail all reads */);
4926 TLSCompressionFailureSocketDataProvider socket_data_provider2(false);
4927 SSLSocketDataProvider ssl_socket_data_provider1(
4928 false, ERR_SSL_DECOMPRESSION_FAILURE_ALERT);
4929 SSLSocketDataProvider ssl_socket_data_provider2(false, OK);
4930 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1);
4931 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2);
4932 session_deps.socket_factory.AddSSLSocketDataProvider(
4933 &ssl_socket_data_provider1);
4934 session_deps.socket_factory.AddSSLSocketDataProvider(
4935 &ssl_socket_data_provider2);
4936
4937 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
4938 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
4939 TestCompletionCallback callback;
4940
4941 int rv = trans->Start(&request, &callback, NULL);
4942 EXPECT_EQ(ERR_IO_PENDING, rv);
4943 EXPECT_EQ(OK, callback.WaitForResult());
4944
4945 const HttpResponseInfo* response = trans->GetResponseInfo();
4946 ASSERT_TRUE(response != NULL);
4947 ASSERT_TRUE(response->headers != NULL);
4948 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
4949
4950 std::string response_data;
4951 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
4952 EXPECT_EQ("ok.", response_data);
4953 }
4954
4955 // Test that we restart a connection if we get a decompression failure from the
4956 // peer while reading the first bytes from the connection. This occurs when the
4957 // peer cannot handle DEFLATE but we're using False Start, so we don't notice
4958 // in the handshake.
4959 TEST_F(HttpNetworkTransactionTest,
4960 RestartAfterTLSDecompressionFailureWithFalseStart) {
4961 HttpRequestInfo request;
4962 request.method = "GET";
4963 request.url = GURL("https://tlsdecompressionfailure2.example.com/");
4964 request.load_flags = 0;
4965
4966 SessionDependencies session_deps;
4967 TLSCompressionFailureSocketDataProvider socket_data_provider1(
4968 true /* fail all reads */);
4969 TLSCompressionFailureSocketDataProvider socket_data_provider2(false);
4970 SSLSocketDataProvider ssl_socket_data_provider1(false, OK);
4971 SSLSocketDataProvider ssl_socket_data_provider2(false, OK);
4972 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1);
4973 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2);
4974 session_deps.socket_factory.AddSSLSocketDataProvider(
4975 &ssl_socket_data_provider1);
4976 session_deps.socket_factory.AddSSLSocketDataProvider(
4977 &ssl_socket_data_provider2);
4978
4979 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
4980 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
4981 TestCompletionCallback callback;
4982
4983 int rv = trans->Start(&request, &callback, NULL);
4984 EXPECT_EQ(ERR_IO_PENDING, rv);
4985 EXPECT_EQ(OK, callback.WaitForResult());
4986
4987 const HttpResponseInfo* response = trans->GetResponseInfo();
4988 ASSERT_TRUE(response != NULL);
4989 ASSERT_TRUE(response->headers != NULL);
4990 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
4991
4992 std::string response_data;
4993 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
4994 EXPECT_EQ("ok.", response_data);
4995 }
4996
4889 } // namespace net 4997 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698