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
3 // found in the LICENSE file.
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,
9 // These constants cannot be used in files that are compiled on iOS, because
10 // this file is not compiled on iOS.
12 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
13 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
15 #include "base/basictypes.h"
17 // This file plases constants inside the ::net::websockets namespace to avoid
18 // risk of collisions with other symbols in libnet.
20 namespace websockets
{
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.
25 extern const char kHttpProtocolVersion
[];
27 // The Sec-WebSockey-Key challenge is 16 random bytes, base64 encoded.
28 extern const size_t kRawChallengeLength
;
30 // "Sec-WebSocket-Protocol"
31 extern const char kSecWebSocketProtocol
[];
33 // "Sec-WebSocket-Extensions"
34 extern const char kSecWebSocketExtensions
[];
36 // "Sec-WebSocket-Key"
37 extern const char kSecWebSocketKey
[];
39 // "Sec-WebSocket-Accept"
40 extern const char kSecWebSocketAccept
[];
42 // "Sec-WebSocket-Version"
43 extern const char kSecWebSocketVersion
[];
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
47 // future, it will probably no longer be worth having a constant for this.
48 extern const char kSupportedVersion
[];
51 extern const char kUpgrade
[];
53 // "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" as defined in section 4.1 of
55 extern const char kWebSocketGuid
[];
57 // Colon-prefixed lowercase headers for SPDY3.
59 // ":sec-websocket-protocol"
60 extern const char kSecWebSocketProtocolSpdy3
[];
62 // ":sec-websocket-extensions"
63 extern const char kSecWebSocketExtensionsSpdy3
[];
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.
67 // "sec-websocket-protocol"
68 extern const char* const kSecWebSocketProtocolLowercase
;
70 // "sec-websocket-extensions"
71 extern const char* const kSecWebSocketExtensionsLowercase
;
73 // "sec-webSocket-key"
74 extern const char kSecWebSocketKeyLowercase
[];
76 // "sec-websocket-version"
77 extern const char kSecWebSocketVersionLowercase
[];
80 extern const char kUpgradeLowercase
[];
82 // "websocket", as used in the "Upgrade:" header. This is always lowercase
83 // (except in obsolete versions of the protocol).
84 extern const char kWebSocketLowercase
[];
86 } // namespace websockets
89 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_