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

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

Issue 2297263002: Revert "Only allow HTTP/0.9 support on default ports." (Closed)
Patch Set: Created 4 years, 3 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_basic_state.cc ('k') | net/http/http_basic_stream.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_basic_state.h" 5 #include "net/http/http_basic_state.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "net/base/completion_callback.h" 8 #include "net/base/completion_callback.h"
9 #include "net/base/request_priority.h" 9 #include "net/base/request_priority.h"
10 #include "net/http/http_request_info.h" 10 #include "net/http/http_request_info.h"
11 #include "net/socket/client_socket_handle.h" 11 #include "net/socket/client_socket_handle.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace net { 14 namespace net {
15 namespace { 15 namespace {
16 16
17 TEST(HttpBasicStateTest, ConstructsProperly) { 17 TEST(HttpBasicStateTest, ConstructsProperly) {
18 ClientSocketHandle* const handle = new ClientSocketHandle; 18 ClientSocketHandle* const handle = new ClientSocketHandle;
19 // Ownership of |handle| is passed to |state|. 19 // Ownership of |handle| is passed to |state|.
20 const HttpBasicState state(base::WrapUnique(handle), true /* using_proxy */, 20 const HttpBasicState state(base::WrapUnique(handle), true);
21 false /* http_09_on_non_default_ports_enabled */);
22 EXPECT_EQ(handle, state.connection()); 21 EXPECT_EQ(handle, state.connection());
23 EXPECT_TRUE(state.using_proxy()); 22 EXPECT_TRUE(state.using_proxy());
24 EXPECT_FALSE(state.http_09_on_non_default_ports_enabled());
25 } 23 }
26 24
27 TEST(HttpBasicStateTest, ConstructsProperlyWithDifferentOptions) { 25 TEST(HttpBasicStateTest, UsingProxyCanBeFalse) {
28 const HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), 26 const HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false);
29 false /* using_proxy */,
30 true /* http_09_on_non_default_ports_enabled */);
31 EXPECT_FALSE(state.using_proxy()); 27 EXPECT_FALSE(state.using_proxy());
32 EXPECT_TRUE(state.http_09_on_non_default_ports_enabled());
33 } 28 }
34 29
35 TEST(HttpBasicStateTest, ReleaseConnectionWorks) { 30 TEST(HttpBasicStateTest, ReleaseConnectionWorks) {
36 ClientSocketHandle* const handle = new ClientSocketHandle; 31 ClientSocketHandle* const handle = new ClientSocketHandle;
37 // Ownership of |handle| is passed to |state|. 32 // Ownership of |handle| is passed to |state|.
38 HttpBasicState state(base::WrapUnique(handle), false, false); 33 HttpBasicState state(base::WrapUnique(handle), false);
39 const std::unique_ptr<ClientSocketHandle> released_connection( 34 const std::unique_ptr<ClientSocketHandle> released_connection(
40 state.ReleaseConnection()); 35 state.ReleaseConnection());
41 EXPECT_EQ(NULL, state.connection()); 36 EXPECT_EQ(NULL, state.connection());
42 EXPECT_EQ(handle, released_connection.get()); 37 EXPECT_EQ(handle, released_connection.get());
43 } 38 }
44 39
45 TEST(HttpBasicStateTest, InitializeWorks) { 40 TEST(HttpBasicStateTest, InitializeWorks) {
46 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false, false); 41 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false);
47 const HttpRequestInfo request_info; 42 const HttpRequestInfo request_info;
48 EXPECT_EQ(OK, 43 EXPECT_EQ(OK,
49 state.Initialize( 44 state.Initialize(
50 &request_info, LOW, BoundNetLog(), CompletionCallback())); 45 &request_info, LOW, BoundNetLog(), CompletionCallback()));
51 EXPECT_TRUE(state.parser()); 46 EXPECT_TRUE(state.parser());
52 } 47 }
53 48
54 TEST(HttpBasicStateTest, DeleteParser) { 49 TEST(HttpBasicStateTest, DeleteParser) {
55 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false, false); 50 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false);
56 const HttpRequestInfo request_info; 51 const HttpRequestInfo request_info;
57 state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback()); 52 state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback());
58 EXPECT_TRUE(state.parser()); 53 EXPECT_TRUE(state.parser());
59 state.DeleteParser(); 54 state.DeleteParser();
60 EXPECT_EQ(NULL, state.parser()); 55 EXPECT_EQ(NULL, state.parser());
61 } 56 }
62 57
63 TEST(HttpBasicStateTest, GenerateRequestLineNoProxy) { 58 TEST(HttpBasicStateTest, GenerateRequestLineNoProxy) {
64 const bool use_proxy = false; 59 const bool use_proxy = false;
65 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), use_proxy, 60 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), use_proxy);
66 false);
67 HttpRequestInfo request_info; 61 HttpRequestInfo request_info;
68 request_info.url = GURL("http://www.example.com/path?foo=bar#hoge"); 62 request_info.url = GURL("http://www.example.com/path?foo=bar#hoge");
69 request_info.method = "PUT"; 63 request_info.method = "PUT";
70 state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback()); 64 state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback());
71 EXPECT_EQ("PUT /path?foo=bar HTTP/1.1\r\n", state.GenerateRequestLine()); 65 EXPECT_EQ("PUT /path?foo=bar HTTP/1.1\r\n", state.GenerateRequestLine());
72 } 66 }
73 67
74 TEST(HttpBasicStateTest, GenerateRequestLineWithProxy) { 68 TEST(HttpBasicStateTest, GenerateRequestLineWithProxy) {
75 const bool use_proxy = true; 69 const bool use_proxy = true;
76 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), use_proxy, 70 HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), use_proxy);
77 false);
78 HttpRequestInfo request_info; 71 HttpRequestInfo request_info;
79 request_info.url = GURL("http://www.example.com/path?foo=bar#hoge"); 72 request_info.url = GURL("http://www.example.com/path?foo=bar#hoge");
80 request_info.method = "PUT"; 73 request_info.method = "PUT";
81 state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback()); 74 state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback());
82 EXPECT_EQ("PUT http://www.example.com/path?foo=bar HTTP/1.1\r\n", 75 EXPECT_EQ("PUT http://www.example.com/path?foo=bar HTTP/1.1\r\n",
83 state.GenerateRequestLine()); 76 state.GenerateRequestLine());
84 } 77 }
85 78
86 } // namespace 79 } // namespace
87 } // namespace net 80 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_basic_state.cc ('k') | net/http/http_basic_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698