Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_simple_job.cc ('k') | net/websockets/websocket_end_to_end_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7d993114034836a3f92d0f153ece8e340cb953fd 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,16 @@ 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) {
+ http_response_info_->headers->ReplaceStatusLine(
+ kConnectionErrorStatusLine);
+ }
return rv;
}
}
« no previous file with comments | « net/url_request/url_request_simple_job.cc ('k') | net/websockets/websocket_end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698