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

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
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_spdy3_unittest.cc ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 base::StatsCounter spdy_sessions("spdy.sessions"); 429 base::StatsCounter spdy_sessions("spdy.sessions");
430 spdy_sessions.Increment(); 430 spdy_sessions.Increment();
431 431
432 state_ = CONNECTED; 432 state_ = CONNECTED;
433 connection_.reset(connection); 433 connection_.reset(connection);
434 connection_->AddLayeredPool(this); 434 connection_->AddLayeredPool(this);
435 is_secure_ = is_secure; 435 is_secure_ = is_secure;
436 certificate_error_code_ = certificate_error_code; 436 certificate_error_code_ = certificate_error_code;
437 437
438 NextProto protocol = g_default_protocol; 438 NextProto protocol = g_default_protocol;
439 if (is_secure_) { 439 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol();
440 SSLClientSocket* ssl_socket = GetSSLClientSocket(); 440 if (protocol_negotiated != kProtoUnknown) {
441 NextProto protocol_negotiated = ssl_socket->GetNegotiatedProtocol(); 441 protocol = protocol_negotiated;
442 if (protocol_negotiated != kProtoUnknown) { 442 }
443 protocol = protocol_negotiated;
444 }
445 443
446 if (ssl_socket->WasDomainBoundCertSent()) { 444 SSLClientSocket* ssl_socket = GetSSLClientSocket();
447 // According to the SPDY spec, the credential associated with the TLS 445 if (ssl_socket && ssl_socket->WasDomainBoundCertSent()) {
448 // connection is stored in slot[1]. 446 // According to the SPDY spec, the credential associated with the TLS
449 credential_state_.SetHasCredential(GURL("https://" + 447 // connection is stored in slot[1].
450 host_port_pair().ToString())); 448 credential_state_.SetHasCredential(GURL("https://" +
451 } 449 host_port_pair().ToString()));
452 } 450 }
453 451
454 DCHECK(protocol >= kProtoSPDY2); 452 DCHECK(protocol >= kProtoSPDY2);
455 DCHECK(protocol <= kProtoSPDY3); 453 DCHECK(protocol <= kProtoSPDY3);
456 int version = (protocol == kProtoSPDY3) ? 3 : 2; 454 int version = (protocol == kProtoSPDY3) ? 3 : 2;
457 flow_control_ = (protocol >= kProtoSPDY21); 455 flow_control_ = (protocol >= kProtoSPDY21);
458 456
459 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); 457 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version));
460 buffered_spdy_framer_->set_visitor(this); 458 buffered_spdy_framer_->set_visitor(this);
461 SendSettings(); 459 SendSettings();
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 void SpdySession::CloseStream(SpdyStreamId stream_id, int status) { 816 void SpdySession::CloseStream(SpdyStreamId stream_id, int status) {
819 // TODO(mbelshe): We should send a RST_STREAM control frame here 817 // TODO(mbelshe): We should send a RST_STREAM control frame here
820 // so that the server can cancel a large send. 818 // so that the server can cancel a large send.
821 819
822 DeleteStream(stream_id, status); 820 DeleteStream(stream_id, status);
823 } 821 }
824 822
825 void SpdySession::ResetStream(SpdyStreamId stream_id, 823 void SpdySession::ResetStream(SpdyStreamId stream_id,
826 SpdyStatusCodes status, 824 SpdyStatusCodes status,
827 const std::string& description) { 825 const std::string& description) {
828
829 net_log().AddEvent( 826 net_log().AddEvent(
830 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM, 827 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM,
831 make_scoped_refptr(new NetLogSpdyRstParameter(stream_id, status, 828 make_scoped_refptr(new NetLogSpdyRstParameter(stream_id, status,
832 description))); 829 description)));
833 830
834 DCHECK(buffered_spdy_framer_.get()); 831 DCHECK(buffered_spdy_framer_.get());
835 scoped_ptr<SpdyRstStreamControlFrame> rst_frame( 832 scoped_ptr<SpdyRstStreamControlFrame> rst_frame(
836 buffered_spdy_framer_->CreateRstStream(stream_id, status)); 833 buffered_spdy_framer_->CreateRstStream(stream_id, status));
837 834
838 // Default to lowest priority unless we know otherwise. 835 // Default to lowest priority unless we know otherwise.
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 associated_stream_id, stream_id); 1421 associated_stream_id, stream_id);
1425 ResetStream(stream_id, INVALID_STREAM, description); 1422 ResetStream(stream_id, INVALID_STREAM, description);
1426 return; 1423 return;
1427 } 1424 }
1428 1425
1429 streams_pushed_count_++; 1426 streams_pushed_count_++;
1430 1427
1431 // TODO(mbelshe): DCHECK that this is a GET method? 1428 // TODO(mbelshe): DCHECK that this is a GET method?
1432 1429
1433 // Verify that the response had a URL for us. 1430 // Verify that the response had a URL for us.
1434 const std::string& url = ContainsKey(*headers, "url") ? 1431 GURL gurl = GetUrlFromHeaderBlock(*headers, GetProtocolVersion(), true);
1435 headers->find("url")->second : ""; 1432 if (!gurl.is_valid()) {
1436 if (url.empty()) {
1437 ResetStream(stream_id, PROTOCOL_ERROR, 1433 ResetStream(stream_id, PROTOCOL_ERROR,
1438 "Pushed stream did not contain a url."); 1434 "Pushed stream url was invalid: " + gurl.spec());
1439 return; 1435 return;
1440 } 1436 }
1441 1437 const std::string& url = gurl.spec();
1442 GURL gurl(url);
1443 if (!gurl.is_valid()) {
1444 ResetStream(stream_id, PROTOCOL_ERROR,
1445 "Pushed stream url was invalid: " + url);
1446 return;
1447 }
1448 1438
1449 // Verify we have a valid stream association. 1439 // Verify we have a valid stream association.
1450 if (!IsStreamActive(associated_stream_id)) { 1440 if (!IsStreamActive(associated_stream_id)) {
1451 ResetStream(stream_id, INVALID_ASSOCIATED_STREAM, 1441 ResetStream(stream_id, INVALID_ASSOCIATED_STREAM,
1452 base::StringPrintf( 1442 base::StringPrintf(
1453 "Received OnSyn with inactive associated stream %d", 1443 "Received OnSyn with inactive associated stream %d",
1454 associated_stream_id)); 1444 associated_stream_id));
1455 return; 1445 return;
1456 } 1446 }
1457 1447
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1965 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1976 if (!is_secure_) 1966 if (!is_secure_)
1977 return NULL; 1967 return NULL;
1978 SSLClientSocket* ssl_socket = 1968 SSLClientSocket* ssl_socket =
1979 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1969 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1980 DCHECK(ssl_socket); 1970 DCHECK(ssl_socket);
1981 return ssl_socket; 1971 return ssl_socket;
1982 } 1972 }
1983 1973
1984 } // namespace net 1974 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_spdy3_unittest.cc ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698