| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/websockets/websocket_basic_handshake_stream.h" | 5 #include "net/websockets/websocket_basic_handshake_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 handshake_challenge_for_testing_.reset(new std::string(key)); | 532 handshake_challenge_for_testing_.reset(new std::string(key)); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback( | 535 void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback( |
| 536 const CompletionCallback& callback, | 536 const CompletionCallback& callback, |
| 537 int result) { | 537 int result) { |
| 538 callback.Run(ValidateResponse(result)); | 538 callback.Run(ValidateResponse(result)); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void WebSocketBasicHandshakeStream::OnFinishOpeningHandshake() { | 541 void WebSocketBasicHandshakeStream::OnFinishOpeningHandshake() { |
| 542 DCHECK(connect_delegate_); |
| 542 DCHECK(http_response_info_); | 543 DCHECK(http_response_info_); |
| 543 WebSocketDispatchOnFinishOpeningHandshake(connect_delegate_, | 544 scoped_refptr<HttpResponseHeaders> headers = http_response_info_->headers; |
| 544 url_, | 545 // If the headers are too large, HttpStreamParser will just not parse them at |
| 545 http_response_info_->headers, | 546 // all. |
| 546 http_response_info_->response_time); | 547 if (headers) { |
| 548 scoped_ptr<WebSocketHandshakeResponseInfo> response( |
| 549 new WebSocketHandshakeResponseInfo(url_, |
| 550 headers->response_code(), |
| 551 headers->GetStatusText(), |
| 552 headers, |
| 553 http_response_info_->response_time)); |
| 554 connect_delegate_->OnFinishOpeningHandshake(response.Pass()); |
| 555 } |
| 547 } | 556 } |
| 548 | 557 |
| 549 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { | 558 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { |
| 550 DCHECK(http_response_info_); | 559 DCHECK(http_response_info_); |
| 551 // Most net errors happen during connection, so they are not seen by this | 560 // Most net errors happen during connection, so they are not seen by this |
| 552 // method. The histogram for error codes is created in | 561 // method. The histogram for error codes is created in |
| 553 // Delegate::OnResponseStarted in websocket_stream.cc instead. | 562 // Delegate::OnResponseStarted in websocket_stream.cc instead. |
| 554 if (rv >= 0) { | 563 if (rv >= 0) { |
| 555 const HttpResponseHeaders* headers = http_response_info_->headers.get(); | 564 const HttpResponseHeaders* headers = http_response_info_->headers.get(); |
| 556 const int response_code = headers->response_code(); | 565 const int response_code = headers->response_code(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 set_failure_message("Error during WebSocket handshake: " + failure_message); | 627 set_failure_message("Error during WebSocket handshake: " + failure_message); |
| 619 return ERR_INVALID_RESPONSE; | 628 return ERR_INVALID_RESPONSE; |
| 620 } | 629 } |
| 621 | 630 |
| 622 void WebSocketBasicHandshakeStream::set_failure_message( | 631 void WebSocketBasicHandshakeStream::set_failure_message( |
| 623 const std::string& failure_message) { | 632 const std::string& failure_message) { |
| 624 *failure_message_ = failure_message; | 633 *failure_message_ = failure_message; |
| 625 } | 634 } |
| 626 | 635 |
| 627 } // namespace net | 636 } // namespace net |
| OLD | NEW |