OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ | 5 #ifndef NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ |
6 #define NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ | 6 #define NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "net/base/io_buffer.h" | |
12 #include "net/quic/quic_data_stream.h" | 11 #include "net/quic/quic_data_stream.h" |
13 #include "net/quic/quic_protocol.h" | 12 #include "net/quic/quic_protocol.h" |
14 #include "net/spdy/spdy_framer.h" | 13 #include "net/spdy/spdy_framer.h" |
15 #include "net/tools/balsa/balsa_headers.h" | 14 #include "net/tools/balsa/balsa_headers.h" |
16 | 15 |
17 namespace net { | 16 namespace net { |
18 | 17 |
19 class QuicSession; | 18 class QuicSession; |
20 | 19 |
21 namespace tools { | 20 namespace tools { |
22 | 21 |
23 namespace test { | 22 namespace test { |
24 class QuicSpdyServerStreamPeer; | 23 class QuicSpdyServerStreamPeer; |
25 } // namespace test | 24 } // namespace test |
26 | 25 |
27 // All this does right now is aggregate data, and on fin, send an HTTP | 26 // All this does right now is aggregate data, and on fin, send an HTTP |
28 // response. | 27 // response. |
29 class QuicSpdyServerStream : public QuicDataStream { | 28 class QuicSpdyServerStream : public QuicDataStream { |
30 public: | 29 public: |
31 QuicSpdyServerStream(QuicStreamId id, QuicSession* session); | 30 QuicSpdyServerStream(QuicStreamId id, QuicSession* session); |
32 ~QuicSpdyServerStream() override; | 31 ~QuicSpdyServerStream() override; |
33 | 32 |
34 // ReliableQuicStream implementation called by the session when there's | 33 // ReliableQuicStream implementation called by the session when there's |
35 // data for us. | 34 // data for us. |
36 uint32 ProcessData(const char* data, uint32 data_len) override; | 35 uint32 ProcessData(const char* data, uint32 data_len) override; |
37 void OnFinRead() override; | 36 void OnFinRead() override; |
38 | 37 |
39 void ParseRequestHeaders(); | |
40 | |
41 private: | 38 private: |
42 friend class test::QuicSpdyServerStreamPeer; | 39 friend class test::QuicSpdyServerStreamPeer; |
43 | 40 |
| 41 // Parses the request headers from |data| to |request_headers_|. |
| 42 // Returns false if there was an error parsing the headers. |
| 43 bool ParseRequestHeaders(const char* data, uint32 data_len); |
| 44 |
44 // Sends a basic 200 response using SendHeaders for the headers and WriteData | 45 // Sends a basic 200 response using SendHeaders for the headers and WriteData |
45 // for the body. | 46 // for the body. |
46 void SendResponse(); | 47 void SendResponse(); |
47 | 48 |
48 // Sends a basic 500 response using SendHeaders for the headers and WriteData | 49 // Sends a basic 500 response using SendHeaders for the headers and WriteData |
49 // for the body | 50 // for the body |
50 void SendErrorResponse(); | 51 void SendErrorResponse(); |
51 | 52 |
52 | 53 |
53 void SendHeadersAndBody(const SpdyHeaderBlock& response_headers, | 54 void SendHeadersAndBody(const SpdyHeaderBlock& response_headers, |
54 base::StringPiece body); | 55 base::StringPiece body); |
55 | 56 |
56 BalsaHeaders headers_; | 57 // The parsed headers received from the client. |
| 58 SpdyHeaderBlock request_headers_; |
| 59 int content_length_; |
57 std::string body_; | 60 std::string body_; |
58 | 61 |
59 // Buffer into which response header data is read. | |
60 scoped_refptr<GrowableIOBuffer> read_buf_; | |
61 bool request_headers_received_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(QuicSpdyServerStream); | 62 DISALLOW_COPY_AND_ASSIGN(QuicSpdyServerStream); |
64 }; | 63 }; |
65 | 64 |
66 } // namespace tools | 65 } // namespace tools |
67 } // namespace net | 66 } // namespace net |
68 | 67 |
69 #endif // NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ | 68 #endif // NET_TOOLS_QUIC_QUIC_SPDY_SERVER_STREAM_H_ |
OLD | NEW |