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/quic_spdy_stream.h" | 5 #include "net/quic/quic_spdy_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "net/quic/quic_bug_tracker.h" | 9 #include "net/quic/quic_bug_tracker.h" |
10 #include "net/quic/quic_spdy_session.h" | 10 #include "net/quic/quic_spdy_session.h" |
11 #include "net/quic/quic_utils.h" | 11 #include "net/quic/quic_utils.h" |
12 #include "net/quic/quic_write_blocked_list.h" | 12 #include "net/quic/quic_write_blocked_list.h" |
| 13 #include "net/quic/spdy_utils.h" |
13 | 14 |
14 using base::StringPiece; | 15 using base::StringPiece; |
15 using std::min; | 16 using std::min; |
16 using net::SpdyPriority; | 17 using net::SpdyPriority; |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 #define ENDPOINT \ | 21 #define ENDPOINT \ |
21 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ | 22 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ |
22 " ") | 23 " ") |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 QUIC_INVALID_HEADERS_STREAM_DATA, "Trailers after fin"); | 207 QUIC_INVALID_HEADERS_STREAM_DATA, "Trailers after fin"); |
207 return; | 208 return; |
208 } | 209 } |
209 if (!fin) { | 210 if (!fin) { |
210 DLOG(ERROR) << "Trailers must have FIN set, on stream: " << id(); | 211 DLOG(ERROR) << "Trailers must have FIN set, on stream: " << id(); |
211 session()->connection()->SendConnectionCloseWithDetails( | 212 session()->connection()->SendConnectionCloseWithDetails( |
212 QUIC_INVALID_HEADERS_STREAM_DATA, "Fin missing from trailers"); | 213 QUIC_INVALID_HEADERS_STREAM_DATA, "Fin missing from trailers"); |
213 return; | 214 return; |
214 } | 215 } |
215 | 216 |
216 OnStreamFrame(QuicStreamFrame(id(), fin, stream_bytes_read(), StringPiece())); | 217 size_t final_byte_offset = 0; |
| 218 SpdyHeaderBlock trailers; |
| 219 if (!SpdyUtils::ParseTrailers(decompressed_trailers().data(), |
| 220 decompressed_trailers().length(), |
| 221 &final_byte_offset, &response_trailers_)) { |
| 222 DLOG(ERROR) << "Trailers are malformed: " << id(); |
| 223 session()->connection()->SendConnectionCloseWithDetails( |
| 224 QUIC_INVALID_HEADERS_STREAM_DATA, "Trailers are malformed"); |
| 225 return; |
| 226 } |
| 227 |
| 228 // The data on this stream ends at |final_byte_offset|. |
| 229 DVLOG(1) << "Stream ends at byte offset: " << final_byte_offset |
| 230 << " currently read: " << stream_bytes_read(); |
| 231 |
| 232 OnStreamFrame(QuicStreamFrame(id(), fin, final_byte_offset, StringPiece())); |
217 trailers_decompressed_ = true; | 233 trailers_decompressed_ = true; |
218 } | 234 } |
219 | 235 |
220 void QuicSpdyStream::OnStreamReset(const QuicRstStreamFrame& frame) { | 236 void QuicSpdyStream::OnStreamReset(const QuicRstStreamFrame& frame) { |
221 if (frame.error_code != QUIC_STREAM_NO_ERROR || | 237 if (frame.error_code != QUIC_STREAM_NO_ERROR || |
222 version() <= QUIC_VERSION_28) { | 238 version() <= QUIC_VERSION_28) { |
223 ReliableQuicStream::OnStreamReset(frame); | 239 ReliableQuicStream::OnStreamReset(frame); |
224 return; | 240 return; |
225 } | 241 } |
226 DVLOG(1) << "Received QUIC_STREAM_NO_ERROR, not discarding response"; | 242 DVLOG(1) << "Received QUIC_STREAM_NO_ERROR, not discarding response"; |
(...skipping 23 matching lines...) Expand all Loading... |
250 // If no further trailing headers are expected, and the decompressed trailers | 266 // If no further trailing headers are expected, and the decompressed trailers |
251 // (if any) have been consumed, then reading of trailers is finished. | 267 // (if any) have been consumed, then reading of trailers is finished. |
252 bool no_more_trailers = fin_received() || trailers_decompressed_; | 268 bool no_more_trailers = fin_received() || trailers_decompressed_; |
253 return no_more_trailers && decompressed_trailers_.empty(); | 269 return no_more_trailers && decompressed_trailers_.empty(); |
254 } | 270 } |
255 | 271 |
256 SpdyPriority QuicSpdyStream::priority() const { | 272 SpdyPriority QuicSpdyStream::priority() const { |
257 return priority_; | 273 return priority_; |
258 } | 274 } |
259 } // namespace net | 275 } // namespace net |
OLD | NEW |