OLD | NEW |
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/tools/balsa/balsa_headers.h" | 5 #include "net/tools/balsa/balsa_headers.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | |
9 #include <algorithm> | 8 #include <algorithm> |
10 #include <string> | 9 #include <string> |
11 #include <unordered_set> | |
12 #include <utility> | 10 #include <utility> |
13 #include <vector> | 11 #include <vector> |
14 | 12 |
| 13 #include "base/containers/hash_tables.h" |
15 #include "base/logging.h" | 14 #include "base/logging.h" |
16 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
17 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
18 #include "net/tools/balsa/balsa_enums.h" | 17 #include "net/tools/balsa/balsa_enums.h" |
19 #include "net/tools/balsa/buffer_interface.h" | 18 #include "net/tools/balsa/buffer_interface.h" |
20 #include "net/tools/balsa/simple_buffer.h" | 19 #include "net/tools/balsa/simple_buffer.h" |
21 #include "third_party/tcmalloc/chromium/src/base/googleinit.h" | 20 #include "third_party/tcmalloc/chromium/src/base/googleinit.h" |
22 | 21 |
23 #if defined(COMPILER_MSVC) | 22 #if defined(COMPILER_MSVC) |
24 #include <string.h> | 23 #include <string.h> |
25 #define snprintf _snprintf | 24 #define snprintf _snprintf |
26 #define strncasecmp _strnicmp | 25 #define strncasecmp _strnicmp |
27 #else | 26 #else |
28 #include <strings.h> | 27 #include <strings.h> |
29 #endif | 28 #endif |
30 | 29 |
31 namespace { | 30 namespace { |
32 | 31 |
33 const char kContentLength[] = "Content-Length"; | 32 const char kContentLength[] = "Content-Length"; |
34 const char kTransferEncoding[] = "Transfer-Encoding"; | 33 const char kTransferEncoding[] = "Transfer-Encoding"; |
35 const char kSpaceChar = ' '; | 34 const char kSpaceChar = ' '; |
36 | 35 |
37 std::unordered_set<base::StringPiece, | 36 #if defined(COMPILER_MSVC) |
38 net::StringPieceCaseHash, | 37 base::hash_set<base::StringPiece, |
39 net::StringPieceCaseEqual> | 38 net::StringPieceCaseCompare> g_multivalued_headers; |
40 g_multivalued_headers; | 39 #else |
| 40 base::hash_set<base::StringPiece, |
| 41 net::StringPieceCaseHash, |
| 42 net::StringPieceCaseEqual> g_multivalued_headers; |
| 43 #endif |
41 | 44 |
42 void InitMultivaluedHeaders() { | 45 void InitMultivaluedHeaders() { |
43 g_multivalued_headers.insert("accept"); | 46 g_multivalued_headers.insert("accept"); |
44 g_multivalued_headers.insert("accept-charset"); | 47 g_multivalued_headers.insert("accept-charset"); |
45 g_multivalued_headers.insert("accept-encoding"); | 48 g_multivalued_headers.insert("accept-encoding"); |
46 g_multivalued_headers.insert("accept-language"); | 49 g_multivalued_headers.insert("accept-language"); |
47 g_multivalued_headers.insert("accept-ranges"); | 50 g_multivalued_headers.insert("accept-ranges"); |
48 g_multivalued_headers.insert("allow"); | 51 g_multivalued_headers.insert("allow"); |
49 g_multivalued_headers.insert("cache-control"); | 52 g_multivalued_headers.insert("cache-control"); |
50 g_multivalued_headers.insert("connection"); | 53 g_multivalued_headers.insert("connection"); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 | 969 |
967 void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) { | 970 void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) { |
968 // Note: There is no difference between request_version() and | 971 // Note: There is no difference between request_version() and |
969 // response_reason_phrase(). Thus, a function to set one is equivalent to a | 972 // response_reason_phrase(). Thus, a function to set one is equivalent to a |
970 // function to set the other. We maintain two functions for this as it is | 973 // function to set the other. We maintain two functions for this as it is |
971 // much more descriptive, and makes code more understandable. | 974 // much more descriptive, and makes code more understandable. |
972 SetRequestVersion(reason); | 975 SetRequestVersion(reason); |
973 } | 976 } |
974 | 977 |
975 } // namespace net | 978 } // namespace net |
OLD | NEW |