xref: /aosp_15_r20/external/cronet/net/websockets/websocket_errors.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
7 
8 #include "net/base/net_errors.h"
9 #include "net/base/net_export.h"
10 
11 namespace net {
12 
13 // Reason codes used with close messages. NoStatusReceived,
14 // AbnormalClosure and TlsHandshake are special in that they
15 // should never be sent on the wire; they are only used within the
16 // implementation.
17 enum WebSocketError {
18   // Status codes in the range 0 to 999 are not used.
19 
20   // The following are defined by RFC6455.
21   kWebSocketNormalClosure = 1000,
22   kWebSocketErrorGoingAway = 1001,
23   kWebSocketErrorProtocolError = 1002,
24   kWebSocketErrorUnsupportedData = 1003,
25   kWebSocketErrorNoStatusReceived = 1005,
26   kWebSocketErrorAbnormalClosure = 1006,
27   kWebSocketErrorInvalidFramePayloadData = 1007,
28   kWebSocketErrorPolicyViolation = 1008,
29   kWebSocketErrorMessageTooBig = 1009,
30   kWebSocketErrorMandatoryExtension = 1010,
31   kWebSocketErrorInternalServerError = 1011,
32   kWebSocketErrorTlsHandshake = 1015,
33 
34   // The range 1000-2999 is reserved by RFC6455 for use by the WebSocket
35   // protocol and public extensions.
36   kWebSocketErrorProtocolReservedMax = 2999,
37 
38   // The range 3000-3999 is reserved by RFC6455 for registered use by libraries,
39   // frameworks and applications.
40   kWebSocketErrorRegisteredReservedMin = 3000,
41   kWebSocketErrorRegisteredReservedMax = 3999,
42 
43   // The range 4000-4999 is reserved by RFC6455 for private use by prior
44   // agreement of the endpoints.
45   kWebSocketErrorPrivateReservedMin = 4000,
46   kWebSocketErrorPrivateReservedMax = 4999,
47 };
48 
49 // Convert WebSocketError to net::Error defined in net/base/net_errors.h.
50 NET_EXPORT_PRIVATE Error WebSocketErrorToNetError(WebSocketError error);
51 
52 }  // namespace net
53 
54 #endif  // NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
55