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 21 matching lines...) Expand all Loading... |
32 #include "net/http/http_status_code.h" | 32 #include "net/http/http_status_code.h" |
33 #include "net/http/http_stream_parser.h" | 33 #include "net/http/http_stream_parser.h" |
34 #include "net/socket/client_socket_handle.h" | 34 #include "net/socket/client_socket_handle.h" |
35 #include "net/socket/websocket_transport_client_socket_pool.h" | 35 #include "net/socket/websocket_transport_client_socket_pool.h" |
36 #include "net/websockets/websocket_basic_stream.h" | 36 #include "net/websockets/websocket_basic_stream.h" |
37 #include "net/websockets/websocket_deflate_predictor.h" | 37 #include "net/websockets/websocket_deflate_predictor.h" |
38 #include "net/websockets/websocket_deflate_predictor_impl.h" | 38 #include "net/websockets/websocket_deflate_predictor_impl.h" |
39 #include "net/websockets/websocket_deflate_stream.h" | 39 #include "net/websockets/websocket_deflate_stream.h" |
40 #include "net/websockets/websocket_deflater.h" | 40 #include "net/websockets/websocket_deflater.h" |
41 #include "net/websockets/websocket_extension_parser.h" | 41 #include "net/websockets/websocket_extension_parser.h" |
| 42 #include "net/websockets/websocket_handshake_challenge.h" |
42 #include "net/websockets/websocket_handshake_constants.h" | 43 #include "net/websockets/websocket_handshake_constants.h" |
43 #include "net/websockets/websocket_handshake_handler.h" | |
44 #include "net/websockets/websocket_handshake_request_info.h" | 44 #include "net/websockets/websocket_handshake_request_info.h" |
45 #include "net/websockets/websocket_handshake_response_info.h" | 45 #include "net/websockets/websocket_handshake_response_info.h" |
46 #include "net/websockets/websocket_stream.h" | 46 #include "net/websockets/websocket_stream.h" |
47 | 47 |
48 namespace net { | 48 namespace net { |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 // TODO(yhirano): Remove these functions once http://crbug.com/399535 is fixed. | 52 // TODO(yhirano): Remove these functions once http://crbug.com/399535 is fixed. |
53 NOINLINE void RunCallbackWithOk(const CompletionCallback& callback, | 53 NOINLINE void RunCallbackWithOk(const CompletionCallback& callback, |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 428 } |
429 enriched_headers.SetHeader(websockets::kSecWebSocketKey, handshake_challenge); | 429 enriched_headers.SetHeader(websockets::kSecWebSocketKey, handshake_challenge); |
430 | 430 |
431 AddVectorHeaderIfNonEmpty(websockets::kSecWebSocketExtensions, | 431 AddVectorHeaderIfNonEmpty(websockets::kSecWebSocketExtensions, |
432 requested_extensions_, | 432 requested_extensions_, |
433 &enriched_headers); | 433 &enriched_headers); |
434 AddVectorHeaderIfNonEmpty(websockets::kSecWebSocketProtocol, | 434 AddVectorHeaderIfNonEmpty(websockets::kSecWebSocketProtocol, |
435 requested_sub_protocols_, | 435 requested_sub_protocols_, |
436 &enriched_headers); | 436 &enriched_headers); |
437 | 437 |
438 ComputeSecWebSocketAccept(handshake_challenge, | 438 handshake_challenge_response_ = |
439 &handshake_challenge_response_); | 439 ComputeSecWebSocketAccept(handshake_challenge); |
440 | 440 |
441 DCHECK(connect_delegate_); | 441 DCHECK(connect_delegate_); |
442 scoped_ptr<WebSocketHandshakeRequestInfo> request( | 442 scoped_ptr<WebSocketHandshakeRequestInfo> request( |
443 new WebSocketHandshakeRequestInfo(url_, base::Time::Now())); | 443 new WebSocketHandshakeRequestInfo(url_, base::Time::Now())); |
444 request->headers.CopyFrom(enriched_headers); | 444 request->headers.CopyFrom(enriched_headers); |
445 connect_delegate_->OnStartOpeningHandshake(request.Pass()); | 445 connect_delegate_->OnStartOpeningHandshake(request.Pass()); |
446 | 446 |
447 return parser()->SendRequest( | 447 return parser()->SendRequest( |
448 state_.GenerateRequestLine(), enriched_headers, response, callback); | 448 state_.GenerateRequestLine(), enriched_headers, response, callback); |
449 } | 449 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 set_failure_message("Error during WebSocket handshake: " + failure_message); | 679 set_failure_message("Error during WebSocket handshake: " + failure_message); |
680 return ERR_INVALID_RESPONSE; | 680 return ERR_INVALID_RESPONSE; |
681 } | 681 } |
682 | 682 |
683 void WebSocketBasicHandshakeStream::set_failure_message( | 683 void WebSocketBasicHandshakeStream::set_failure_message( |
684 const std::string& failure_message) { | 684 const std::string& failure_message) { |
685 *failure_message_ = failure_message; | 685 *failure_message_ = failure_message; |
686 } | 686 } |
687 | 687 |
688 } // namespace net | 688 } // namespace net |
OLD | NEW |