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

Unified Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 173523004: Use a better error message for bad status lines. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update WebSocketStreamCreateTest.MalformedResponse Created 6 years, 10 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 | « no previous file | net/websockets/websocket_stream_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 6d769e0d35ab9f4b43c1e58e77deffa681e84375..85dad8c9011b37dd59a8b7100ec073494efcaf34 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -565,9 +565,18 @@ int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
// Other status codes are potentially risky (see the warnings in the
// WHATWG WebSocket API spec) and so are dropped by default.
default:
- failure_message_ = base::StringPrintf(
- "Error during WebSocket handshake: Unexpected response code: %d",
- headers->response_code());
+ // A WebSocket server cannot be using HTTP/0.9, so if we see version
+ // 0.9, it means the response was garbage.
+ // Reporting "Unexpected response code: 200" in this case is not
+ // helpful, so use a different error message.
+ if (headers->GetHttpVersion() == HttpVersion(0, 9)) {
+ failure_message_ =
+ "Error during WebSocket handshake: Invalid status line";
+ } else {
+ failure_message_ = base::StringPrintf(
+ "Error during WebSocket handshake: Unexpected response code: %d",
+ headers->response_code());
+ }
OnFinishOpeningHandshake();
return ERR_INVALID_RESPONSE;
}
« no previous file with comments | « no previous file | net/websockets/websocket_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698