websocket_errors.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2012 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. #ifndef NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
  5. #define NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
  6. #include "net/base/net_errors.h"
  7. #include "net/base/net_export.h"
  8. namespace net {
  9. // Reason codes used with close messages. NoStatusReceived,
  10. // AbnormalClosure and TlsHandshake are special in that they
  11. // should never be sent on the wire; they are only used within the
  12. // implementation.
  13. enum WebSocketError {
  14. // Status codes in the range 0 to 999 are not used.
  15. // The following are defined by RFC6455.
  16. kWebSocketNormalClosure = 1000,
  17. kWebSocketErrorGoingAway = 1001,
  18. kWebSocketErrorProtocolError = 1002,
  19. kWebSocketErrorUnsupportedData = 1003,
  20. kWebSocketErrorNoStatusReceived = 1005,
  21. kWebSocketErrorAbnormalClosure = 1006,
  22. kWebSocketErrorInvalidFramePayloadData = 1007,
  23. kWebSocketErrorPolicyViolation = 1008,
  24. kWebSocketErrorMessageTooBig = 1009,
  25. kWebSocketErrorMandatoryExtension = 1010,
  26. kWebSocketErrorInternalServerError = 1011,
  27. kWebSocketErrorTlsHandshake = 1015,
  28. // The range 1000-2999 is reserved by RFC6455 for use by the WebSocket
  29. // protocol and public extensions.
  30. kWebSocketErrorProtocolReservedMax = 2999,
  31. // The range 3000-3999 is reserved by RFC6455 for registered use by libraries,
  32. // frameworks and applications.
  33. kWebSocketErrorRegisteredReservedMin = 3000,
  34. kWebSocketErrorRegisteredReservedMax = 3999,
  35. // The range 4000-4999 is reserved by RFC6455 for private use by prior
  36. // agreement of the endpoints.
  37. kWebSocketErrorPrivateReservedMin = 4000,
  38. kWebSocketErrorPrivateReservedMax = 4999,
  39. };
  40. // Convert WebSocketError to net::Error defined in net/base/net_errors.h.
  41. NET_EXPORT_PRIVATE Error WebSocketErrorToNetError(WebSocketError error);
  42. } // namespace net
  43. #endif // NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_