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. 4 5#ifndef NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ 6#define NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ 7 8#include <string> 9 10#include "net/base/io_buffer.h" 11#include "net/quic/quic_data_stream.h" 12#include "net/quic/quic_protocol.h" 13#include "net/tools/balsa/balsa_headers.h" 14 15namespace net { 16 17class QuicSession; 18 19namespace tools { 20 21namespace test { 22class QuicSpdyServerStreamPeer; 23} // namespace test 24 25// All this does right now is aggregate data, and on fin, send an HTTP 26// response. 27class QuicSpdyServerStream : public QuicDataStream { 28 public: 29 QuicSpdyServerStream(QuicStreamId id, QuicSession* session); 30 virtual ~QuicSpdyServerStream(); 31 32 // ReliableQuicStream implementation called by the session when there's 33 // data for us. 34 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE; 35 virtual void OnFinRead() OVERRIDE; 36 37 int ParseRequestHeaders(); 38 39 private: 40 friend class test::QuicSpdyServerStreamPeer; 41 42 // Sends a basic 200 response using SendHeaders for the headers and WriteData 43 // for the body. 44 void SendResponse(); 45 46 // Sends a basic 500 response using SendHeaders for the headers and WriteData 47 // for the body 48 void SendErrorResponse(); 49 50 void SendHeadersAndBody(const BalsaHeaders& response_headers, 51 base::StringPiece body); 52 53 BalsaHeaders headers_; 54 string body_; 55 56 // Buffer into which response header data is read. 57 scoped_refptr<GrowableIOBuffer> read_buf_; 58 bool request_headers_received_; 59}; 60 61} // namespace tools 62} // namespace net 63 64#endif // NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ 65