Index: net/websockets/websocket_basic_handshake_stream.cc |
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc |
index c0f20c7266e2e05f6b78d4642a24782ecdd13242..cff11fe7f852c513530bc6b62f95b13dacb8cb31 100644 |
--- a/net/websockets/websocket_basic_handshake_stream.cc |
+++ b/net/websockets/websocket_basic_handshake_stream.cc |
@@ -50,6 +50,8 @@ namespace net { |
namespace { |
+const char kConnectionErrorStatusLine[] = "HTTP/1.1 503 Connection Error"; |
+ |
// TODO(yhirano): Remove these functions once http://crbug.com/399535 is fixed. |
NOINLINE void RunCallbackWithOk(const CompletionCallback& callback, |
int result) { |
@@ -654,6 +656,15 @@ int WebSocketBasicHandshakeStream::ValidateResponse(int rv, |
set_failure_message(std::string("Error during WebSocket handshake: ") + |
ErrorToString(rv)); |
OnFinishOpeningHandshake(); |
+ // Some error codes (for example ERR_CONNECTION_CLOSED) get changed to OK at |
+ // higher levels. To prevent an unvalidated connection getting erroneously |
+ // upgraded, don't pass through the status code unchanged if it is |
+ // HTTP_SWITCHING_PROTOCOLS. |
+ if (http_response_info_->headers && |
+ http_response_info_->headers->response_code() == |
+ HTTP_SWITCHING_PROTOCOLS) |
yhirano
2015/02/02 11:06:47
[optional] This condition is not simple and the ac
Adam Rice
2015/02/02 12:10:26
Done. Thanks.
|
+ http_response_info_->headers->ReplaceStatusLine( |
+ kConnectionErrorStatusLine); |
return rv; |
} |
} |