1 // 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.
5 #ifndef NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_
6 #define NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_
11 #include "base/basictypes.h"
12 #include "base/strings/string_piece.h"
13 #include "net/base/io_buffer.h"
14 #include "net/quic/quic_data_stream.h"
15 #include "net/quic/quic_protocol.h"
16 #include "net/tools/balsa/balsa_frame.h"
17 #include "net/tools/balsa/balsa_headers.h"
23 class QuicClientSession
;
25 // All this does right now is send an SPDY request, and aggregate the
27 class QuicSpdyClientStream
: public QuicDataStream
{
29 QuicSpdyClientStream(QuicStreamId id
, QuicClientSession
* session
);
30 virtual ~QuicSpdyClientStream();
32 // Override the base class to close the write side as soon as we get a
34 // SPDY/HTTP does not support bidirectional streaming.
35 virtual void OnStreamFrame(const QuicStreamFrame
& frame
) OVERRIDE
;
37 // Override the base class to store the size of the headers.
38 virtual void OnStreamHeadersComplete(bool fin
, size_t frame_len
) OVERRIDE
;
40 // ReliableQuicStream implementation called by the session when there's
42 virtual uint32
ProcessData(const char* data
, uint32 data_len
) OVERRIDE
;
44 virtual void OnFinRead() OVERRIDE
;
46 // Serializes the headers and body, sends it to the server, and
47 // returns the number of bytes sent.
48 ssize_t
SendRequest(const BalsaHeaders
& headers
,
49 base::StringPiece body
,
52 // Sends body data to the server, or buffers if it can't be sent immediately.
53 void SendBody(const std::string
& data
, bool fin
);
55 // Returns the response data.
56 const std::string
& data() { return data_
; }
58 // Returns whatever headers have been received for this stream.
59 const BalsaHeaders
& headers() { return headers_
; }
61 size_t header_bytes_read() const { return header_bytes_read_
; }
63 size_t header_bytes_written() const { return header_bytes_written_
; }
65 // While the server's set_priority shouldn't be called externally, the creator
66 // of client-side streams should be able to set the priority.
67 using QuicDataStream::set_priority
;
70 int ParseResponseHeaders();
72 BalsaHeaders headers_
;
75 scoped_refptr
<GrowableIOBuffer
> read_buf_
;
76 bool response_headers_received_
;
77 size_t header_bytes_read_
;
78 size_t header_bytes_written_
;
80 DISALLOW_COPY_AND_ASSIGN(QuicSpdyClientStream
);
86 #endif // NET_TOOLS_QUIC_QUIC_SPDY_CLIENT_STREAM_H_