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

Side by Side Diff: net/tools/quic/quic_spdy_client_stream.cc

Issue 1908103002: Landing Recent QUIC changes until 4/15/2016 17:20 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 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
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/tools/quic/quic_spdy_client_stream.h" 5 #include "net/tools/quic/quic_spdy_client_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "net/quic/quic_alarm.h" 10 #include "net/quic/quic_alarm.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 61 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
62 return; 62 return;
63 } 63 }
64 64
65 MarkHeadersConsumed(decompressed_headers().length()); 65 MarkHeadersConsumed(decompressed_headers().length());
66 DVLOG(1) << "headers complete for stream " << id(); 66 DVLOG(1) << "headers complete for stream " << id();
67 67
68 session_->OnInitialHeadersComplete(id(), response_headers_); 68 session_->OnInitialHeadersComplete(id(), response_headers_);
69 } 69 }
70 70
71 void QuicSpdyClientStream::OnInitialHeadersComplete(
72 bool fin,
73 size_t frame_len,
74 const QuicHeaderList& header_list) {
75 QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list);
76
77 DCHECK(headers_decompressed());
78 header_bytes_read_ += frame_len;
79 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_,
80 &response_headers_)) {
81 DLOG(ERROR) << "Failed to parse header list: " << header_list.DebugString();
82 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
83 return;
84 }
85
86 if (!ParseHeaderStatusCode(&response_headers_, &response_code_)) {
87 DLOG(ERROR) << "Received invalid response code: "
88 << response_headers_[":status"].as_string();
89 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
90 return;
91 }
92
93 ConsumeHeaderList();
94 DVLOG(1) << "headers complete for stream " << id();
95
96 session_->OnInitialHeadersComplete(id(), response_headers_);
97 }
98
71 void QuicSpdyClientStream::OnTrailingHeadersComplete(bool fin, 99 void QuicSpdyClientStream::OnTrailingHeadersComplete(bool fin,
72 size_t frame_len) { 100 size_t frame_len) {
73 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len); 101 QuicSpdyStream::OnTrailingHeadersComplete(fin, frame_len);
74 MarkTrailersConsumed(decompressed_trailers().length()); 102 MarkTrailersConsumed(decompressed_trailers().length());
75 } 103 }
76 104
77 void QuicSpdyClientStream::OnPromiseHeadersComplete(QuicStreamId promised_id, 105 void QuicSpdyClientStream::OnPromiseHeadersComplete(QuicStreamId promised_id,
78 size_t frame_len) { 106 size_t frame_len) {
79 header_bytes_read_ += frame_len; 107 header_bytes_read_ += frame_len;
80 int64_t content_length = -1; 108 int64_t content_length = -1;
81 SpdyHeaderBlock promise_headers; 109 SpdyHeaderBlock promise_headers;
82 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(), 110 if (!SpdyUtils::ParseHeaders(decompressed_headers().data(),
83 decompressed_headers().length(), &content_length, 111 decompressed_headers().length(), &content_length,
84 &promise_headers)) { 112 &promise_headers)) {
85 DLOG(ERROR) << "Failed to parse promise headers: " 113 DLOG(ERROR) << "Failed to parse promise headers: "
86 << decompressed_headers(); 114 << decompressed_headers();
87 Reset(QUIC_BAD_APPLICATION_PAYLOAD); 115 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
88 return; 116 return;
89 } 117 }
90 MarkHeadersConsumed(decompressed_headers().length()); 118 MarkHeadersConsumed(decompressed_headers().length());
91 119
92 session_->HandlePromised(id(), promised_id, promise_headers); 120 session_->HandlePromised(id(), promised_id, promise_headers);
121 if (visitor() != nullptr) {
122 visitor()->OnPromiseHeadersComplete(promised_id, frame_len);
123 }
124 }
125
126 void QuicSpdyClientStream::OnPromiseHeaderList(
127 QuicStreamId promised_id,
128 size_t frame_len,
129 const QuicHeaderList& header_list) {
130 header_bytes_read_ += frame_len;
131 int64_t content_length = -1;
132 SpdyHeaderBlock promise_headers;
133 if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length,
134 &promise_headers)) {
135 DLOG(ERROR) << "Failed to parse promise headers: "
136 << header_list.DebugString();
137 Reset(QUIC_BAD_APPLICATION_PAYLOAD);
138 return;
139 }
140
141 session_->HandlePromised(id(), promised_id, promise_headers);
93 } 142 }
94 143
95 void QuicSpdyClientStream::OnDataAvailable() { 144 void QuicSpdyClientStream::OnDataAvailable() {
96 if (FLAGS_quic_supports_push_promise) { 145 if (FLAGS_quic_supports_push_promise) {
97 // For push streams, visitor will not be set until the rendezvous 146 // For push streams, visitor will not be set until the rendezvous
98 // between server promise and client request is complete. 147 // between server promise and client request is complete.
99 if (visitor() == nullptr) 148 if (visitor() == nullptr)
100 return; 149 return;
101 } 150 }
102 151
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bytes_sent += header_bytes_written_; 184 bytes_sent += header_bytes_written_;
136 185
137 if (!body.empty()) { 186 if (!body.empty()) {
138 WriteOrBufferData(body, fin, nullptr); 187 WriteOrBufferData(body, fin, nullptr);
139 } 188 }
140 189
141 return bytes_sent; 190 return bytes_sent;
142 } 191 }
143 192
144 } // namespace net 193 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_spdy_client_stream.h ('k') | net/tools/quic/quic_spdy_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698