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

Unified Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 152483003: [WebSocket] Add Cache-Control to the request header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: status code => response code Created 6 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 | « no previous file | net/websockets/websocket_handshake_stream_create_helper_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 808383bacf40f99fac7fea6c3640cdb732398ca3..5a2806071f9c57fe1b9079f3465a77f5c720a1a2 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -234,7 +234,7 @@ bool ValidatePerMessageDeflateExtension(const WebSocketExtension& extension,
the_strings_server_and_client_must_be_the_same_length);
typedef std::vector<WebSocketExtension::Parameter> ParameterVector;
- DCHECK(extension.name() == "permessage-deflate");
+ DCHECK_EQ("permessage-deflate", extension.name());
const ParameterVector& parameters = extension.parameters();
std::set<std::string> seen_names;
for (ParameterVector::const_iterator it = parameters.begin();
@@ -526,10 +526,19 @@ std::string WebSocketBasicHandshakeStream::GetFailureMessage() const {
void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback(
const CompletionCallback& callback,
int result) {
- if (result == OK)
+ if (result == OK) {
result = ValidateResponse();
- else
+ } else {
+ std::string message = "Unknown failure";
+ const scoped_refptr<HttpResponseHeaders>& headers =
+ http_response_info_->headers;
+ if (headers) {
+ message = base::StringPrintf("Unexpected response code: %d",
+ headers->response_code());
+ }
+ failure_message_ = "Error during WebSocket handshake: " + message;
OnFinishOpeningHandshake();
Adam Rice 2014/02/03 08:43:52 OnFinishOpeningHandshake() is also called at line
yhirano 2014/02/03 09:32:52 Done in ValidateResponse. HttpStreamParser return
Adam Rice 2014/02/04 03:52:46 In my tests, HttpStreamParser returns a positive v
yhirano 2014/02/04 04:15:50 Done.
+ }
callback.Run(result);
}
@@ -564,7 +573,7 @@ int WebSocketBasicHandshakeStream::ValidateResponse() {
// 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("Unexpected status code: %d",
+ failure_message_ = base::StringPrintf("Unexpected response code: %d",
headers->response_code());
OnFinishOpeningHandshake();
return ERR_INVALID_RESPONSE;
« no previous file with comments | « no previous file | net/websockets/websocket_handshake_stream_create_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698