OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tools/quic/spdy_balsa_utils.h" | 5 #include "net/tools/quic/spdy_balsa_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "net/base/linked_hash_map.h" | 13 #include "net/base/linked_hash_map.h" |
14 #include "net/quic/quic_flags.h" | 14 #include "net/quic/quic_flags.h" |
15 #include "net/quic/spdy_utils.h" | 15 #include "net/quic/spdy_utils.h" |
16 #include "net/spdy/spdy_frame_builder.h" | 16 #include "net/spdy/spdy_frame_builder.h" |
17 #include "net/spdy/spdy_framer.h" | 17 #include "net/spdy/spdy_framer.h" |
18 #include "net/spdy/spdy_protocol.h" | 18 #include "net/spdy/spdy_protocol.h" |
19 #include "net/tools/balsa/balsa_headers.h" | 19 #include "net/tools/balsa/balsa_headers.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
22 using base::StringPiece; | 22 using base::StringPiece; |
| 23 using base::StringPieceHash; |
23 using std::make_pair; | 24 using std::make_pair; |
24 using std::pair; | 25 using std::pair; |
25 using std::string; | 26 using std::string; |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 namespace { | 29 namespace { |
29 | 30 |
30 const char kV4Host[] = ":authority"; | 31 const char kV4Host[] = ":authority"; |
31 | 32 |
32 const char kV3Host[] = ":host"; | 33 const char kV3Host[] = ":host"; |
33 const char kV3Path[] = ":path"; | 34 const char kV3Path[] = ":path"; |
34 const char kV3Scheme[] = ":scheme"; | 35 const char kV3Scheme[] = ":scheme"; |
35 const char kV3Method[] = ":method"; | 36 const char kV3Method[] = ":method"; |
36 const char kV3Status[] = ":status"; | 37 const char kV3Status[] = ":status"; |
37 const char kV3Version[] = ":version"; | 38 const char kV3Version[] = ":version"; |
38 | 39 |
39 void PopulateSpdyHeaderBlock(const BalsaHeaders& headers, | 40 void PopulateSpdyHeaderBlock(const BalsaHeaders& headers, |
40 SpdyHeaderBlock* block, | 41 SpdyHeaderBlock* block, |
41 bool allow_empty_values) { | 42 bool allow_empty_values) { |
42 using HeaderValuesMap = | 43 using HeaderValuesMap = |
43 linked_hash_map<StringPiece, std::vector<StringPiece>>; | 44 linked_hash_map<StringPiece, std::vector<StringPiece>, StringPieceHash>; |
44 std::deque<string> names; | 45 std::deque<string> names; |
45 HeaderValuesMap header_values_map; | 46 HeaderValuesMap header_values_map; |
46 // First, gather references to all values for each name. | 47 // First, gather references to all values for each name. |
47 for (BalsaHeaders::const_header_lines_iterator hi = | 48 for (BalsaHeaders::const_header_lines_iterator hi = |
48 headers.header_lines_begin(); | 49 headers.header_lines_begin(); |
49 hi != headers.header_lines_end(); ++hi) { | 50 hi != headers.header_lines_end(); ++hi) { |
50 if ((hi->second.length() == 0) && !allow_empty_values) { | 51 if ((hi->second.length() == 0) && !allow_empty_values) { |
51 DVLOG(1) << "Dropping empty header " << hi->first.as_string() | 52 DVLOG(1) << "Dropping empty header " << hi->first.as_string() |
52 << " from headers"; | 53 << " from headers"; |
53 continue; | 54 continue; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 SpdyHeaderValidatorType::RESPONSE_HEADER); | 273 SpdyHeaderValidatorType::RESPONSE_HEADER); |
273 } | 274 } |
274 | 275 |
275 // static | 276 // static |
276 void SpdyBalsaUtils::SpdyHeadersToRequestHeaders(const SpdyHeaderBlock& block, | 277 void SpdyBalsaUtils::SpdyHeadersToRequestHeaders(const SpdyHeaderBlock& block, |
277 BalsaHeaders* headers) { | 278 BalsaHeaders* headers) { |
278 SpdyHeadersToBalsaHeaders(block, headers, SpdyHeaderValidatorType::REQUEST); | 279 SpdyHeadersToBalsaHeaders(block, headers, SpdyHeaderValidatorType::REQUEST); |
279 } | 280 } |
280 | 281 |
281 } // namespace net | 282 } // namespace net |
OLD | NEW |