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

Side by Side Diff: net/spdy/spdy_session.cc

Issue 9958023: Properly handle spdy3 responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 int certificate_error_code) { 417 int certificate_error_code) {
418 base::StatsCounter spdy_sessions("spdy.sessions"); 418 base::StatsCounter spdy_sessions("spdy.sessions");
419 spdy_sessions.Increment(); 419 spdy_sessions.Increment();
420 420
421 state_ = CONNECTED; 421 state_ = CONNECTED;
422 connection_.reset(connection); 422 connection_.reset(connection);
423 is_secure_ = is_secure; 423 is_secure_ = is_secure;
424 certificate_error_code_ = certificate_error_code; 424 certificate_error_code_ = certificate_error_code;
425 425
426 NextProto protocol = g_default_protocol; 426 NextProto protocol = g_default_protocol;
427 if (is_secure_) { 427 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol();
428 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 428 if (protocol_negotiated != kProtoUnknown) {
429 NextProto protocol_negotiated = ssl_socket->protocol_negotiated(); 429 protocol = protocol_negotiated;
430 if (protocol_negotiated != kProtoUnknown) { 430 }
431 protocol = protocol_negotiated;
432 }
433 431
434 if (ssl_socket->WasDomainBoundCertSent()) { 432 SSLClientSocket* ssl_socket = GetSSLClientSocket();
435 // According to the SPDY spec, the credential associated with the TLS 433 if (ssl_socket && ssl_socket->WasDomainBoundCertSent()) {
436 // connection is stored in slot[1]. 434 // According to the SPDY spec, the credential associated with the TLS
437 credential_state_.SetHasCredential(GURL("https://" + 435 // connection is stored in slot[1].
438 host_port_pair().ToString())); 436 credential_state_.SetHasCredential(GURL("https://" +
439 } 437 host_port_pair().ToString()));
440 } 438 }
441 439
442 DCHECK(protocol >= kProtoSPDY2); 440 DCHECK(protocol >= kProtoSPDY2);
443 DCHECK(protocol <= kProtoSPDY3); 441 DCHECK(protocol <= kProtoSPDY3);
444 int version = (protocol == kProtoSPDY3) ? 3 : 2; 442 int version = (protocol == kProtoSPDY3) ? 3 : 2;
445 flow_control_ = (protocol >= kProtoSPDY21); 443 flow_control_ = (protocol >= kProtoSPDY21);
446 444
447 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); 445 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version));
448 buffered_spdy_framer_->set_visitor(this); 446 buffered_spdy_framer_->set_visitor(this);
449 SendSettings(); 447 SendSettings();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 void SpdySession::CloseStream(SpdyStreamId stream_id, int status) { 805 void SpdySession::CloseStream(SpdyStreamId stream_id, int status) {
808 // TODO(mbelshe): We should send a RST_STREAM control frame here 806 // TODO(mbelshe): We should send a RST_STREAM control frame here
809 // so that the server can cancel a large send. 807 // so that the server can cancel a large send.
810 808
811 DeleteStream(stream_id, status); 809 DeleteStream(stream_id, status);
812 } 810 }
813 811
814 void SpdySession::ResetStream(SpdyStreamId stream_id, 812 void SpdySession::ResetStream(SpdyStreamId stream_id,
815 SpdyStatusCodes status, 813 SpdyStatusCodes status,
816 const std::string& description) { 814 const std::string& description) {
817
818 net_log().AddEvent( 815 net_log().AddEvent(
819 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM, 816 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM,
820 make_scoped_refptr(new NetLogSpdyRstParameter(stream_id, status, 817 make_scoped_refptr(new NetLogSpdyRstParameter(stream_id, status,
821 description))); 818 description)));
822 819
823 DCHECK(buffered_spdy_framer_.get()); 820 DCHECK(buffered_spdy_framer_.get());
824 scoped_ptr<SpdyRstStreamControlFrame> rst_frame( 821 scoped_ptr<SpdyRstStreamControlFrame> rst_frame(
825 buffered_spdy_framer_->CreateRstStream(stream_id, status)); 822 buffered_spdy_framer_->CreateRstStream(stream_id, status));
826 823
827 // Default to lowest priority unless we know otherwise. 824 // Default to lowest priority unless we know otherwise.
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 associated_stream_id, stream_id); 1398 associated_stream_id, stream_id);
1402 ResetStream(stream_id, INVALID_STREAM, description); 1399 ResetStream(stream_id, INVALID_STREAM, description);
1403 return; 1400 return;
1404 } 1401 }
1405 1402
1406 streams_pushed_count_++; 1403 streams_pushed_count_++;
1407 1404
1408 // TODO(mbelshe): DCHECK that this is a GET method? 1405 // TODO(mbelshe): DCHECK that this is a GET method?
1409 1406
1410 // Verify that the response had a URL for us. 1407 // Verify that the response had a URL for us.
1411 const std::string& url = ContainsKey(*headers, "url") ? 1408 GURL gurl = GetUrlFromHeaderBlock(*headers, GetProtocolVersion(), true);
1412 headers->find("url")->second : ""; 1409 if (!gurl.is_valid()) {
1413 if (url.empty()) {
1414 ResetStream(stream_id, PROTOCOL_ERROR, 1410 ResetStream(stream_id, PROTOCOL_ERROR,
1415 "Pushed stream did not contain a url."); 1411 "Pushed stream url was invalid: " + gurl.spec());
1416 return; 1412 return;
1417 } 1413 }
1418 1414 const std::string& url = gurl.spec();
1419 GURL gurl(url);
1420 if (!gurl.is_valid()) {
1421 ResetStream(stream_id, PROTOCOL_ERROR,
1422 "Pushed stream url was invalid: " + url);
1423 return;
1424 }
1425 1415
1426 // Verify we have a valid stream association. 1416 // Verify we have a valid stream association.
1427 if (!IsStreamActive(associated_stream_id)) { 1417 if (!IsStreamActive(associated_stream_id)) {
1428 ResetStream(stream_id, INVALID_ASSOCIATED_STREAM, 1418 ResetStream(stream_id, INVALID_ASSOCIATED_STREAM,
1429 base::StringPrintf( 1419 base::StringPrintf(
1430 "Received OnSyn with inactive associated stream %d", 1420 "Received OnSyn with inactive associated stream %d",
1431 associated_stream_id)); 1421 associated_stream_id));
1432 return; 1422 return;
1433 } 1423 }
1434 1424
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1937 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1948 if (!is_secure_) 1938 if (!is_secure_)
1949 return NULL; 1939 return NULL;
1950 SSLClientSocket* ssl_socket = 1940 SSLClientSocket* ssl_socket =
1951 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1941 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1952 DCHECK(ssl_socket); 1942 DCHECK(ssl_socket);
1953 return ssl_socket; 1943 return ssl_socket;
1954 } 1944 }
1955 1945
1956 } // namespace net 1946 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698