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_RELIABLE_SERVER_STREAM_H_
6 #define NET_TOOLS_QUIC_QUIC_RELIABLE_SERVER_STREAM_H_
10 #include "net/quic/quic_protocol.h"
11 #include "net/quic/reliable_quic_stream.h"
12 #include "net/tools/flip_server/balsa_headers.h"
21 class QuicReliableServerStreamPeer
;
24 // A base class for spdy/http server streams which handles the concept
25 // of sending and receiving headers and bodies.
26 class QuicReliableServerStream
: public ReliableQuicStream
{
28 QuicReliableServerStream(QuicStreamId id
, QuicSession
* session
);
29 virtual ~QuicReliableServerStream() {}
31 // Subclasses should process and frame data when this is called, returning
32 // how many bytes are processed.
33 virtual uint32
ProcessData(const char* data
, uint32 data_len
) = 0;
34 // Subclasses should implement this to serialize headers in a
35 // protocol-specific manner, and send it out to the client.
36 virtual void SendHeaders(const BalsaHeaders
& response_headers
) = 0;
38 // Sends a basic 200 response using SendHeaders for the headers and WriteData
41 // Sends a basic 500 response using SendHeaders for the headers and WriteData
43 void SendErrorResponse();
44 // Make sure that as soon as we start writing data, we stop reading.
45 virtual QuicConsumedData
WriteData(base::StringPiece data
, bool fin
) OVERRIDE
;
47 // Returns whatever headers have been received for this stream.
48 const BalsaHeaders
& headers() { return headers_
; }
50 const string
& body() { return body_
; }
52 BalsaHeaders
* mutable_headers() { return &headers_
; }
53 string
* mutable_body() { return &body_
; }
56 friend class test::QuicReliableServerStreamPeer
;
58 BalsaHeaders headers_
;
65 #endif // NET_TOOLS_QUIC_QUIC_RELIABLE_SERVER_STREAM_H_