Commit ceae3b24 authored by tyoshino's avatar tyoshino Committed by Commit bot

[WebSocket] Pass received status code of 0 to script as-is

0 is not a valid close code, but we're passing through the other invalid
codes. Let's apply the rule also to 0 for consistency.

R=ricea
BUG=428794

Review URL: https://codereview.chromium.org/690753009

Cr-Commit-Position: refs/heads/master@{#302233}
parent 9d6e421c
...@@ -297,6 +297,7 @@ WebSocketChannel::WebSocketChannel( ...@@ -297,6 +297,7 @@ WebSocketChannel::WebSocketChannel(
current_send_quota_(0), current_send_quota_(0),
current_receive_quota_(0), current_receive_quota_(0),
timeout_(base::TimeDelta::FromSeconds(kClosingHandshakeTimeoutSeconds)), timeout_(base::TimeDelta::FromSeconds(kClosingHandshakeTimeoutSeconds)),
has_received_close_frame_(false),
received_close_code_(0), received_close_code_(0),
state_(FRESHLY_CONSTRUCTED), state_(FRESHLY_CONSTRUCTED),
notification_sender_(new HandshakeNotificationSender(this)), notification_sender_(new HandshakeNotificationSender(this)),
...@@ -744,7 +745,7 @@ ChannelState WebSocketChannel::OnReadDone(bool synchronous, int result) { ...@@ -744,7 +745,7 @@ ChannelState WebSocketChannel::OnReadDone(bool synchronous, int result) {
uint16 code = kWebSocketErrorAbnormalClosure; uint16 code = kWebSocketErrorAbnormalClosure;
std::string reason = ""; std::string reason = "";
bool was_clean = false; bool was_clean = false;
if (received_close_code_ != 0) { if (has_received_close_frame_) {
code = received_close_code_; code = received_close_code_;
reason = received_close_reason_; reason = received_close_reason_;
was_clean = (result == ERR_CONNECTION_CLOSED); was_clean = (result == ERR_CONNECTION_CLOSED);
...@@ -844,6 +845,7 @@ ChannelState WebSocketChannel::HandleFrameByState( ...@@ -844,6 +845,7 @@ ChannelState WebSocketChannel::HandleFrameByState(
if (event_interface_->OnClosingHandshake() == CHANNEL_DELETED) if (event_interface_->OnClosingHandshake() == CHANNEL_DELETED)
return CHANNEL_DELETED; return CHANNEL_DELETED;
has_received_close_frame_ = true;
received_close_code_ = code; received_close_code_ = code;
received_close_reason_ = reason; received_close_reason_ = reason;
break; break;
...@@ -853,6 +855,7 @@ ChannelState WebSocketChannel::HandleFrameByState( ...@@ -853,6 +855,7 @@ ChannelState WebSocketChannel::HandleFrameByState(
// From RFC6455 section 7.1.5: "Each endpoint // From RFC6455 section 7.1.5: "Each endpoint
// will see the status code sent by the other end as _The WebSocket // will see the status code sent by the other end as _The WebSocket
// Connection Close Code_." // Connection Close Code_."
has_received_close_frame_ = true;
received_close_code_ = code; received_close_code_ = code;
received_close_reason_ = reason; received_close_reason_ = reason;
break; break;
......
...@@ -379,6 +379,7 @@ class NET_EXPORT WebSocketChannel { ...@@ -379,6 +379,7 @@ class NET_EXPORT WebSocketChannel {
// Storage for the status code and reason from the time the Close frame // Storage for the status code and reason from the time the Close frame
// arrives until the connection is closed and they are passed to // arrives until the connection is closed and they are passed to
// OnDropChannel(). // OnDropChannel().
bool has_received_close_frame_;
uint16 received_close_code_; uint16 received_close_code_;
std::string received_close_reason_; std::string received_close_reason_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment