xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/tools/quic_simple_client_stream.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "quiche/quic/tools/quic_simple_client_stream.h"
6 
7 #include "quiche/common/platform/api/quiche_logging.h"
8 
9 namespace quic {
10 
OnBodyAvailable()11 void QuicSimpleClientStream::OnBodyAvailable() {
12   if (!drop_response_body_) {
13     QuicSpdyClientStream::OnBodyAvailable();
14     return;
15   }
16 
17   while (HasBytesToRead()) {
18     struct iovec iov;
19     if (GetReadableRegions(&iov, 1) == 0) {
20       break;
21     }
22     MarkConsumed(iov.iov_len);
23   }
24   if (sequencer()->IsClosed()) {
25     OnFinRead();
26   } else {
27     sequencer()->SetUnblocked();
28   }
29 }
30 
ParseAndValidateStatusCode()31 bool QuicSimpleClientStream::ParseAndValidateStatusCode() {
32   const size_t num_previous_interim_headers = preliminary_headers().size();
33   if (!QuicSpdyClientStream::ParseAndValidateStatusCode()) {
34     return false;
35   }
36   // The base ParseAndValidateStatusCode() may have added a preliminary header.
37   if (preliminary_headers().size() > num_previous_interim_headers) {
38     QUICHE_DCHECK_EQ(preliminary_headers().size(),
39                      num_previous_interim_headers + 1);
40     if (on_interim_headers_) {
41       on_interim_headers_(preliminary_headers().back());
42     }
43   }
44   return true;
45 }
46 
47 }  // namespace quic
48