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_SERVER_STREAM_H_
6 #define NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_
10 #include "base/basictypes.h"
11 #include "net/quic/quic_data_stream.h"
12 #include "net/quic/quic_protocol.h"
13 #include "net/spdy/spdy_framer.h"
17 class QuicSpdySession
;
22 class QuicSpdyServerStreamPeer
;
25 // All this does right now is aggregate data, and on fin, send an HTTP
27 class QuicSpdyServerStream
: public QuicDataStream
{
29 QuicSpdyServerStream(QuicStreamId id
, QuicSpdySession
* session
);
30 ~QuicSpdyServerStream() override
;
33 void OnStreamHeadersComplete(bool fin
, size_t frame_len
) override
;
35 // ReliableQuicStream implementation called by the sequencer when there is
36 // data (or a FIN) to be read.
37 void OnDataAvailable() override
;
40 // Sends a basic 200 response using SendHeaders for the headers and WriteData
42 virtual void SendResponse();
44 void SendHeadersAndBody(const SpdyHeaderBlock
& response_headers
,
45 base::StringPiece body
);
47 SpdyHeaderBlock
* request_headers() { return &request_headers_
; }
49 const std::string
& body() { return body_
; }
52 friend class test::QuicSpdyServerStreamPeer
;
54 // Parses the request headers from |data| to |request_headers_|.
55 // Returns false if there was an error parsing the headers.
56 bool ParseRequestHeaders(const char* data
, uint32 data_len
);
58 // Sends a basic 500 response using SendHeaders for the headers and WriteData
60 void SendErrorResponse();
62 // Returns the key for |request_headers_| which identifies the host.
63 const std::string
GetHostKey();
65 // The parsed headers received from the client.
66 SpdyHeaderBlock request_headers_
;
70 DISALLOW_COPY_AND_ASSIGN(QuicSpdyServerStream
);
76 #endif // NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_