| OLD | NEW |
| (Empty) |
| 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 "base/basictypes.h" | |
| 11 #include "net/quic/quic_protocol.h" | |
| 12 #include "net/quic/quic_spdy_stream.h" | |
| 13 #include "net/spdy/spdy_framer.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 class QuicSpdySession; | |
| 18 | |
| 19 namespace tools { | |
| 20 | |
| 21 namespace test { | |
| 22 class QuicSpdyServerStreamPeer; | |
| 23 } // namespace test | |
| 24 | |
| 25 // All this does right now is aggregate data, and on fin, send an HTTP | |
| 26 // response. | |
| 27 class QuicSpdyServerStream : public QuicSpdyStream { | |
| 28 public: | |
| 29 QuicSpdyServerStream(QuicStreamId id, QuicSpdySession* session); | |
| 30 ~QuicSpdyServerStream() override; | |
| 31 | |
| 32 // QuicSpdyStream | |
| 33 void OnInitialHeadersComplete(bool fin, size_t frame_len) override; | |
| 34 void OnTrailingHeadersComplete(bool fin, size_t frame_len) override; | |
| 35 | |
| 36 // ReliableQuicStream implementation called by the sequencer when there is | |
| 37 // data (or a FIN) to be read. | |
| 38 void OnDataAvailable() override; | |
| 39 | |
| 40 // The response body of error responses. | |
| 41 static const char* const kErrorResponseBody; | |
| 42 | |
| 43 protected: | |
| 44 // Sends a basic 200 response using SendHeaders for the headers and WriteData | |
| 45 // for the body. | |
| 46 virtual void SendResponse(); | |
| 47 | |
| 48 // Sends a basic 500 response using SendHeaders for the headers and WriteData | |
| 49 // for the body | |
| 50 virtual void SendErrorResponse(); | |
| 51 | |
| 52 void SendHeadersAndBody(const SpdyHeaderBlock& response_headers, | |
| 53 base::StringPiece body); | |
| 54 void SendHeadersAndBodyAndTrailers(const SpdyHeaderBlock& response_headers, | |
| 55 base::StringPiece body, | |
| 56 const SpdyHeaderBlock& response_trailers); | |
| 57 | |
| 58 SpdyHeaderBlock* request_headers() { return &request_headers_; } | |
| 59 | |
| 60 const std::string& body() { return body_; } | |
| 61 | |
| 62 private: | |
| 63 friend class test::QuicSpdyServerStreamPeer; | |
| 64 | |
| 65 // The parsed headers received from the client. | |
| 66 SpdyHeaderBlock request_headers_; | |
| 67 int content_length_; | |
| 68 std::string body_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(QuicSpdyServerStream); | |
| 71 }; | |
| 72 | |
| 73 } // namespace tools | |
| 74 } // namespace net | |
| 75 | |
| 76 #endif // NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ | |
| OLD | NEW |