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 // A set of common constants that are needed for the WebSocket handshake. | 5 // A set of common constants that are needed for the WebSocket handshake. |
6 // In general, you should prefer using these constants to literal strings, | 6 // In general, you should prefer using these constants to literal strings, |
7 // except in tests. | 7 // except in tests. |
8 // | 8 // |
9 // These constants cannot be used in files that are compiled on iOS, because | 9 // These constants cannot be used in files that are compiled on iOS, because |
10 // this file is not compiled on iOS. | 10 // this file is not compiled on iOS. |
11 | 11 |
12 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_ | 12 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_ |
13 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_ | 13 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_ |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 | 16 |
17 // This file plases constants inside the ::net::websockets namespace to avoid | 17 // This file plases constants inside the ::net::websockets namespace to avoid |
18 // risk of collisions with other symbols in libnet. | 18 // risk of collisions with other symbols in libnet. |
19 namespace net { | 19 namespace net { |
20 namespace websockets { | 20 namespace websockets { |
21 | 21 |
22 // "HTTP/1.1" | 22 // "HTTP/1.1" |
23 // RFC6455 only requires HTTP/1.1 "or better" but in practice an HTTP version | 23 // RFC6455 only requires HTTP/1.1 "or better" but in practice an HTTP version |
24 // other than 1.1 should not occur in a WebSocket handshake. | 24 // other than 1.1 should not occur in a WebSocket handshake. |
25 extern const char* const kHttpProtocolVersion; | 25 extern const char kHttpProtocolVersion[]; |
26 | 26 |
27 // The Sec-WebSockey-Key challenge is 16 random bytes, base64 encoded. | 27 // The Sec-WebSockey-Key challenge is 16 random bytes, base64 encoded. |
28 extern const size_t kRawChallengeLength; | 28 extern const size_t kRawChallengeLength; |
29 | 29 |
30 // "Sec-WebSocket-Protocol" | 30 // "Sec-WebSocket-Protocol" |
31 extern const char* const kSecWebSocketProtocol; | 31 extern const char kSecWebSocketProtocol[]; |
32 | 32 |
33 // "Sec-WebSocket-Extensions" | 33 // "Sec-WebSocket-Extensions" |
34 extern const char* const kSecWebSocketExtensions; | 34 extern const char kSecWebSocketExtensions[]; |
35 | 35 |
36 // "Sec-WebSocket-Key" | 36 // "Sec-WebSocket-Key" |
37 extern const char* const kSecWebSocketKey; | 37 extern const char kSecWebSocketKey[]; |
38 | 38 |
39 // "Sec-WebSocket-Accept" | 39 // "Sec-WebSocket-Accept" |
40 extern const char* const kSecWebSocketAccept; | 40 extern const char kSecWebSocketAccept[]; |
41 | 41 |
42 // "Sec-WebSocket-Version" | 42 // "Sec-WebSocket-Version" |
43 extern const char* const kSecWebSocketVersion; | 43 extern const char kSecWebSocketVersion[]; |
44 | 44 |
45 // This implementation only supports one version of the WebSocket protocol, | 45 // This implementation only supports one version of the WebSocket protocol, |
46 // "13", as specified in RFC6455. If support for multiple versions is added in | 46 // "13", as specified in RFC6455. If support for multiple versions is added in |
47 // future, it will probably no longer be worth having a constant for this. | 47 // future, it will probably no longer be worth having a constant for this. |
48 extern const char* const kSupportedVersion; | 48 extern const char kSupportedVersion[]; |
49 | 49 |
50 // "Upgrade" | 50 // "Upgrade" |
51 extern const char* const kUpgrade; | 51 extern const char kUpgrade[]; |
52 | 52 |
53 // "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" as defined in section 4.1 of | 53 // "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" as defined in section 4.1 of |
54 // RFC6455. | 54 // RFC6455. |
55 extern const char* const kWebSocketGuid; | 55 extern const char kWebSocketGuid[]; |
56 | 56 |
57 // Colon-prefixed lowercase headers for SPDY3. | 57 // Colon-prefixed lowercase headers for SPDY3. |
58 | 58 |
59 // ":sec-websocket-protocol" | 59 // ":sec-websocket-protocol" |
60 extern const char* const kSecWebSocketProtocolSpdy3; | 60 extern const char kSecWebSocketProtocolSpdy3[]; |
61 | 61 |
62 // ":sec-websocket-extensions" | 62 // ":sec-websocket-extensions" |
63 extern const char* const kSecWebSocketExtensionsSpdy3; | 63 extern const char kSecWebSocketExtensionsSpdy3[]; |
64 | 64 |
65 // Some parts of the code require lowercase versions of the header names in | 65 // Some parts of the code require lowercase versions of the header names in |
66 // order to do case-insensitive comparisons, or because of SPDY. | 66 // order to do case-insensitive comparisons, or because of SPDY. |
67 // "sec-websocket-protocol" | 67 // "sec-websocket-protocol" |
68 extern const char* const kSecWebSocketProtocolLowercase; | 68 extern const char* const kSecWebSocketProtocolLowercase; |
69 | 69 |
70 // "sec-websocket-extensions" | 70 // "sec-websocket-extensions" |
71 extern const char* const kSecWebSocketExtensionsLowercase; | 71 extern const char* const kSecWebSocketExtensionsLowercase; |
72 | 72 |
73 // "sec-webSocket-key" | 73 // "sec-webSocket-key" |
74 extern const char* const kSecWebSocketKeyLowercase; | 74 extern const char kSecWebSocketKeyLowercase[]; |
75 | 75 |
76 // "sec-websocket-version" | 76 // "sec-websocket-version" |
77 extern const char* const kSecWebSocketVersionLowercase; | 77 extern const char kSecWebSocketVersionLowercase[]; |
78 | 78 |
79 // "upgrade" | 79 // "upgrade" |
80 extern const char* const kUpgradeLowercase; | 80 extern const char kUpgradeLowercase[]; |
81 | 81 |
82 // "websocket", as used in the "Upgrade:" header. This is always lowercase | 82 // "websocket", as used in the "Upgrade:" header. This is always lowercase |
83 // (except in obsolete versions of the protocol). | 83 // (except in obsolete versions of the protocol). |
84 extern const char* const kWebSocketLowercase; | 84 extern const char kWebSocketLowercase[]; |
85 | 85 |
86 } // namespace websockets | 86 } // namespace websockets |
87 } // namespace net | 87 } // namespace net |
88 | 88 |
89 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_ | 89 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_ |
OLD | NEW |