1 // Copyright (c) 2011 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_FLIP_SERVER_STREAMER_INTERFACE_H_
6 #define NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_H_
10 #include "base/compiler_specific.h"
11 #include "net/tools/balsa/balsa_headers.h"
12 #include "net/tools/balsa/balsa_visitor_interface.h"
13 #include "net/tools/flip_server/sm_interface.h"
23 class StreamerSM
: public BalsaVisitorInterface
, public SMInterface
{
25 StreamerSM(SMConnection
* connection
,
26 SMInterface
* sm_other_interface
,
27 EpollServer
* epoll_server
,
28 FlipAcceptor
* acceptor
);
29 ~StreamerSM() override
;
31 void AddToOutputOrder(const MemCacheIter
& mci
) {}
33 void InitSMInterface(SMInterface
* sm_other_interface
,
34 int32 server_idx
) override
;
35 void InitSMConnection(SMConnectionPoolInterface
* connection_pool
,
36 SMInterface
* sm_interface
,
37 EpollServer
* epoll_server
,
39 std::string server_ip
,
40 std::string server_port
,
41 std::string remote_ip
,
42 bool use_ssl
) override
;
44 size_t ProcessReadInput(const char* data
, size_t len
) override
;
45 size_t ProcessWriteInput(const char* data
, size_t len
) override
;
46 bool MessageFullyRead() const override
;
47 void SetStreamID(uint32 stream_id
) override
{}
48 bool Error() const override
;
49 const char* ErrorAsString() const override
;
50 void Reset() override
;
51 void ResetForNewInterface(int32 server_idx
) override
{}
52 void ResetForNewConnection() override
;
53 void Cleanup() override
;
54 int PostAcceptHook() override
;
55 void NewStream(uint32 stream_id
,
57 const std::string
& filename
) override
{}
58 void SendEOF(uint32 stream_id
) override
{}
59 void SendErrorNotFound(uint32 stream_id
) override
{}
60 virtual void SendOKResponse(uint32 stream_id
, std::string output
) {}
61 size_t SendSynStream(uint32 stream_id
, const BalsaHeaders
& headers
) override
;
62 size_t SendSynReply(uint32 stream_id
, const BalsaHeaders
& headers
) override
;
63 void SendDataFrame(uint32 stream_id
,
67 bool compress
) override
{}
68 void set_is_request() override
;
69 static std::string
forward_ip_header() { return forward_ip_header_
; }
70 static void set_forward_ip_header(std::string value
) {
71 forward_ip_header_
= value
;
75 void SendEOFImpl(uint32 stream_id
) {}
76 void SendErrorNotFoundImpl(uint32 stream_id
) {}
77 void SendOKResponseImpl(uint32 stream_id
, std::string
* output
) {}
78 size_t SendSynReplyImpl(uint32 stream_id
, const BalsaHeaders
& headers
) {
81 size_t SendSynStreamImpl(uint32 stream_id
, const BalsaHeaders
& headers
) {
84 void SendDataFrameImpl(uint32 stream_id
,
89 void GetOutput() override
{}
91 void ProcessBodyInput(const char* input
, size_t size
) override
;
92 void MessageDone() override
;
93 void ProcessHeaders(const BalsaHeaders
& headers
) override
;
94 void ProcessBodyData(const char* input
, size_t size
) override
{}
95 void ProcessHeaderInput(const char* input
, size_t size
) override
{}
96 void ProcessTrailerInput(const char* input
, size_t size
) override
{}
97 void ProcessRequestFirstLine(const char* line_input
,
99 const char* method_input
,
100 size_t method_length
,
101 const char* request_uri_input
,
102 size_t request_uri_length
,
103 const char* version_input
,
104 size_t version_length
) override
{}
105 void ProcessResponseFirstLine(const char* line_input
,
107 const char* version_input
,
108 size_t version_length
,
109 const char* status_input
,
110 size_t status_length
,
111 const char* reason_input
,
112 size_t reason_length
) override
{}
113 void ProcessChunkLength(size_t chunk_length
) override
{}
114 void ProcessChunkExtensions(const char* input
, size_t size
) override
{}
115 void HeaderDone() override
{}
116 void HandleHeaderError(BalsaFrame
* framer
) override
;
117 void HandleHeaderWarning(BalsaFrame
* framer
) override
{}
118 void HandleChunkingError(BalsaFrame
* framer
) override
;
119 void HandleBodyError(BalsaFrame
* framer
) override
;
122 SMConnection
* connection_
;
123 SMInterface
* sm_other_interface_
;
124 EpollServer
* epoll_server_
;
125 FlipAcceptor
* acceptor_
;
127 BalsaFrame
* http_framer_
;
128 BalsaHeaders headers_
;
129 static std::string forward_ip_header_
;
134 #endif // NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_H_