Home | History | Annotate | Download | only in websockets
      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 "base/basictypes.h"
     16 
     17 // This file plases constants inside the ::net::websockets namespace to avoid
     18 // risk of collisions with other symbols in libnet.
     19 namespace net {
     20 namespace websockets {
     21 
     22 // "HTTP/1.1"
     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* const kHttpProtocolVersion;
     26 
     27 // The Sec-WebSockey-Key challenge is 16 random bytes, base64 encoded.
     28 extern const size_t kRawChallengeLength;
     29 
     30 // "Sec-WebSocket-Protocol"
     31 extern const char* const kSecWebSocketProtocol;
     32 
     33 // "Sec-WebSocket-Extensions"
     34 extern const char* const kSecWebSocketExtensions;
     35 
     36 // "Sec-WebSocket-Key"
     37 extern const char* const kSecWebSocketKey;
     38 
     39 // "Sec-WebSocket-Accept"
     40 extern const char* const kSecWebSocketAccept;
     41 
     42 // "Sec-WebSocket-Version"
     43 extern const char* const kSecWebSocketVersion;
     44 
     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* const kSupportedVersion;
     49 
     50 // "Upgrade"
     51 extern const char* const kUpgrade;
     52 
     53 // "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" as defined in section 4.1 of
     54 // RFC6455.
     55 extern const char* const kWebSocketGuid;
     56 
     57 // Colon-prefixed lowercase headers for SPDY3.
     58 
     59 // ":sec-websocket-protocol"
     60 extern const char* const kSecWebSocketProtocolSpdy3;
     61 
     62 // ":sec-websocket-extensions"
     63 extern const char* const kSecWebSocketExtensionsSpdy3;
     64 
     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;
     69 
     70 // "sec-websocket-extensions"
     71 extern const char* const kSecWebSocketExtensionsLowercase;
     72 
     73 // "sec-webSocket-key"
     74 extern const char* const kSecWebSocketKeyLowercase;
     75 
     76 // "sec-websocket-version"
     77 extern const char* const kSecWebSocketVersionLowercase;
     78 
     79 // "upgrade"
     80 extern const char* const kUpgradeLowercase;
     81 
     82 // "websocket", as used in the "Upgrade:" header. This is always lowercase
     83 // (except in obsolete versions of the protocol).
     84 extern const char* const kWebSocketLowercase;
     85 
     86 }  // namespace websockets
     87 }  // namespace net
     88 
     89 #endif  // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
     90