Chromium Code Reviews| Index: net/websockets/websocket_stream.cc |
| diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc |
| index 304edc75c9a8bb31a16dcc2c1d72993c2f2e5e3e..dac1814981138e6bd22c79e7714fd4218df43d22 100644 |
| --- a/net/websockets/websocket_stream.cc |
| +++ b/net/websockets/websocket_stream.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/metrics/sparse_histogram.h" |
| #include "net/base/load_flags.h" |
| #include "net/http/http_request_headers.h" |
| +#include "net/http/http_response_headers.h" |
| #include "net/http/http_status_code.h" |
| #include "net/url_request/url_request.h" |
| #include "net/url_request/url_request_context.h" |
| @@ -135,9 +136,25 @@ class StreamRequestImpl : public WebSocketStreamRequest { |
| break; |
| } |
| } |
| + ReportFailureWithMessage(failure_message); |
| + } |
| + |
| + void ReportFailureWithMessage(const std::string& failure_message) { |
| connect_delegate_->OnFailure(failure_message); |
| } |
| + void OnFinishOpeningHandshake() { |
|
tyoshino (SeeGerritForStatus)
2014/07/07 19:26:44
this looks similar to
WebSocketBasicHandshakeStrea
Adam Rice
2014/07/08 10:23:45
Yes. Factored out in a separate function used by b
|
| + HttpResponseHeaders* headers = url_request_.response_headers(); |
| + if (headers) { |
| + connect_delegate_->OnFinishOpeningHandshake(make_scoped_ptr( |
| + new WebSocketHandshakeResponseInfo(url_request_.url(), |
| + headers->response_code(), |
| + headers->GetStatusText(), |
| + headers, |
| + url_request_.response_time()))); |
| + } |
| + } |
| + |
| WebSocketStream::ConnectDelegate* connect_delegate() const { |
| return connect_delegate_.get(); |
| } |
| @@ -197,7 +214,16 @@ void Delegate::OnResponseStarted(URLRequest* request) { |
| return; |
| case HTTP_UNAUTHORIZED: |
| + result_ = FAILED; |
| + owner_->OnFinishOpeningHandshake(); |
| + owner_->ReportFailureWithMessage( |
| + "HTTP Authentication failed; no valid credentials available"); |
| + return; |
| + |
| case HTTP_PROXY_AUTHENTICATION_REQUIRED: |
| + result_ = FAILED; |
| + owner_->OnFinishOpeningHandshake(); |
| + owner_->ReportFailureWithMessage("Proxy authentication failed"); |
| return; |
| default: |