2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#ifndef WEB_HTTP_SERVER_RESPONSE_H
43#define WEB_HTTP_SERVER_RESPONSE_H
45#include "core/pipe/Sink.h"
46#include "web/http/ConnectionState.h"
47#include "web/http/CookieOptions.h"
48#include "web/http/TransferEncoding.h"
50namespace web::http::
server {
55#ifndef DOXYGEN_SHOULD_SKIP_THIS
57#include "web/http/CiStringMap.h"
67namespace web::http::
server {
89 Response&
append(
const std::string& field,
const std::string& value);
90 Response&
set(
const std::string& field,
const std::string& value,
bool overwrite =
true);
91 Response&
set(
const std::map<std::string, std::string>& headers,
bool overwrite =
true);
93 Response&
cookie(
const std::string& name,
const std::string& value,
const std::map<std::string, std::string>& options = {});
94 Response&
clearCookie(
const std::string& name,
const std::map<std::string, std::string>& options = {});
95 Response&
setTrailer(
const std::string& field,
const std::string& value,
bool overwrite =
true);
97 void send(
const char* chunk, std::size_t chunkLen);
98 void send(
const std::string& chunk);
100 void upgrade(
const std::shared_ptr<
Request>& request,
const std::function<
void(
const std::string&)>& status);
101 void sendFile(
const std::string& file,
const std::function<
void(
int)>& callback);
112 void onSourceData(
const char* chunk, std::size_t chunkLen)
override;
117 const std::string&
header(
const std::string& field);
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
static void atNextTick(const std::function< void(void)> &callBack)
virtual void setReadTimeout(const utils::Timeval &timeout)=0
const std::string & getConnectionName() const
SocketConnection * getSocketConnection() const
SocketContext(core::socket::stream::SocketConnection *socketConnection)
void shutdownWrite(bool forceClose=false)
static bool contains(int status)
static std::map< int, std::string > statusCode
static std::string reason(int status)
RequestParser(core::socket::stream::SocketContext *socketContext, const std::function< void()> &onRequestStart, const std::function< void(Request &&)> &onRequestParsed, const std::function< void(int, const std::string &)> &onRequestParseError)
Request(int status, const std::string &reason="")
const std::string & get(const std::string &key, int i=0) const
void onSourceData(const char *chunk, std::size_t chunkLen) override
Response(SocketContext *socketContext)
Response & operator=(Response &&) noexcept=delete
SocketContext * getSocketContext() const
void onSourceConnect(core::pipe::Source *source) override
web::http::CiStringMap< web::http::CookieOptions > cookies
Response & status(int statusCode)
void send(const std::string &chunk)
Response & sendFragment(const std::string &chunk="")
Response(Response &&) noexcept=delete
void send(const char *chunk, std::size_t chunkLen)
Response & setTrailer(const std::string &field, const std::string &value, bool overwrite=true)
std::string requestMethod
Response & set(const std::map< std::string, std::string > &headers, bool overwrite=true)
web::http::CiStringMap< std::string > trailer
web::http::CiStringMap< std::string > headers
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
TransferEncoding transferEncoding
void upgrade(const std::shared_ptr< Request > &request, const std::function< void(const std::string &)> &status)
Response & type(const std::string &type)
void onSourceError(int errnum) override
Response(Response &)=delete
std::size_t contentLength
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
web::http::server::SocketContext * socketContext
Response & operator=(Response &)=delete
Response & append(const std::string &field, const std::string &value)
void sendStatus(int statusCode)
Response & sendFragment(const char *chunk, std::size_t chunkLen)
void onSourceEof() override
void sendFile(const std::string &file, const std::function< void(int)> &callback)
Response & clearCookie(const std::string &name, const std::map< std::string, std::string > &options={})
ConnectionState connectionState
const std::string & header(const std::string &field)
bool onSignal(int signum) override
std::list< std::function< void()> > onDisconnectEventReceiverList
void onConnected() override
void onDisconnected() override
void responseCompleted(const Response &response, bool success)
std::shared_ptr< Response > masterResponse
core::socket::stream::SocketContext Super
web::http::server::Response Response
std::size_t onReceivedFromPeer() override
void onWriteError(int errnum) override
std::list< std::function< void()> > onConnectEventReceiverList
void responseStarted(const Response &response)
void requestCompleted(const Response &response)
SocketContext(core::socket::stream::SocketConnection *socketConnection, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onRequestReady)
std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> onRequestReady
web::http::server::Request Request
SocketContext * onConnected(std::function< void()> onConnectEventReceiver)
SocketContext * onDisconnected(std::function< void()> onDisconnectEventReceiver)
std::list< std::shared_ptr< Request > > pendingRequests
bool ciContains(const std::string &str1, const std::string &str2)