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