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

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

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/http/http_response_body_drainer.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 8493 matching lines...) Expand 10 before | Expand all | Expand 10 after
8504 8504
8505 std::string response_data; 8505 std::string response_data;
8506 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 8506 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
8507 EXPECT_EQ("hello world", response_data); 8507 EXPECT_EQ("hello world", response_data);
8508 8508
8509 ASSERT_TRUE(http_server_properties->HasAlternateProtocol( 8509 ASSERT_TRUE(http_server_properties->HasAlternateProtocol(
8510 HostPortPair::FromURL(request.url))); 8510 HostPortPair::FromURL(request.url)));
8511 const AlternateProtocolInfo alternate = 8511 const AlternateProtocolInfo alternate =
8512 http_server_properties->GetAlternateProtocol( 8512 http_server_properties->GetAlternateProtocol(
8513 HostPortPair::FromURL(request.url)); 8513 HostPortPair::FromURL(request.url));
8514 EXPECT_EQ(ALTERNATE_PROTOCOL_BROKEN, alternate.protocol); 8514 EXPECT_TRUE(alternate.is_broken);
8515 } 8515 }
8516 8516
8517 TEST_P(HttpNetworkTransactionTest, 8517 TEST_P(HttpNetworkTransactionTest,
8518 AlternateProtocolPortRestrictedBlocked) { 8518 AlternateProtocolPortRestrictedBlocked) {
8519 // Ensure that we're not allowed to redirect traffic via an alternate 8519 // Ensure that we're not allowed to redirect traffic via an alternate
8520 // protocol to an unrestricted (port >= 1024) when the original traffic was 8520 // protocol to an unrestricted (port >= 1024) when the original traffic was
8521 // on a restricted port (port < 1024). Ensure that we can redirect in all 8521 // on a restricted port (port < 1024). Ensure that we can redirect in all
8522 // other cases. 8522 // other cases.
8523 session_deps_.use_alternate_protocols = true; 8523 session_deps_.use_alternate_protocols = true;
8524 8524
(...skipping 3661 matching lines...) Expand 10 before | Expand all | Expand 10 after
12186 12186
12187 HttpRequestHeaders request_headers; 12187 HttpRequestHeaders request_headers;
12188 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); 12188 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
12189 std::string foo; 12189 std::string foo;
12190 EXPECT_TRUE(request_headers.GetHeader("X-Foo", &foo)); 12190 EXPECT_TRUE(request_headers.GetHeader("X-Foo", &foo));
12191 EXPECT_EQ("bar", foo); 12191 EXPECT_EQ("bar", foo);
12192 } 12192 }
12193 12193
12194 namespace { 12194 namespace {
12195 12195
12196 // Fake HttpStreamBase that simply records calls to SetPriority(). 12196 // Fake HttpStream that simply records calls to SetPriority().
12197 class FakeStream : public HttpStreamBase, 12197 class FakeStream : public HttpStream,
12198 public base::SupportsWeakPtr<FakeStream> { 12198 public base::SupportsWeakPtr<FakeStream> {
12199 public: 12199 public:
12200 explicit FakeStream(RequestPriority priority) : priority_(priority) {} 12200 explicit FakeStream(RequestPriority priority) : priority_(priority) {}
12201 ~FakeStream() override {} 12201 ~FakeStream() override {}
12202 12202
12203 RequestPriority priority() const { return priority_; } 12203 RequestPriority priority() const { return priority_; }
12204 12204
12205 int InitializeStream(const HttpRequestInfo* request_info, 12205 int InitializeStream(const HttpRequestInfo* request_info,
12206 RequestPriority priority, 12206 RequestPriority priority,
12207 const BoundNetLog& net_log, 12207 const BoundNetLog& net_log,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
12267 12267
12268 bool IsSpdyHttpStream() const override { 12268 bool IsSpdyHttpStream() const override {
12269 ADD_FAILURE(); 12269 ADD_FAILURE();
12270 return false; 12270 return false;
12271 } 12271 }
12272 12272
12273 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); } 12273 void Drain(HttpNetworkSession* session) override { ADD_FAILURE(); }
12274 12274
12275 void SetPriority(RequestPriority priority) override { priority_ = priority; } 12275 void SetPriority(RequestPriority priority) override { priority_ = priority; }
12276 12276
12277 UploadProgress GetUploadProgress() const override { return UploadProgress(); }
12278
12279 HttpStream* RenewStreamForAuth() override { return NULL; }
12280
12277 private: 12281 private:
12278 RequestPriority priority_; 12282 RequestPriority priority_;
12279 12283
12280 DISALLOW_COPY_AND_ASSIGN(FakeStream); 12284 DISALLOW_COPY_AND_ASSIGN(FakeStream);
12281 }; 12285 };
12282 12286
12283 // Fake HttpStreamRequest that simply records calls to SetPriority() 12287 // Fake HttpStreamRequest that simply records calls to SetPriority()
12284 // and vends FakeStreams with its current priority. 12288 // and vends FakeStreams with its current priority.
12285 class FakeStreamRequest : public HttpStreamRequest, 12289 class FakeStreamRequest : public HttpStreamRequest,
12286 public base::SupportsWeakPtr<FakeStreamRequest> { 12290 public base::SupportsWeakPtr<FakeStreamRequest> {
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
13177 EXPECT_EQ(ERR_IO_PENDING, rv); 13181 EXPECT_EQ(ERR_IO_PENDING, rv);
13178 13182
13179 rv = callback.WaitForResult(); 13183 rv = callback.WaitForResult();
13180 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 13184 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
13181 13185
13182 const HttpResponseInfo* response = trans->GetResponseInfo(); 13186 const HttpResponseInfo* response = trans->GetResponseInfo();
13183 EXPECT_TRUE(response == NULL); 13187 EXPECT_TRUE(response == NULL);
13184 } 13188 }
13185 13189
13186 } // namespace net 13190 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_response_body_drainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698