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