0
Files
src/net/websockets/websocket_errors.cc
Avi Drissman 6459548ee3 Update copyright headers in net/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c95.

No-Try: true
Bug: 1098010
Change-Id: I26884c98578ee1ba4d7708ace5b25d1df5c0e576
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895939
Owners-Override: Avi Drissman <avi@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047098}
2022-09-14 20:52:29 +00:00

42 lines
1.1 KiB
C++

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/websockets/websocket_errors.h"
namespace net {
Error WebSocketErrorToNetError(WebSocketError error) {
switch (error) {
case kWebSocketNormalClosure:
return OK;
case kWebSocketErrorGoingAway: // TODO(ricea): More specific code?
case kWebSocketErrorProtocolError:
case kWebSocketErrorUnsupportedData:
case kWebSocketErrorInvalidFramePayloadData:
case kWebSocketErrorPolicyViolation:
case kWebSocketErrorMandatoryExtension:
case kWebSocketErrorInternalServerError:
return ERR_WS_PROTOCOL_ERROR;
case kWebSocketErrorNoStatusReceived:
case kWebSocketErrorAbnormalClosure:
return ERR_CONNECTION_CLOSED;
case kWebSocketErrorTlsHandshake:
// This error will probably be reported with more detail at a lower layer;
// this is the best we can do at this layer.
return ERR_SSL_PROTOCOL_ERROR;
case kWebSocketErrorMessageTooBig:
return ERR_MSG_TOO_BIG;
default:
return ERR_UNEXPECTED;
}
}
} // namespace net