blob: 9c94b70093674650c11337cc8f672353c45dd745 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
3// found in the LICENSE file.
4
5#ifndef QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_CLIENT_STREAM_H_
6#define QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_CLIENT_STREAM_H_
7
8#include <cstddef>
vasilvv872e7a32019-03-12 16:42:44 -07009#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -050010
QUICHE teama6ef0a62019-03-07 20:34:33 -050011#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h"
12#include "net/third_party/quiche/src/quic/core/quic_packets.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050013#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
14#include "net/third_party/quiche/src/spdy/core/spdy_framer.h"
15
16namespace quic {
17
18class QuicSpdyClientSession;
19
20// All this does right now is send an SPDY request, and aggregate the
21// SPDY response.
22class QuicSpdyClientStream : public QuicSpdyStream {
23 public:
24 QuicSpdyClientStream(QuicStreamId id,
25 QuicSpdyClientSession* session,
26 StreamType type);
renjietangbaea59c2019-05-29 15:08:14 -070027 QuicSpdyClientStream(PendingStream* pending,
QUICHE teama6ef0a62019-03-07 20:34:33 -050028 QuicSpdyClientSession* spdy_session,
29 StreamType type);
30 QuicSpdyClientStream(const QuicSpdyClientStream&) = delete;
31 QuicSpdyClientStream& operator=(const QuicSpdyClientStream&) = delete;
32 ~QuicSpdyClientStream() override;
33
34 // Override the base class to parse and store headers.
35 void OnInitialHeadersComplete(bool fin,
36 size_t frame_len,
37 const QuicHeaderList& header_list) override;
38
39 // Override the base class to parse and store trailers.
40 void OnTrailingHeadersComplete(bool fin,
41 size_t frame_len,
42 const QuicHeaderList& header_list) override;
43
44 // Override the base class to handle creation of the push stream.
45 void OnPromiseHeaderList(QuicStreamId promised_id,
46 size_t frame_len,
47 const QuicHeaderList& header_list) override;
48
49 // QuicStream implementation called by the session when there's data for us.
50 void OnBodyAvailable() override;
51
52 // Serializes the headers and body, sends it to the server, and
53 // returns the number of bytes sent.
54 size_t SendRequest(spdy::SpdyHeaderBlock headers,
55 QuicStringPiece body,
56 bool fin);
57
58 // Returns the response data.
vasilvvc48c8712019-03-11 13:38:16 -070059 const std::string& data() { return data_; }
QUICHE teama6ef0a62019-03-07 20:34:33 -050060
61 // Returns whatever headers have been received for this stream.
62 const spdy::SpdyHeaderBlock& response_headers() { return response_headers_; }
63
64 const spdy::SpdyHeaderBlock& preliminary_headers() {
65 return preliminary_headers_;
66 }
67
68 size_t header_bytes_read() const { return header_bytes_read_; }
69
70 size_t header_bytes_written() const { return header_bytes_written_; }
71
72 int response_code() const { return response_code_; }
73
74 // While the server's SetPriority shouldn't be called externally, the creator
75 // of client-side streams should be able to set the priority.
76 using QuicSpdyStream::SetPriority;
77
78 private:
79 // The parsed headers received from the server.
80 spdy::SpdyHeaderBlock response_headers_;
81
82 // The parsed content-length, or -1 if none is specified.
83 int64_t content_length_;
84 int response_code_;
vasilvvc48c8712019-03-11 13:38:16 -070085 std::string data_;
QUICHE teama6ef0a62019-03-07 20:34:33 -050086 size_t header_bytes_read_;
87 size_t header_bytes_written_;
88
89 QuicSpdyClientSession* session_;
90
91 // These preliminary headers are used for the 100 Continue headers
92 // that may arrive before the response headers when the request has
93 // Expect: 100-continue.
94 bool has_preliminary_headers_;
95 spdy::SpdyHeaderBlock preliminary_headers_;
96};
97
98} // namespace quic
99
100#endif // QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_CLIENT_STREAM_H_