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/quic/spdy_utils.h" | 5 #include "net/quic/spdy_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "net/spdy/spdy_frame_builder.h" | 13 #include "net/spdy/spdy_frame_builder.h" |
14 #include "net/spdy/spdy_framer.h" | 14 #include "net/spdy/spdy_framer.h" |
15 #include "net/spdy/spdy_protocol.h" | 15 #include "net/spdy/spdy_protocol.h" |
| 16 #include "url/gurl.h" |
16 | 17 |
17 using std::string; | 18 using std::string; |
18 using std::vector; | 19 using std::vector; |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 // static | 23 // static |
23 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) { | 24 string SpdyUtils::SerializeUncompressedHeaders(const SpdyHeaderBlock& headers) { |
24 SpdyMajorVersion spdy_version = HTTP2; | 25 SpdyMajorVersion spdy_version = HTTP2; |
25 | 26 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return false; | 99 return false; |
99 } | 100 } |
100 | 101 |
101 // TODO(rjshade): Check for other forbidden keys, following the HTTP/2 spec. | 102 // TODO(rjshade): Check for other forbidden keys, following the HTTP/2 spec. |
102 } | 103 } |
103 | 104 |
104 DVLOG(1) << "Successfully parsed Trailers."; | 105 DVLOG(1) << "Successfully parsed Trailers."; |
105 return true; | 106 return true; |
106 } | 107 } |
107 | 108 |
| 109 // static |
| 110 string SpdyUtils::GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers) { |
| 111 SpdyHeaderBlock::const_iterator it = headers.find(":scheme"); |
| 112 if (it == headers.end()) |
| 113 return ""; |
| 114 std::string url = it->second.as_string(); |
| 115 |
| 116 url.append("://"); |
| 117 |
| 118 it = headers.find(":authority"); |
| 119 if (it == headers.end()) |
| 120 return ""; |
| 121 url.append(it->second.as_string()); |
| 122 |
| 123 it = headers.find(":path"); |
| 124 if (it == headers.end()) |
| 125 return ""; |
| 126 url.append(it->second.as_string()); |
| 127 return url; |
| 128 } |
| 129 |
| 130 // static |
| 131 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { |
| 132 string url(GetUrlFromHeaderBlock(headers)); |
| 133 return url != "" && GURL(url).is_valid(); |
| 134 } |
| 135 |
108 } // namespace net | 136 } // namespace net |
OLD | NEW |