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

Side by Side Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 336263005: Map WebSocket URL schemes to HTTP URL schemes for auth purposes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace accidentally removed #include <string> Created 6 years, 4 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 unified diff | Download patch
OLDNEW
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
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_);
543 DCHECK(http_response_info_); 542 DCHECK(http_response_info_);
544 scoped_refptr<HttpResponseHeaders> headers = http_response_info_->headers; 543 WebSocketDispatchOnFinishOpeningHandshake(connect_delegate_,
545 // If the headers are too large, HttpStreamParser will just not parse them at 544 url_,
546 // all. 545 http_response_info_->headers,
547 if (headers) { 546 http_response_info_->response_time);
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 }
556 } 547 }
557 548
558 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { 549 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
559 DCHECK(http_response_info_); 550 DCHECK(http_response_info_);
560 // Most net errors happen during connection, so they are not seen by this 551 // Most net errors happen during connection, so they are not seen by this
561 // method. The histogram for error codes is created in 552 // method. The histogram for error codes is created in
562 // Delegate::OnResponseStarted in websocket_stream.cc instead. 553 // Delegate::OnResponseStarted in websocket_stream.cc instead.
563 if (rv >= 0) { 554 if (rv >= 0) {
564 const HttpResponseHeaders* headers = http_response_info_->headers.get(); 555 const HttpResponseHeaders* headers = http_response_info_->headers.get();
565 const int response_code = headers->response_code(); 556 const int response_code = headers->response_code();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 set_failure_message("Error during WebSocket handshake: " + failure_message); 618 set_failure_message("Error during WebSocket handshake: " + failure_message);
628 return ERR_INVALID_RESPONSE; 619 return ERR_INVALID_RESPONSE;
629 } 620 }
630 621
631 void WebSocketBasicHandshakeStream::set_failure_message( 622 void WebSocketBasicHandshakeStream::set_failure_message(
632 const std::string& failure_message) { 623 const std::string& failure_message) {
633 *failure_message_ = failure_message; 624 *failure_message_ = failure_message;
634 } 625 }
635 626
636 } // namespace net 627 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698