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.
4 
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,
7 // except in tests.
8 //
9 // These constants cannot be used in files that are compiled on iOS, because
10 // this file is not compiled on iOS.
11 
12 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
13 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
14 
15 #include <stddef.h>
16 
17 #include "net/base/net_export.h"
18 
19 // This file plases constants inside the ::net::websockets namespace to avoid
20 // risk of collisions with other symbols in libnet.
21 namespace net {
22 namespace websockets {
23 
24 // "HTTP/1.1"
25 // RFC6455 only requires HTTP/1.1 "or better" but in practice an HTTP version
26 // other than 1.1 should not occur in a WebSocket handshake.
27 extern const char kHttpProtocolVersion[];
28 
29 // The Sec-WebSockey-Key challenge is 16 random bytes, base64 encoded.
30 extern const size_t kRawChallengeLength;
31 
32 // "Sec-WebSocket-Protocol"
33 extern const char kSecWebSocketProtocol[];
34 
35 // "Sec-WebSocket-Extensions"
36 extern const char kSecWebSocketExtensions[];
37 
38 // "Sec-WebSocket-Key"
39 extern const char kSecWebSocketKey[];
40 
41 // "Sec-WebSocket-Accept"
42 extern const char kSecWebSocketAccept[];
43 
44 // "Sec-WebSocket-Version"
45 extern const char kSecWebSocketVersion[];
46 
47 // This implementation only supports one version of the WebSocket protocol,
48 // "13", as specified in RFC6455. If support for multiple versions is added in
49 // future, it will probably no longer be worth having a constant for this.
50 extern const char kSupportedVersion[];
51 
52 // "Upgrade"
53 extern const char kUpgrade[];
54 
55 // "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" as defined in section 4.1 of
56 // RFC6455.
57 extern const char NET_EXPORT kWebSocketGuid[];
58 
59 // "websocket", as used in the "Upgrade:" header. This is always lowercase
60 // (except in obsolete versions of the protocol).
61 extern const char kWebSocketLowercase[];
62 
63 }  // namespace websockets
64 }  // namespace net
65 
66 #endif  // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
67