SNode.C
|
#include <Response.h>
Public Member Functions | |
Response (SocketContext *socketContext) | |
Response (Response &)=delete | |
Response (Response &&) noexcept=delete | |
Response & | operator= (Response &)=delete |
Response & | operator= (Response &&) noexcept=delete |
~Response () override | |
void | stopResponse () |
Response & | status (int statusCode) |
Response & | append (const std::string &field, const std::string &value) |
Response & | set (const std::string &field, const std::string &value, bool overwrite=true) |
Response & | set (const std::map< std::string, std::string > &headers, bool overwrite=true) |
Response & | type (const std::string &type) |
Response & | cookie (const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={}) |
Response & | clearCookie (const std::string &name, const std::map< std::string, std::string > &options={}) |
Response & | setTrailer (const std::string &field, const std::string &value, bool overwrite=true) |
void | send (const char *chunk, std::size_t chunkLen) |
void | send (const std::string &chunk) |
void | sendStatus (int statusCode) |
void | upgrade (const std::shared_ptr< Request > &request, const std::function< void(const std::string &)> &status) |
void | sendFile (const std::string &file, const std::function< void(int)> &callback) |
void | end () |
Response & | sendHeader () |
Response & | sendFragment (const char *chunk, std::size_t chunkLen) |
Response & | sendFragment (const std::string &chunk) |
const std::string & | header (const std::string &field) |
SocketContext * | getSocketContext () const |
![]() | |
Sink (Sink &)=delete | |
Sink & | operator= (Sink &)=delete |
Public Attributes | |
int | statusCode = 200 |
int | httpMajor = 1 |
int | httpMinor = 1 |
Protected Attributes | |
web::http::CiStringMap< std::string > | headers |
web::http::CiStringMap< web::http::CookieOptions > | cookies |
web::http::CiStringMap< std::string > | trailer |
Private Member Functions | |
virtual void | init () |
void | sendCompleted () |
void | onSourceConnect (core::pipe::Source *source) override |
void | onSourceData (const char *chunk, std::size_t chunkLen) override |
void | onSourceEof () override |
void | onSourceError (int errnum) override |
Private Attributes | |
std::size_t | contentSent = 0 |
std::size_t | contentLength = 0 |
SocketContext * | socketContext = nullptr |
core::socket::stream::SocketContext * | socketContextUpgrade = nullptr |
ConnectionState | connectionState = ConnectionState::Default |
TransferEncoding | transferEncoding = TransferEncoding::HTTP10 |
Friends | |
class | SocketContext |
Additional Inherited Members | |
![]() | |
Sink ()=default | |
Sink (Sink &&) noexcept=default | |
Sink & | operator= (Sink &&) noexcept=default |
virtual | ~Sink () |
bool | isStreaming () |
void | stop () |
Definition at line 51 of file Response.h.
|
explicit |
Definition at line 50 of file Response.cpp.
References Response().
Referenced by Response().
|
explicitdelete |
|
explicitdeletenoexcept |
|
override |
Definition at line 54 of file Response.cpp.
Response & web::http::server::Response::append | ( | const std::string & | field, |
const std::string & | value ) |
Definition at line 86 of file Response.cpp.
Response & web::http::server::Response::clearCookie | ( | const std::string & | name, |
const std::map< std::string, std::string > & | options = {} ) |
Definition at line 162 of file Response.cpp.
Response & web::http::server::Response::cookie | ( | const std::string & | name, |
const std::string & | value, | ||
const std::map< std::string, std::string > & | options = {} ) |
Definition at line 156 of file Response.cpp.
void web::http::server::Response::end | ( | ) |
Definition at line 305 of file Response.cpp.
SocketContext * web::http::server::Response::getSocketContext | ( | ) | const |
Definition at line 432 of file Response.cpp.
const std::string & web::http::server::Response::header | ( | const std::string & | field | ) |
Definition at line 428 of file Response.cpp.
|
privatevirtual |
Definition at line 66 of file Response.cpp.
References httpMajor, httpMinor, and statusCode.
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 391 of file Response.cpp.
References sendHeader(), core::pipe::Source::start(), and core::pipe::Source::stop().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 405 of file Response.cpp.
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 409 of file Response.cpp.
References sendCompleted().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 417 of file Response.cpp.
References sendCompleted().
void web::http::server::Response::send | ( | const char * | chunk, |
std::size_t | chunkLen ) |
Definition at line 191 of file Response.cpp.
References sendCompleted(), and sendHeader().
void web::http::server::Response::send | ( | const std::string & | chunk | ) |
Definition at line 202 of file Response.cpp.
|
private |
Definition at line 368 of file Response.cpp.
Referenced by onSourceEof(), onSourceError(), and send().
void web::http::server::Response::sendFile | ( | const std::string & | file, |
const std::function< void(int)> & | callback ) |
Definition at line 270 of file Response.cpp.
Response & web::http::server::Response::sendFragment | ( | const char * | chunk, |
std::size_t | chunkLen ) |
Definition at line 346 of file Response.cpp.
Response & web::http::server::Response::sendFragment | ( | const std::string & | chunk | ) |
Definition at line 364 of file Response.cpp.
Response & web::http::server::Response::sendHeader | ( | ) |
Definition at line 309 of file Response.cpp.
Referenced by onSourceConnect(), and send().
void web::http::server::Response::sendStatus | ( | int | statusCode | ) |
Definition at line 210 of file Response.cpp.
References status().
Response & web::http::server::Response::set | ( | const std::map< std::string, std::string > & | headers, |
bool | overwrite = true ) |
Definition at line 98 of file Response.cpp.
Response & web::http::server::Response::set | ( | const std::string & | field, |
const std::string & | value, | ||
bool | overwrite = true ) |
Definition at line 106 of file Response.cpp.
Response & web::http::server::Response::setTrailer | ( | const std::string & | field, |
const std::string & | value, | ||
bool | overwrite = true ) |
Definition at line 172 of file Response.cpp.
Response & web::http::server::Response::status | ( | int | statusCode | ) |
Definition at line 80 of file Response.cpp.
References statusCode.
Referenced by sendStatus().
void web::http::server::Response::stopResponse | ( | ) |
Definition at line 62 of file Response.cpp.
Response & web::http::server::Response::type | ( | const std::string & | type | ) |
Definition at line 152 of file Response.cpp.
void web::http::server::Response::upgrade | ( | const std::shared_ptr< Request > & | request, |
const std::function< void(const std::string &)> & | status ) |
Sequence diagram of res.upgrade(req).
Definition at line 222 of file Response.cpp.
|
friend |
Definition at line 121 of file Response.h.
|
private |
Definition at line 118 of file Response.h.
|
private |
Definition at line 113 of file Response.h.
|
private |
Definition at line 112 of file Response.h.
|
protected |
Definition at line 108 of file Response.h.
|
protected |
Definition at line 107 of file Response.h.
int web::http::server::Response::httpMajor = 1 |
Definition at line 103 of file Response.h.
Referenced by init().
int web::http::server::Response::httpMinor = 1 |
Definition at line 104 of file Response.h.
Referenced by init().
|
private |
Definition at line 115 of file Response.h.
|
private |
Definition at line 116 of file Response.h.
int web::http::server::Response::statusCode = 200 |
Definition at line 102 of file Response.h.
|
protected |
Definition at line 109 of file Response.h.
|
private |
Definition at line 119 of file Response.h.