OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 void SplitPushedHeadersToRequestAndResponse(const SpdyHeaderBlock& headers, | 458 void SplitPushedHeadersToRequestAndResponse(const SpdyHeaderBlock& headers, |
459 SpdyMajorVersion protocol_version, | 459 SpdyMajorVersion protocol_version, |
460 SpdyHeaderBlock* request_headers, | 460 SpdyHeaderBlock* request_headers, |
461 SpdyHeaderBlock* response_headers) { | 461 SpdyHeaderBlock* response_headers) { |
462 DCHECK(response_headers); | 462 DCHECK(response_headers); |
463 DCHECK(request_headers); | 463 DCHECK(request_headers); |
464 for (SpdyHeaderBlock::const_iterator it = headers.begin(); | 464 for (SpdyHeaderBlock::const_iterator it = headers.begin(); |
465 it != headers.end(); | 465 it != headers.end(); |
466 ++it) { | 466 ++it) { |
467 SpdyHeaderBlock* to_insert = response_headers; | 467 SpdyHeaderBlock* to_insert = response_headers; |
468 if (protocol_version == SPDY2) { | 468 const char* host = protocol_version >= HTTP2 ? ":authority" : ":host"; |
469 if (it->first == "url") | 469 static const char scheme[] = ":scheme"; |
470 to_insert = request_headers; | 470 static const char path[] = ":path"; |
471 } else { | 471 if (it->first == host || it->first == scheme || it->first == path) { |
472 const char* host = protocol_version >= HTTP2 ? ":authority" : ":host"; | 472 to_insert = request_headers; |
473 static const char scheme[] = ":scheme"; | |
474 static const char path[] = ":path"; | |
475 if (it->first == host || it->first == scheme || it->first == path) | |
476 to_insert = request_headers; | |
477 } | 473 } |
478 to_insert->insert(*it); | 474 to_insert->insert(*it); |
479 } | 475 } |
480 } | 476 } |
481 | 477 |
482 SpdyStreamRequest::SpdyStreamRequest() : weak_ptr_factory_(this) { | 478 SpdyStreamRequest::SpdyStreamRequest() : weak_ptr_factory_(this) { |
483 Reset(); | 479 Reset(); |
484 } | 480 } |
485 | 481 |
486 SpdyStreamRequest::~SpdyStreamRequest() { | 482 SpdyStreamRequest::~SpdyStreamRequest() { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); | 756 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); |
761 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); | 757 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); |
762 | 758 |
763 if (protocol_ == kProtoHTTP2) | 759 if (protocol_ == kProtoHTTP2) |
764 send_connection_header_prefix_ = true; | 760 send_connection_header_prefix_ = true; |
765 | 761 |
766 if (protocol_ >= kProtoSPDY31) { | 762 if (protocol_ >= kProtoSPDY31) { |
767 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; | 763 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; |
768 session_send_window_size_ = GetDefaultInitialWindowSize(protocol_); | 764 session_send_window_size_ = GetDefaultInitialWindowSize(protocol_); |
769 session_recv_window_size_ = GetDefaultInitialWindowSize(protocol_); | 765 session_recv_window_size_ = GetDefaultInitialWindowSize(protocol_); |
770 } else if (protocol_ >= kProtoSPDY3) { | 766 } else { |
771 flow_control_state_ = FLOW_CONTROL_STREAM; | 767 flow_control_state_ = FLOW_CONTROL_STREAM; |
772 } else { | |
773 flow_control_state_ = FLOW_CONTROL_NONE; | |
774 } | 768 } |
775 | 769 |
776 buffered_spdy_framer_.reset( | 770 buffered_spdy_framer_.reset( |
777 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), | 771 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), |
778 enable_compression_)); | 772 enable_compression_)); |
779 buffered_spdy_framer_->set_visitor(this); | 773 buffered_spdy_framer_->set_visitor(this); |
780 buffered_spdy_framer_->set_debug_visitor(this); | 774 buffered_spdy_framer_->set_debug_visitor(this); |
781 UMA_HISTOGRAM_ENUMERATION( | 775 UMA_HISTOGRAM_ENUMERATION( |
782 "Net.SpdyVersion2", | 776 "Net.SpdyVersion2", |
783 protocol_ - kProtoSPDYHistogramOffset, | 777 protocol_ - kProtoSPDYHistogramOffset, |
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2633 } | 2627 } |
2634 } | 2628 } |
2635 | 2629 |
2636 bool SpdySession::TryCreatePushStream(SpdyStreamId stream_id, | 2630 bool SpdySession::TryCreatePushStream(SpdyStreamId stream_id, |
2637 SpdyStreamId associated_stream_id, | 2631 SpdyStreamId associated_stream_id, |
2638 SpdyPriority priority, | 2632 SpdyPriority priority, |
2639 const SpdyHeaderBlock& headers) { | 2633 const SpdyHeaderBlock& headers) { |
2640 // Server-initiated streams should have even sequence numbers. | 2634 // Server-initiated streams should have even sequence numbers. |
2641 if ((stream_id & 0x1) != 0) { | 2635 if ((stream_id & 0x1) != 0) { |
2642 LOG(WARNING) << "Received invalid push stream id " << stream_id; | 2636 LOG(WARNING) << "Received invalid push stream id " << stream_id; |
2643 if (GetProtocolVersion() > SPDY2) | 2637 CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Odd push stream id."); |
2644 CloseSessionOnError(ERR_SPDY_PROTOCOL_ERROR, "Odd push stream id."); | |
2645 return false; | 2638 return false; |
2646 } | 2639 } |
2647 | 2640 |
2648 if (GetProtocolVersion() > SPDY2) { | 2641 if (stream_id <= last_accepted_push_stream_id_) { |
2649 if (stream_id <= last_accepted_push_stream_id_) { | 2642 LOG(WARNING) << "Received push stream id lesser or equal to the last " |
2650 LOG(WARNING) << "Received push stream id lesser or equal to the last " | 2643 << "accepted before " << stream_id; |
2651 << "accepted before " << stream_id; | 2644 CloseSessionOnError( |
2652 CloseSessionOnError( | 2645 ERR_SPDY_PROTOCOL_ERROR, |
2653 ERR_SPDY_PROTOCOL_ERROR, | 2646 "New push stream id must be greater than the last accepted."); |
2654 "New push stream id must be greater than the last accepted."); | 2647 return false; |
2655 return false; | |
2656 } | |
2657 } | 2648 } |
2658 | 2649 |
2659 if (IsStreamActive(stream_id)) { | 2650 if (IsStreamActive(stream_id)) { |
2660 // For SPDY3 and higher we should not get here, we'll start going away | 2651 // For SPDY3 and higher we should not get here, we'll start going away |
2661 // earlier on |last_seen_push_stream_id_| check. | 2652 // earlier on |last_seen_push_stream_id_| check. |
2662 CHECK_GT(SPDY3, GetProtocolVersion()); | 2653 CHECK_GT(SPDY3, GetProtocolVersion()); |
2663 LOG(WARNING) << "Received push for active stream " << stream_id; | 2654 LOG(WARNING) << "Received push for active stream " << stream_id; |
2664 return false; | 2655 return false; |
2665 } | 2656 } |
2666 | 2657 |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3330 if (!queue->empty()) { | 3321 if (!queue->empty()) { |
3331 SpdyStreamId stream_id = queue->front(); | 3322 SpdyStreamId stream_id = queue->front(); |
3332 queue->pop_front(); | 3323 queue->pop_front(); |
3333 return stream_id; | 3324 return stream_id; |
3334 } | 3325 } |
3335 } | 3326 } |
3336 return 0; | 3327 return 0; |
3337 } | 3328 } |
3338 | 3329 |
3339 } // namespace net | 3330 } // namespace net |
OLD | NEW |