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_
6 #define NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_
10 #include "base/compiler_specific.h"
11 #include "net/tools/flip_server/balsa_headers.h"
12 #include "net/tools/flip_server/balsa_visitor_interface.h"
13 #include "net/tools/flip_server/sm_interface.h"
23 class StreamerSM
: public BalsaVisitorInterface
,
26 StreamerSM(SMConnection
* connection
,
27 SMInterface
* sm_other_interface
,
28 EpollServer
* epoll_server
,
29 FlipAcceptor
* acceptor
);
30 virtual ~StreamerSM();
32 void AddToOutputOrder(const MemCacheIter
& mci
) {}
34 virtual void InitSMInterface(SMInterface
* sm_other_interface
,
35 int32 server_idx
) OVERRIDE
;
36 virtual void InitSMConnection(SMConnectionPoolInterface
* connection_pool
,
37 SMInterface
* sm_interface
,
38 EpollServer
* epoll_server
,
40 std::string server_ip
,
41 std::string server_port
,
42 std::string remote_ip
,
43 bool use_ssl
) OVERRIDE
;
45 virtual size_t ProcessReadInput(const char* data
, size_t len
) OVERRIDE
;
46 virtual size_t ProcessWriteInput(const char* data
, size_t len
) OVERRIDE
;
47 virtual bool MessageFullyRead() const OVERRIDE
;
48 virtual void SetStreamID(uint32 stream_id
) OVERRIDE
{}
49 virtual bool Error() const OVERRIDE
;
50 virtual const char* ErrorAsString() const OVERRIDE
;
51 virtual void Reset() OVERRIDE
;
52 virtual void ResetForNewInterface(int32 server_idx
) OVERRIDE
{}
53 virtual void ResetForNewConnection() OVERRIDE
;
54 virtual void Cleanup() OVERRIDE
;
55 virtual int PostAcceptHook() OVERRIDE
;
56 virtual void NewStream(uint32 stream_id
, uint32 priority
,
57 const std::string
& filename
) OVERRIDE
{}
58 virtual void SendEOF(uint32 stream_id
) OVERRIDE
{}
59 virtual void SendErrorNotFound(uint32 stream_id
) OVERRIDE
{}
60 virtual void SendOKResponse(uint32 stream_id
, std::string output
) {}
61 virtual size_t SendSynStream(uint32 stream_id
,
62 const BalsaHeaders
& headers
) OVERRIDE
;
63 virtual size_t SendSynReply(uint32 stream_id
,
64 const BalsaHeaders
& headers
) OVERRIDE
;
65 virtual void SendDataFrame(uint32 stream_id
, const char* data
, int64 len
,
66 uint32 flags
, bool compress
) OVERRIDE
{}
67 virtual void set_is_request() OVERRIDE
;
68 static std::string
forward_ip_header() { return forward_ip_header_
; }
69 static void set_forward_ip_header(std::string value
) {
70 forward_ip_header_
= value
;
74 void SendEOFImpl(uint32 stream_id
) {}
75 void SendErrorNotFoundImpl(uint32 stream_id
) {}
76 void SendOKResponseImpl(uint32 stream_id
, std::string
* output
) {}
77 size_t SendSynReplyImpl(uint32 stream_id
, const BalsaHeaders
& headers
) {
80 size_t SendSynStreamImpl(uint32 stream_id
, const BalsaHeaders
& headers
) {
83 void SendDataFrameImpl(uint32 stream_id
, const char* data
, int64 len
,
84 uint32 flags
, bool compress
) {}
85 virtual void GetOutput() OVERRIDE
{}
87 virtual void ProcessBodyInput(const char *input
, size_t size
) OVERRIDE
;
88 virtual void MessageDone() OVERRIDE
;
89 virtual void ProcessHeaders(const BalsaHeaders
& headers
) OVERRIDE
;
90 virtual void ProcessBodyData(const char *input
, size_t size
) OVERRIDE
{}
91 virtual void ProcessHeaderInput(const char *input
, size_t size
) OVERRIDE
{}
92 virtual void ProcessTrailerInput(const char *input
, size_t size
) OVERRIDE
{}
93 virtual void ProcessRequestFirstLine(const char* line_input
,
95 const char* method_input
,
97 const char* request_uri_input
,
98 size_t request_uri_length
,
99 const char* version_input
,
100 size_t version_length
) OVERRIDE
{}
101 virtual void ProcessResponseFirstLine(const char *line_input
,
103 const char *version_input
,
104 size_t version_length
,
105 const char *status_input
,
106 size_t status_length
,
107 const char *reason_input
,
108 size_t reason_length
) OVERRIDE
{}
109 virtual void ProcessChunkLength(size_t chunk_length
) OVERRIDE
{}
110 virtual void ProcessChunkExtensions(const char *input
,
111 size_t size
) OVERRIDE
{}
112 virtual void HeaderDone() OVERRIDE
{}
113 virtual void HandleHeaderError(BalsaFrame
* framer
) OVERRIDE
;
114 virtual void HandleHeaderWarning(BalsaFrame
* framer
) OVERRIDE
{}
115 virtual void HandleChunkingError(BalsaFrame
* framer
) OVERRIDE
;
116 virtual void HandleBodyError(BalsaFrame
* framer
) OVERRIDE
;
119 SMConnection
* connection_
;
120 SMInterface
* sm_other_interface_
;
121 EpollServer
* epoll_server_
;
122 FlipAcceptor
* acceptor_
;
124 BalsaFrame
* http_framer_
;
125 BalsaHeaders headers_
;
126 static std::string forward_ip_header_
;
131 #endif // NET_TOOLS_FLIP_SERVER_STREAMER_INTERFACE_