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_spdy_stream.h" | 5 #include "net/quic/core/quic_spdy_stream.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "net/quic/core/quic_spdy_session.h" | 9 #include "net/quic/core/quic_spdy_session.h" |
10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
11 #include "net/quic/core/quic_write_blocked_list.h" | 11 #include "net/quic/core/quic_write_blocked_list.h" |
12 #include "net/quic/core/spdy_utils.h" | 12 #include "net/quic/core/spdy_utils.h" |
13 #include "net/quic/platform/api/quic_bug_tracker.h" | 13 #include "net/quic/platform/api/quic_bug_tracker.h" |
14 #include "net/quic/platform/api/quic_logging.h" | 14 #include "net/quic/platform/api/quic_logging.h" |
| 15 #include "net/quic/platform/api/quic_string_piece.h" |
15 #include "net/quic/platform/api/quic_text_utils.h" | 16 #include "net/quic/platform/api/quic_text_utils.h" |
16 | 17 |
17 using base::IntToString; | 18 using base::IntToString; |
18 using base::StringPiece; | |
19 using std::string; | 19 using std::string; |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 #define ENDPOINT \ | 22 #define ENDPOINT \ |
23 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ | 23 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ |
24 " ") | 24 " ") |
25 | 25 |
26 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) | 26 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) |
27 : QuicStream(id, spdy_session), | 27 : QuicStream(id, spdy_session), |
28 spdy_session_(spdy_session), | 28 spdy_session_(spdy_session), |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 Reset(QUIC_HEADERS_TOO_LARGE); | 184 Reset(QUIC_HEADERS_TOO_LARGE); |
185 } | 185 } |
186 | 186 |
187 void QuicSpdyStream::OnInitialHeadersComplete( | 187 void QuicSpdyStream::OnInitialHeadersComplete( |
188 bool fin, | 188 bool fin, |
189 size_t /*frame_len*/, | 189 size_t /*frame_len*/, |
190 const QuicHeaderList& header_list) { | 190 const QuicHeaderList& header_list) { |
191 headers_decompressed_ = true; | 191 headers_decompressed_ = true; |
192 header_list_ = header_list; | 192 header_list_ = header_list; |
193 if (fin) { | 193 if (fin) { |
194 OnStreamFrame(QuicStreamFrame(id(), fin, 0, StringPiece())); | 194 OnStreamFrame(QuicStreamFrame(id(), fin, 0, QuicStringPiece())); |
195 } | 195 } |
196 if (FinishedReadingHeaders()) { | 196 if (FinishedReadingHeaders()) { |
197 sequencer()->SetUnblocked(); | 197 sequencer()->SetUnblocked(); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 void QuicSpdyStream::OnPromiseHeaderList( | 201 void QuicSpdyStream::OnPromiseHeaderList( |
202 QuicStreamId /* promised_id */, | 202 QuicStreamId /* promised_id */, |
203 size_t /* frame_len */, | 203 size_t /* frame_len */, |
204 const QuicHeaderList& /*header_list */) { | 204 const QuicHeaderList& /*header_list */) { |
(...skipping 28 matching lines...) Expand all Loading... |
233 size_t final_byte_offset = 0; | 233 size_t final_byte_offset = 0; |
234 if (!SpdyUtils::CopyAndValidateTrailers(header_list, &final_byte_offset, | 234 if (!SpdyUtils::CopyAndValidateTrailers(header_list, &final_byte_offset, |
235 &received_trailers_)) { | 235 &received_trailers_)) { |
236 QUIC_DLOG(ERROR) << "Trailers are malformed: " << id(); | 236 QUIC_DLOG(ERROR) << "Trailers are malformed: " << id(); |
237 session()->connection()->CloseConnection( | 237 session()->connection()->CloseConnection( |
238 QUIC_INVALID_HEADERS_STREAM_DATA, "Trailers are malformed", | 238 QUIC_INVALID_HEADERS_STREAM_DATA, "Trailers are malformed", |
239 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 239 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
240 return; | 240 return; |
241 } | 241 } |
242 trailers_decompressed_ = true; | 242 trailers_decompressed_ = true; |
243 OnStreamFrame(QuicStreamFrame(id(), fin, final_byte_offset, StringPiece())); | 243 OnStreamFrame( |
| 244 QuicStreamFrame(id(), fin, final_byte_offset, QuicStringPiece())); |
244 } | 245 } |
245 | 246 |
246 void QuicSpdyStream::OnStreamReset(const QuicRstStreamFrame& frame) { | 247 void QuicSpdyStream::OnStreamReset(const QuicRstStreamFrame& frame) { |
247 if (frame.error_code != QUIC_STREAM_NO_ERROR) { | 248 if (frame.error_code != QUIC_STREAM_NO_ERROR) { |
248 QuicStream::OnStreamReset(frame); | 249 QuicStream::OnStreamReset(frame); |
249 return; | 250 return; |
250 } | 251 } |
251 QUIC_DVLOG(1) << "Received QUIC_STREAM_NO_ERROR, not discarding response"; | 252 QUIC_DVLOG(1) << "Received QUIC_STREAM_NO_ERROR, not discarding response"; |
252 set_rst_received(true); | 253 set_rst_received(true); |
253 MaybeIncreaseHighestReceivedOffset(frame.byte_offset); | 254 MaybeIncreaseHighestReceivedOffset(frame.byte_offset); |
(...skipping 25 matching lines...) Expand all Loading... |
279 bool QuicSpdyStream::FinishedReadingHeaders() const { | 280 bool QuicSpdyStream::FinishedReadingHeaders() const { |
280 return headers_decompressed_ && header_list_.empty(); | 281 return headers_decompressed_ && header_list_.empty(); |
281 } | 282 } |
282 | 283 |
283 bool QuicSpdyStream::ParseHeaderStatusCode(const SpdyHeaderBlock& header, | 284 bool QuicSpdyStream::ParseHeaderStatusCode(const SpdyHeaderBlock& header, |
284 int* status_code) const { | 285 int* status_code) const { |
285 SpdyHeaderBlock::const_iterator it = header.find(":status"); | 286 SpdyHeaderBlock::const_iterator it = header.find(":status"); |
286 if (it == header.end()) { | 287 if (it == header.end()) { |
287 return false; | 288 return false; |
288 } | 289 } |
289 const StringPiece status(it->second); | 290 const QuicStringPiece status(it->second); |
290 if (status.size() != 3) { | 291 if (status.size() != 3) { |
291 return false; | 292 return false; |
292 } | 293 } |
293 // First character must be an integer in range [1,5]. | 294 // First character must be an integer in range [1,5]. |
294 if (status[0] < '1' || status[0] > '5') { | 295 if (status[0] < '1' || status[0] > '5') { |
295 return false; | 296 return false; |
296 } | 297 } |
297 // The remaining two characters must be integers. | 298 // The remaining two characters must be integers. |
298 if (!isdigit(status[1]) || !isdigit(status[2])) { | 299 if (!isdigit(status[1]) || !isdigit(status[2])) { |
299 return false; | 300 return false; |
(...skipping 28 matching lines...) Expand all Loading... |
328 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { | 329 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { |
329 if (spdy_session_->headers_stream() != nullptr && | 330 if (spdy_session_->headers_stream() != nullptr && |
330 spdy_session_->force_hol_blocking()) { | 331 spdy_session_->force_hol_blocking()) { |
331 return spdy_session_->WritevStreamData(id(), iov, offset, fin, | 332 return spdy_session_->WritevStreamData(id(), iov, offset, fin, |
332 std::move(ack_listener)); | 333 std::move(ack_listener)); |
333 } | 334 } |
334 return QuicStream::WritevDataInner(iov, offset, fin, std::move(ack_listener)); | 335 return QuicStream::WritevDataInner(iov, offset, fin, std::move(ack_listener)); |
335 } | 336 } |
336 | 337 |
337 } // namespace net | 338 } // namespace net |
OLD | NEW |