blob: 2b95b6ac1773079a2fb3e295be9c586efc479cad [file] [log] [blame]
Avi Drissman64595482022-09-14 20:52:291// Copyright 2012 The Chromium Authors
[email protected]be5a7822012-08-06 15:36:102// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]a97ee922013-01-18 05:32:555#include "net/websockets/websocket_errors.h"
6
[email protected]be5a7822012-08-06 15:36:107
8namespace net {
9
10Error WebSocketErrorToNetError(WebSocketError error) {
11 switch (error) {
[email protected]40e9c62f2013-05-07 14:59:2112 case kWebSocketNormalClosure:
[email protected]be5a7822012-08-06 15:36:1013 return OK;
[email protected]40e9c62f2013-05-07 14:59:2114
15 case kWebSocketErrorGoingAway: // TODO(ricea): More specific code?
16 case kWebSocketErrorProtocolError:
17 case kWebSocketErrorUnsupportedData:
18 case kWebSocketErrorInvalidFramePayloadData:
19 case kWebSocketErrorPolicyViolation:
20 case kWebSocketErrorMandatoryExtension:
21 case kWebSocketErrorInternalServerError:
[email protected]be5a7822012-08-06 15:36:1022 return ERR_WS_PROTOCOL_ERROR;
[email protected]40e9c62f2013-05-07 14:59:2123
24 case kWebSocketErrorNoStatusReceived:
25 case kWebSocketErrorAbnormalClosure:
26 return ERR_CONNECTION_CLOSED;
27
28 case kWebSocketErrorTlsHandshake:
29 // This error will probably be reported with more detail at a lower layer;
30 // this is the best we can do at this layer.
31 return ERR_SSL_PROTOCOL_ERROR;
32
33 case kWebSocketErrorMessageTooBig:
[email protected]be5a7822012-08-06 15:36:1034 return ERR_MSG_TOO_BIG;
[email protected]40e9c62f2013-05-07 14:59:2135
[email protected]be5a7822012-08-06 15:36:1036 default:
[email protected]a97ee922013-01-18 05:32:5537 return ERR_UNEXPECTED;
[email protected]be5a7822012-08-06 15:36:1038 }
39}
40
41} // namespace net