| 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 "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "net/base/parse_number.h" |
| 11 #include "net/quic/core/quic_bug_tracker.h" | 12 #include "net/quic/core/quic_bug_tracker.h" |
| 12 #include "net/quic/core/quic_spdy_session.h" | 13 #include "net/quic/core/quic_spdy_session.h" |
| 13 #include "net/quic/core/quic_utils.h" | 14 #include "net/quic/core/quic_utils.h" |
| 14 #include "net/quic/core/quic_write_blocked_list.h" | 15 #include "net/quic/core/quic_write_blocked_list.h" |
| 15 #include "net/quic/core/spdy_utils.h" | 16 #include "net/quic/core/spdy_utils.h" |
| 16 | 17 |
| 17 using base::IntToString; | 18 using base::IntToString; |
| 18 using base::StringPiece; | 19 using base::StringPiece; |
| 19 using std::string; | 20 using std::string; |
| 20 | 21 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 StringPiece 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 |
| 294 if (status[0] < '1' || status[0] > '5') { | 295 unsigned int result; |
| 296 if (!ParseUint32(status, &result, nullptr)) { |
| 295 return false; | 297 return false; |
| 296 } | 298 } |
| 297 // The remaining two characters must be integers. | 299 |
| 298 if (!isdigit(status[1]) || !isdigit(status[2])) { | 300 // Valid status codes are only in the range [100, 599]. |
| 301 if (result < 100 || result >= 600) { |
| 299 return false; | 302 return false; |
| 300 } | 303 } |
| 301 return StringToInt(status, status_code); | 304 |
| 305 *status_code = static_cast<int>(result); |
| 306 return true; |
| 302 } | 307 } |
| 303 | 308 |
| 304 bool QuicSpdyStream::FinishedReadingTrailers() const { | 309 bool QuicSpdyStream::FinishedReadingTrailers() const { |
| 305 // If no further trailing headers are expected, and the decompressed trailers | 310 // If no further trailing headers are expected, and the decompressed trailers |
| 306 // (if any) have been consumed, then reading of trailers is finished. | 311 // (if any) have been consumed, then reading of trailers is finished. |
| 307 if (!fin_received()) { | 312 if (!fin_received()) { |
| 308 return false; | 313 return false; |
| 309 } else if (!trailers_decompressed_) { | 314 } else if (!trailers_decompressed_) { |
| 310 return true; | 315 return true; |
| 311 } else { | 316 } else { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 328 QuicAckListenerInterface* ack_notifier_delegate) { | 333 QuicAckListenerInterface* ack_notifier_delegate) { |
| 329 if (spdy_session_->headers_stream() != nullptr && | 334 if (spdy_session_->headers_stream() != nullptr && |
| 330 spdy_session_->force_hol_blocking()) { | 335 spdy_session_->force_hol_blocking()) { |
| 331 return spdy_session_->headers_stream()->WritevStreamData( | 336 return spdy_session_->headers_stream()->WritevStreamData( |
| 332 id(), iov, offset, fin, ack_notifier_delegate); | 337 id(), iov, offset, fin, ack_notifier_delegate); |
| 333 } | 338 } |
| 334 return QuicStream::WritevDataInner(iov, offset, fin, ack_notifier_delegate); | 339 return QuicStream::WritevDataInner(iov, offset, fin, ack_notifier_delegate); |
| 335 } | 340 } |
| 336 | 341 |
| 337 } // namespace net | 342 } // namespace net |
| OLD | NEW |