OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "net/spdy/spdy_http_utils.h" | 23 #include "net/spdy/spdy_http_utils.h" |
24 #include "net/spdy/spdy_session.h" | 24 #include "net/spdy/spdy_session.h" |
25 #include "net/spdy/spdy_session_pool.h" | 25 #include "net/spdy/spdy_session_pool.h" |
26 #include "net/spdy/spdy_stream.h" | 26 #include "net/spdy/spdy_stream.h" |
27 | 27 |
28 namespace net { | 28 namespace net { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 bool next_proto_is_spdy(NextProto next_proto) { | 32 bool next_proto_is_spdy(NextProto next_proto) { |
33 // TODO(akalin): Change this to kProtoSPDYMinimumVersion once we | 33 return next_proto >= kProtoSPDYMinimumVersion && |
34 // stop supporting SPDY/1. | 34 next_proto <= kProtoSPDYMaximumVersion; |
35 return next_proto >= kProtoSPDY2 && next_proto <= kProtoSPDYMaximumVersion; | |
36 } | 35 } |
37 | 36 |
38 // Parses a URL into the scheme, host, and path components required for a | 37 // Parses a URL into the scheme, host, and path components required for a |
39 // SPDY request. | 38 // SPDY request. |
40 void ParseUrl(base::StringPiece url, std::string* scheme, std::string* host, | 39 void ParseUrl(base::StringPiece url, std::string* scheme, std::string* host, |
41 std::string* path) { | 40 std::string* path) { |
42 GURL gurl(url.as_string()); | 41 GURL gurl(url.as_string()); |
43 path->assign(gurl.PathForRequest()); | 42 path->assign(gurl.PathForRequest()); |
44 scheme->assign(gurl.scheme()); | 43 scheme->assign(gurl.scheme()); |
45 host->assign(gurl.host()); | 44 host->assign(gurl.host()); |
46 if (gurl.has_port()) { | 45 if (gurl.has_port()) { |
47 host->append(":"); | 46 host->append(":"); |
48 host->append(gurl.port()); | 47 host->append(gurl.port()); |
49 } | 48 } |
50 } | 49 } |
51 | 50 |
52 } // namespace | 51 } // namespace |
53 | 52 |
54 std::vector<NextProto> SpdyNextProtos() { | 53 std::vector<NextProto> SpdyNextProtos() { |
55 std::vector<NextProto> next_protos; | 54 std::vector<NextProto> next_protos; |
56 for (int i = kProtoMinimumVersion; i <= kProtoMaximumVersion; ++i) { | 55 for (int i = kProtoMinimumVersion; i <= kProtoMaximumVersion; ++i) { |
57 NextProto proto = static_cast<NextProto>(i); | 56 next_protos.push_back(static_cast<NextProto>(i)); |
58 if (proto != kProtoSPDY1 && proto != kProtoSPDY21) | |
59 next_protos.push_back(proto); | |
60 } | 57 } |
61 return next_protos; | 58 return next_protos; |
62 } | 59 } |
63 | 60 |
64 // Chop a frame into an array of MockWrites. | 61 // Chop a frame into an array of MockWrites. |
65 // |data| is the frame to chop. | 62 // |data| is the frame to chop. |
66 // |length| is the length of the frame to chop. | 63 // |length| is the length of the frame to chop. |
67 // |num_chunks| is the number of chunks to create. | 64 // |num_chunks| is the number of chunks to create. |
68 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { | 65 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { |
69 MockWrite* chunks = new MockWrite[num_chunks]; | 66 MockWrite* chunks = new MockWrite[num_chunks]; |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 (*headers)[GetSchemeKey()] = scheme.c_str(); | 1221 (*headers)[GetSchemeKey()] = scheme.c_str(); |
1225 (*headers)[GetVersionKey()] = "HTTP/1.1"; | 1222 (*headers)[GetVersionKey()] = "HTTP/1.1"; |
1226 if (content_length) { | 1223 if (content_length) { |
1227 std::string length_str = base::Int64ToString(*content_length); | 1224 std::string length_str = base::Int64ToString(*content_length); |
1228 (*headers)["content-length"] = length_str; | 1225 (*headers)["content-length"] = length_str; |
1229 } | 1226 } |
1230 return headers.Pass(); | 1227 return headers.Pass(); |
1231 } | 1228 } |
1232 | 1229 |
1233 } // namespace net | 1230 } // namespace net |
OLD | NEW |