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

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 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->GetNegotiatedProtocol(); 429 protocol = protocol_negotiated;
430 if (protocol_negotiated != kProtoUnknown) { 430 }
431 protocol = protocol_negotiated;
432 }
433 431
434 if (ssl_socket->WasDomainBoundCertSent()) { 432
ramant (doing other things) 2012/03/30 22:19:58 nit: extra line.
Ryan Hamilton 2012/03/30 22:46:02 Done.
435 // According to the SPDY spec, the credential associated with the TLS 433 SSLClientSocket* ssl_socket = GetSSLClientSocket();
436 // connection is stored in slot[1]. 434 if (ssl_socket && ssl_socket->WasDomainBoundCertSent()) {
437 credential_state_.SetHasCredential(GURL("https://" + 435 // According to the SPDY spec, the credential associated with the TLS
438 host_port_pair().ToString())); 436 // connection is stored in slot[1].
439 } 437 credential_state_.SetHasCredential(GURL("https://" +
438 host_port_pair().ToString()));
440 } 439 }
441 440
442 DCHECK(protocol >= kProtoSPDY2); 441 DCHECK(protocol >= kProtoSPDY2);
443 DCHECK(protocol <= kProtoSPDY3); 442 DCHECK(protocol <= kProtoSPDY3);
444 int version = (protocol == kProtoSPDY3) ? 3 : 2; 443 int version = (protocol == kProtoSPDY3) ? 3 : 2;
445 flow_control_ = (protocol >= kProtoSPDY21); 444 flow_control_ = (protocol >= kProtoSPDY21);
446 445
447 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version)); 446 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version));
448 buffered_spdy_framer_->set_visitor(this); 447 buffered_spdy_framer_->set_visitor(this);
449 SendSettings(); 448 SendSettings();
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 void SpdySession::CloseStream(SpdyStreamId stream_id, int status) { 805 void SpdySession::CloseStream(SpdyStreamId stream_id, int status) {
807 // TODO(mbelshe): We should send a RST_STREAM control frame here 806 // TODO(mbelshe): We should send a RST_STREAM control frame here
808 // so that the server can cancel a large send. 807 // so that the server can cancel a large send.
809 808
810 DeleteStream(stream_id, status); 809 DeleteStream(stream_id, status);
811 } 810 }
812 811
813 void SpdySession::ResetStream(SpdyStreamId stream_id, 812 void SpdySession::ResetStream(SpdyStreamId stream_id,
814 SpdyStatusCodes status, 813 SpdyStatusCodes status,
815 const std::string& description) { 814 const std::string& description) {
816
817 net_log().AddEvent( 815 net_log().AddEvent(
818 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM, 816 NetLog::TYPE_SPDY_SESSION_SEND_RST_STREAM,
819 make_scoped_refptr(new NetLogSpdyRstParameter(stream_id, status, 817 make_scoped_refptr(new NetLogSpdyRstParameter(stream_id, status,
820 description))); 818 description)));
821 819
822 DCHECK(buffered_spdy_framer_.get()); 820 DCHECK(buffered_spdy_framer_.get());
823 scoped_ptr<SpdyRstStreamControlFrame> rst_frame( 821 scoped_ptr<SpdyRstStreamControlFrame> rst_frame(
824 buffered_spdy_framer_->CreateRstStream(stream_id, status)); 822 buffered_spdy_framer_->CreateRstStream(stream_id, status));
825 823
826 // 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
1400 associated_stream_id, stream_id); 1398 associated_stream_id, stream_id);
1401 ResetStream(stream_id, INVALID_STREAM, description); 1399 ResetStream(stream_id, INVALID_STREAM, description);
1402 return; 1400 return;
1403 } 1401 }
1404 1402
1405 streams_pushed_count_++; 1403 streams_pushed_count_++;
1406 1404
1407 // TODO(mbelshe): DCHECK that this is a GET method? 1405 // TODO(mbelshe): DCHECK that this is a GET method?
1408 1406
1409 // Verify that the response had a URL for us. 1407 // Verify that the response had a URL for us.
1410 const std::string& url = ContainsKey(*headers, "url") ? 1408 GURL gurl = GetUrlFromHeaderBlock(*headers, GetProtocolVersion(), true);
1411 headers->find("url")->second : ""; 1409 if (!gurl.is_valid()) {
1412 if (url.empty()) {
1413 ResetStream(stream_id, PROTOCOL_ERROR, 1410 ResetStream(stream_id, PROTOCOL_ERROR,
1414 "Pushed stream did not contain a url."); 1411 "Pushed stream url was invalid: " + gurl.spec());
1415 return; 1412 return;
1416 } 1413 }
1417 1414 const std::string& url = gurl.spec();
1418 GURL gurl(url);
1419 if (!gurl.is_valid()) {
1420 ResetStream(stream_id, PROTOCOL_ERROR,
1421 "Pushed stream url was invalid: " + url);
1422 return;
1423 }
1424 1415
1425 // Verify we have a valid stream association. 1416 // Verify we have a valid stream association.
1426 if (!IsStreamActive(associated_stream_id)) { 1417 if (!IsStreamActive(associated_stream_id)) {
1427 ResetStream(stream_id, INVALID_ASSOCIATED_STREAM, 1418 ResetStream(stream_id, INVALID_ASSOCIATED_STREAM,
1428 base::StringPrintf( 1419 base::StringPrintf(
1429 "Received OnSyn with inactive associated stream %d", 1420 "Received OnSyn with inactive associated stream %d",
1430 associated_stream_id)); 1421 associated_stream_id));
1431 return; 1422 return;
1432 } 1423 }
1433 1424
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 SSLClientSocket* SpdySession::GetSSLClientSocket() const { 1937 SSLClientSocket* SpdySession::GetSSLClientSocket() const {
1947 if (!is_secure_) 1938 if (!is_secure_)
1948 return NULL; 1939 return NULL;
1949 SSLClientSocket* ssl_socket = 1940 SSLClientSocket* ssl_socket =
1950 reinterpret_cast<SSLClientSocket*>(connection_->socket()); 1941 reinterpret_cast<SSLClientSocket*>(connection_->socket());
1951 DCHECK(ssl_socket); 1942 DCHECK(ssl_socket);
1952 return ssl_socket; 1943 return ssl_socket;
1953 } 1944 }
1954 1945
1955 } // namespace net 1946 } // 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