| OLD | NEW |
| 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/quic/core/quic_headers_stream.h" | 5 #include "net/quic/core/quic_headers_stream.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "net/quic/core/quic_bug_tracker.h" | 13 #include "net/quic/core/quic_bug_tracker.h" |
| 14 #include "net/quic/core/quic_flags.h" | 14 #include "net/quic/core/quic_flags.h" |
| 15 #include "net/quic/core/quic_header_list.h" | 15 #include "net/quic/core/quic_header_list.h" |
| 16 #include "net/quic/core/quic_server_session_base.h" |
| 16 #include "net/quic/core/quic_spdy_session.h" | 17 #include "net/quic/core/quic_spdy_session.h" |
| 17 #include "net/quic/core/quic_time.h" | 18 #include "net/quic/core/quic_time.h" |
| 18 #include "net/spdy/spdy_protocol.h" | 19 #include "net/spdy/spdy_protocol.h" |
| 19 | 20 |
| 20 using base::StringPiece; | 21 using base::StringPiece; |
| 21 using net::HTTP2; | 22 using net::HTTP2; |
| 22 using net::SpdyFrameType; | 23 using net::SpdyFrameType; |
| 23 using std::string; | 24 using std::string; |
| 24 | 25 |
| 25 namespace net { | 26 namespace net { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 190 |
| 190 void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override { | 191 void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override { |
| 191 if (!FLAGS_quic_respect_http2_settings_frame) { | 192 if (!FLAGS_quic_respect_http2_settings_frame) { |
| 192 CloseConnection("SPDY SETTINGS frame received."); | 193 CloseConnection("SPDY SETTINGS frame received."); |
| 193 return; | 194 return; |
| 194 } | 195 } |
| 195 switch (id) { | 196 switch (id) { |
| 196 case SETTINGS_HEADER_TABLE_SIZE: | 197 case SETTINGS_HEADER_TABLE_SIZE: |
| 197 stream_->UpdateHeaderEncoderTableSize(value); | 198 stream_->UpdateHeaderEncoderTableSize(value); |
| 198 break; | 199 break; |
| 200 case SETTINGS_ENABLE_PUSH: |
| 201 if (FLAGS_quic_enable_server_push_by_default && |
| 202 stream_->session()->perspective() == Perspective::IS_SERVER) { |
| 203 // See rfc7540, Section 6.5.2. |
| 204 if (value > 1) { |
| 205 CloseConnection("Invalid value for SETTINGS_ENABLE_PUSH: " + |
| 206 base::IntToString(value)); |
| 207 return; |
| 208 } |
| 209 stream_->UpdateEnableServerPush(value > 0); |
| 210 break; |
| 211 } else { |
| 212 CloseConnection("Unsupported field of HTTP/2 SETTINGS frame: " + |
| 213 base::IntToString(id)); |
| 214 } |
| 215 break; |
| 199 // TODO(fayang): Need to support SETTINGS_MAX_HEADER_LIST_SIZE when | 216 // TODO(fayang): Need to support SETTINGS_MAX_HEADER_LIST_SIZE when |
| 200 // clients are actually sending it. | 217 // clients are actually sending it. |
| 201 default: | 218 default: |
| 202 CloseConnection("Unsupported field of HTTP/2 SETTINGS frame: " + | 219 CloseConnection("Unsupported field of HTTP/2 SETTINGS frame: " + |
| 203 base::IntToString(id)); | 220 base::IntToString(id)); |
| 204 } | 221 } |
| 205 } | 222 } |
| 206 | 223 |
| 207 void OnSettingsAck() override { | 224 void OnSettingsAck() override { |
| 208 if (!FLAGS_quic_respect_http2_settings_frame) { | 225 if (!FLAGS_quic_respect_http2_settings_frame) { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 std::unique_ptr<HpackDebugVisitor> visitor) { | 603 std::unique_ptr<HpackDebugVisitor> visitor) { |
| 587 spdy_framer_.SetDecoderHeaderTableDebugVisitor( | 604 spdy_framer_.SetDecoderHeaderTableDebugVisitor( |
| 588 std::unique_ptr<HeaderTableDebugVisitor>(new HeaderTableDebugVisitor( | 605 std::unique_ptr<HeaderTableDebugVisitor>(new HeaderTableDebugVisitor( |
| 589 session()->connection()->helper()->GetClock(), std::move(visitor)))); | 606 session()->connection()->helper()->GetClock(), std::move(visitor)))); |
| 590 } | 607 } |
| 591 | 608 |
| 592 void QuicHeadersStream::UpdateHeaderEncoderTableSize(uint32_t value) { | 609 void QuicHeadersStream::UpdateHeaderEncoderTableSize(uint32_t value) { |
| 593 spdy_framer_.UpdateHeaderEncoderTableSize(value); | 610 spdy_framer_.UpdateHeaderEncoderTableSize(value); |
| 594 } | 611 } |
| 595 | 612 |
| 613 void QuicHeadersStream::UpdateEnableServerPush(bool value) { |
| 614 spdy_session_->set_server_push_enabled(value); |
| 615 } |
| 616 |
| 596 bool QuicHeadersStream::OnDataFrameHeader(QuicStreamId stream_id, | 617 bool QuicHeadersStream::OnDataFrameHeader(QuicStreamId stream_id, |
| 597 size_t length, | 618 size_t length, |
| 598 bool fin) { | 619 bool fin) { |
| 599 if (!spdy_session_->force_hol_blocking()) { | 620 if (!spdy_session_->force_hol_blocking()) { |
| 600 return false; | 621 return false; |
| 601 } | 622 } |
| 602 if (!IsConnected()) { | 623 if (!IsConnected()) { |
| 603 return true; | 624 return true; |
| 604 } | 625 } |
| 605 DVLOG(1) << "DATA frame header for stream " << stream_id << " length " | 626 DVLOG(1) << "DATA frame header for stream " << stream_id << " length " |
| (...skipping 16 matching lines...) Expand all Loading... |
| 622 return true; | 643 return true; |
| 623 } | 644 } |
| 624 frame_len_ -= len; | 645 frame_len_ -= len; |
| 625 // Ignore fin_ while there is more data coming, if frame_len_ > 0. | 646 // Ignore fin_ while there is more data coming, if frame_len_ > 0. |
| 626 spdy_session_->OnStreamFrameData(stream_id, data, len, | 647 spdy_session_->OnStreamFrameData(stream_id, data, len, |
| 627 frame_len_ > 0 ? false : fin_); | 648 frame_len_ > 0 ? false : fin_); |
| 628 return true; | 649 return true; |
| 629 } | 650 } |
| 630 | 651 |
| 631 } // namespace net | 652 } // namespace net |
| OLD | NEW |