SNode.C
Loading...
Searching...
No Matches
web::http::server::Response Class Reference

#include <Response.h>

Inheritance diagram for web::http::server::Response:
Collaboration diagram for web::http::server::Response:

Public Member Functions

 Response (SocketContext *socketContext)
 
 Response (Response &)=delete
 
 Response (Response &&) noexcept=delete
 
Responseoperator= (Response &)=delete
 
Responseoperator= (Response &&) noexcept=delete
 
 ~Response () override
 
void stopResponse ()
 
Responsestatus (int statusCode)
 
Responseappend (const std::string &field, const std::string &value)
 
Responseset (const std::string &field, const std::string &value, bool overwrite=true)
 
Responseset (const std::map< std::string, std::string > &headers, bool overwrite=true)
 
Responsetype (const std::string &type)
 
Responsecookie (const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
 
ResponseclearCookie (const std::string &name, const std::map< std::string, std::string > &options={})
 
ResponsesetTrailer (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 ()
 
ResponsesendHeader ()
 
ResponsesendFragment (const char *chunk, std::size_t chunkLen)
 
ResponsesendFragment (const std::string &chunk)
 
const std::string & header (const std::string &field)
 
SocketContextgetSocketContext () const
 
- Public Member Functions inherited from core::pipe::Sink
 Sink (Sink &)=delete
 
Sinkoperator= (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::CookieOptionscookies
 
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
 
web::http::server::SocketContextsocketContext = nullptr
 
ConnectionState connectionState = ConnectionState::Default
 
TransferEncoding transferEncoding = TransferEncoding::HTTP10
 

Friends

class SocketContext
 

Additional Inherited Members

- Protected Member Functions inherited from core::pipe::Sink
 Sink ()=default
 
 Sink (Sink &&) noexcept=default
 
Sinkoperator= (Sink &&) noexcept=default
 
virtual ~Sink ()
 
bool isStreaming ()
 
void stop ()
 

Detailed Description

Definition at line 69 of file Response.h.

Constructor & Destructor Documentation

◆ Response() [1/3]

web::http::server::Response::Response ( SocketContext socketContext)
explicit

Definition at line 72 of file Response.cpp.

74 }
web::http::server::SocketContext * socketContext
Definition Response.h:133

References socketContext.

◆ Response() [2/3]

web::http::server::Response::Response ( Response )
explicitdelete

◆ Response() [3/3]

web::http::server::Response::Response ( Response &&  )
explicitdeletenoexcept

◆ ~Response()

web::http::server::Response::~Response ( )
override

Definition at line 76 of file Response.cpp.

76 {
77 if (socketContext != nullptr && Sink::isStreaming()) {
79 }
80 }

References core::pipe::Sink::isStreaming(), socketContext, and core::socket::stream::SocketContext::streamEof().

Here is the call graph for this function:

Member Function Documentation

◆ append()

Response & web::http::server::Response::append ( const std::string &  field,
const std::string &  value 
)

Definition at line 105 of file Response.cpp.

105 {
106 const std::map<std::string, std::string>::iterator it = headers.find(field);
107
108 if (it != headers.end()) {
109 set(field, it->second.append(", ").append(value));
110 } else {
111 set(field, value);
112 }
113
114 return *this;
115 }
web::http::CiStringMap< std::string > headers
Definition Response.h:125
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
Definition Response.cpp:125

References headers, and set().

Referenced by express::Response::append().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearCookie()

Response & web::http::server::Response::clearCookie ( const std::string &  name,
const std::map< std::string, std::string > &  options = {} 
)

Definition at line 181 of file Response.cpp.

181 {
182 std::map<std::string, std::string> opts = options;
183
184 opts.erase("Max-Age");
185 const time_t time = 0;
186 opts["Expires"] = httputils::to_http_date(utils::system::gmtime(&time));
187
188 return cookie(name, "", opts);
189 }
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
Definition Response.cpp:175
std::string to_http_date(struct tm *tm)
struct tm * gmtime(const time_t *timep)
Definition time.cpp:62
time_t time(time_t *tloc)
Definition time.cpp:52

References cookie(), utils::system::gmtime(), and httputils::to_http_date().

Referenced by express::Response::clearCookie().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cookie()

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 175 of file Response.cpp.

175 {
176 cookies.insert({name, CookieOptions(value, options)});
177
178 return *this;
179 }
web::http::CiStringMap< web::http::CookieOptions > cookies
Definition Response.h:126

References web::http::CookieOptions::CookieOptions(), and cookies.

Referenced by clearCookie(), and express::Response::cookie().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

void web::http::server::Response::end ( )

Definition at line 346 of file Response.cpp.

346 {
347 send("");
348 }
void send(const char *chunk, std::size_t chunkLen)
Definition Response.cpp:210

References send().

Referenced by express::Response::end().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSocketContext()

SocketContext * web::http::server::Response::getSocketContext ( ) const

Definition at line 468 of file Response.cpp.

468 {
469 return socketContext;
470 }

References socketContext.

Referenced by express::Response::getSocketContext().

Here is the caller graph for this function:

◆ header()

const std::string & web::http::server::Response::header ( const std::string &  field)

Definition at line 464 of file Response.cpp.

464 {
465 return headers[field];
466 }

References headers.

Referenced by express::Response::header(), and upgrade().

Here is the caller graph for this function:

◆ init()

void web::http::server::Response::init ( )
privatevirtual

Definition at line 86 of file Response.cpp.

References connectionState, contentLength, contentSent, cookies, web::http::Default, headers, web::http::HTTP10, httpMajor, httpMinor, statusCode, trailer, and transferEncoding.

Referenced by web::http::server::SocketContext::deliverRequest(), and web::http::server::SocketContext::onConnected().

Here is the caller graph for this function:

◆ onSourceConnect()

void web::http::server::Response::onSourceConnect ( core::pipe::Source source)
overrideprivatevirtual

Implements core::pipe::Sink.

Definition at line 427 of file Response.cpp.

427 {
428 if (socketContext != nullptr) {
430 sendHeader();
431
432 source->start();
433 } else {
434 source->stop();
435 }
436 } else {
437 source->stop();
438 }
439 }
Source * source
Definition Sink.h:90
virtual void stop()=0
virtual void start()=0
bool streamToPeer(core::pipe::Source *source) const

References sendHeader(), socketContext, core::pipe::Source::start(), core::pipe::Source::stop(), and core::socket::stream::SocketContext::streamToPeer().

Here is the call graph for this function:

◆ onSourceData()

void web::http::server::Response::onSourceData ( const char *  chunk,
std::size_t  chunkLen 
)
overrideprivatevirtual

Implements core::pipe::Sink.

Definition at line 441 of file Response.cpp.

441 {
442 sendFragment(chunk, chunkLen);
443 }
Response & sendFragment(const char *chunk, std::size_t chunkLen)
Definition Response.cpp:387

References sendFragment().

Here is the call graph for this function:

◆ onSourceEof()

void web::http::server::Response::onSourceEof ( )
overrideprivatevirtual

Implements core::pipe::Sink.

Definition at line 445 of file Response.cpp.

445 {
446 if (socketContext != nullptr) {
448 }
449
451 }

References sendCompleted(), socketContext, and core::socket::stream::SocketContext::streamEof().

Here is the call graph for this function:

◆ onSourceError()

void web::http::server::Response::onSourceError ( int  errnum)
overrideprivatevirtual

Implements core::pipe::Sink.

Definition at line 453 of file Response.cpp.

453 {
454 errno = errnum;
455
456 if (socketContext != nullptr) {
459 }
460
462 }

References core::socket::stream::SocketContext::close(), sendCompleted(), socketContext, and core::socket::stream::SocketContext::streamEof().

Here is the call graph for this function:

◆ operator=() [1/2]

Response & web::http::server::Response::operator= ( Response &&  )
deletenoexcept

◆ operator=() [2/2]

Response & web::http::server::Response::operator= ( Response )
delete

◆ send() [1/2]

void web::http::server::Response::send ( const char *  chunk,
std::size_t  chunkLen 
)

Definition at line 210 of file Response.cpp.

210 {
211 if (chunkLen > 0) {
212 set("Content-Type", "application/octet-stream", false);
213 }
214 set("Content-Length", std::to_string(chunkLen));
215
216 sendHeader();
217 sendFragment(chunk, chunkLen);
219 }

References sendCompleted(), sendFragment(), sendHeader(), and set().

Referenced by express::Response::send(), and send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [2/2]

void web::http::server::Response::send ( const std::string &  chunk)

Definition at line 221 of file Response.cpp.

221 {
222 if (!chunk.empty()) {
223 set("Content-Type", "text/html; charset=utf-8", false);
224 }
225
226 send(chunk.data(), chunk.size());
227 }

References send(), and set().

Referenced by end(), express::Response::send(), and sendStatus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendCompleted()

void web::http::server::Response::sendCompleted ( )
private

Definition at line 409 of file Response.cpp.

409 {
411 sendFragment(""); // For transfer encoding chunked. Terminate the chunk sequence.
412
413 if (!trailer.empty()) {
414 for (auto& [field, value] : trailer) {
415 socketContext->sendToPeer(std::string(field).append(":").append(value).append("\r\n"));
416 }
417
418 socketContext->sendToPeer("\r\n");
419 }
420 }
421
422 if (socketContext != nullptr) {
424 }
425 }
void sendToPeer(const char *chunk, std::size_t chunkLen) const final
Response & append(const std::string &field, const std::string &value)
Definition Response.cpp:105

References web::http::Chunked, contentLength, contentSent, httpMajor, httpMinor, web::http::server::SocketContext::responseCompleted(), sendFragment(), core::socket::SocketContext::sendToPeer(), socketContext, trailer, and transferEncoding.

Referenced by onSourceEof(), onSourceError(), and send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendFile()

void web::http::server::Response::sendFile ( const std::string &  file,
const std::function< void(int)> &  callback 
)

Definition at line 308 of file Response.cpp.

308 {
309 if (socketContext != nullptr) {
310 std::string absolutFileName = file;
311
312 if (std::filesystem::exists(absolutFileName)) {
313 std::error_code ec;
314 absolutFileName = std::filesystem::canonical(absolutFileName);
315
316 if (std::filesystem::is_regular_file(absolutFileName, ec) && !ec) {
317 core::file::FileReader::open(absolutFileName)->pipe(this, [this, &absolutFileName, &callback](int errnum) {
318 callback(errnum);
319
320 if (errnum == 0) {
321 set("Content-Type", web::http::MimeTypes::contentType(absolutFileName), false);
322 set("Last-Modified", httputils::file_mod_http_date(absolutFileName), false);
323 if (httpMajor == 1) {
324 if (httpMinor == 1) {
325 set("Transfer-Encoding", "chunked");
326 } else {
327 set("Content-Length", std::to_string(std::filesystem::file_size(absolutFileName)));
328 }
329 }
330 } else {
331 status(404);
332 }
333 });
334 } else {
335 status(404);
336 errno = EEXIST;
337 callback(errno);
338 }
339 } else {
340 errno = ENOENT;
341 callback(errno);
342 }
343 }
344 }
static FileReader * open(const std::string &path)
void pipe(Sink *sink, const std::function< void(int)> &callback)
Definition Source.cpp:60
static std::string contentType(const std::string &file)
Response & status(int statusCode)
Definition Response.cpp:99
std::string file_mod_http_date(const std::string &filePath)

References web::http::MimeTypes::contentType(), httputils::file_mod_http_date(), httpMajor, httpMinor, core::file::FileReader::open(), core::pipe::Source::pipe(), set(), socketContext, and status().

Referenced by express::Response::sendFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendFragment() [1/2]

Response & web::http::server::Response::sendFragment ( const char *  chunk,
std::size_t  chunkLen 
)

Definition at line 387 of file Response.cpp.

387 {
388 if (socketContext != nullptr) {
390 socketContext->sendToPeer(to_hex_str(chunkLen).append("\r\n"));
391 }
392
393 socketContext->sendToPeer(chunk, chunkLen);
394 contentSent += chunkLen;
395
397 socketContext->sendToPeer("\r\n");
398 contentLength += chunkLen;
399 }
400 }
401
402 return *this;
403 }
#define to_hex_str(int_val)
Definition Request.cpp:71

References web::http::Chunked, contentLength, contentSent, core::socket::stream::SocketContext::sendToPeer(), core::socket::SocketContext::sendToPeer(), socketContext, and transferEncoding.

Referenced by onSourceData(), send(), express::Response::sendFragment(), and sendFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendFragment() [2/2]

Response & web::http::server::Response::sendFragment ( const std::string &  chunk)

Definition at line 405 of file Response.cpp.

405 {
406 return sendFragment(chunk.data(), chunk.size());
407 }

References sendFragment().

Referenced by sendCompleted(), and express::Response::sendFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendHeader()

Response & web::http::server::Response::sendHeader ( )

Definition at line 350 of file Response.cpp.

350 {
351 if (socketContext != nullptr) {
353
354 socketContext->sendToPeer("HTTP/" + std::to_string(httpMajor)
355 .append(".")
356 .append(std::to_string(httpMinor))
357 .append(" ")
358 .append(std::to_string(statusCode))
359 .append(" ")
361 .append("\r\n"));
362 socketContext->sendToPeer("Date: " + httputils::to_http_date() + "\r\n");
363
364 set("X-Powered-By", "snode.c");
365
366 for (const auto& [field, value] : headers) {
367 socketContext->sendToPeer(std::string(field).append(": ").append(value).append("\r\n"));
368 }
369
370 for (const auto& [cookie, cookieValue] : cookies) {
371 const std::string cookieString = std::accumulate(
372 cookieValue.getOptions().begin(),
373 cookieValue.getOptions().end(),
374 cookie + "=" + cookieValue.getValue(),
375 [](const std::string& str, const std::pair<const std::string&, const std::string&> option) -> std::string {
376 return str + "; " + option.first + (!option.second.empty() ? "=" + option.second : "");
377 });
378 socketContext->sendToPeer("Set-Cookie: " + cookieString + "\r\n");
379 }
380
381 socketContext->sendToPeer("\r\n");
382 }
383
384 return *this;
385 }
static std::string reason(int status)

References cookies, web::http::CookieOptions::getOptions(), web::http::CookieOptions::getValue(), headers, httpMajor, httpMinor, web::http::StatusCode::reason(), web::http::server::SocketContext::responseStarted(), core::socket::SocketContext::sendToPeer(), set(), socketContext, statusCode, and httputils::to_http_date().

Referenced by onSourceConnect(), send(), and express::Response::sendHeader().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendStatus()

void web::http::server::Response::sendStatus ( int  statusCode)

Definition at line 229 of file Response.cpp.

229 {
231
233 }

References web::http::StatusCode::reason(), send(), and status().

Here is the call graph for this function:

◆ set() [1/2]

Response & web::http::server::Response::set ( const std::map< std::string, std::string > &  headers,
bool  overwrite = true 
)

Definition at line 117 of file Response.cpp.

117 {
118 for (const auto& [field, value] : headers) {
119 set(field, value, overwrite);
120 }
121
122 return *this;
123 }

References set().

Referenced by express::Response::set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [2/2]

Response & web::http::server::Response::set ( const std::string &  field,
const std::string &  value,
bool  overwrite = true 
)

Definition at line 125 of file Response.cpp.

125 {
126 if (!value.empty()) {
127 if (overwrite) {
128 headers.insert_or_assign(field, value);
129 } else {
130 headers.insert({field, value});
131 }
132
133 if (web::http::ciEquals(field, "Connection")) {
134 if (web::http::ciContains(headers[field], "keep-alive")) {
136 } else if (web::http::ciContains(headers[field], "close")) {
138 }
139 } else if (web::http::ciEquals(field, "Content-Length")) {
140 contentLength = std::stoul(value);
142 headers.erase("Transfer-Encoding");
143 } else if (web::http::ciEquals(field, "Transfer-Encoding")) {
144 if (web::http::ciContains(headers[field], "chunked")) {
146 headers.erase("Content-Length");
147 }
148 if (web::http::ciContains(headers[field], "compressed")) {
149 }
150 if (web::http::ciContains(headers[field], "deflate")) {
151 }
152 if (web::http::ciContains(headers[field], "gzip")) {
153 }
154 } else if (web::http::ciEquals(field, "Content-Encoding")) {
155 if (web::http::ciContains(headers[field], "compressed")) {
156 }
157 if (web::http::ciContains(headers[field], "deflate")) {
158 }
159 if (web::http::ciContains(headers[field], "gzip")) {
160 }
161 if (web::http::ciContains(headers[field], "br")) {
162 }
163 }
164 } else {
165 headers.erase(field);
166 }
167
168 return *this;
169 }
bool ciEquals(const std::string &str1, const std::string &str2)
bool ciContains(const std::string &str1, const std::string &str2)

References web::http::Chunked, web::http::ciContains(), web::http::ciEquals(), web::http::Close, connectionState, contentLength, headers, web::http::Identity, web::http::Keep, and transferEncoding.

Referenced by append(), web::websocket::server::SocketContextUpgradeFactory::create(), web::http::server::SocketContext::deliverRequest(), send(), send(), sendFile(), sendHeader(), set(), express::Response::set(), setTrailer(), type(), and upgrade().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTrailer()

Response & web::http::server::Response::setTrailer ( const std::string &  field,
const std::string &  value,
bool  overwrite = true 
)

Definition at line 191 of file Response.cpp.

191 {
192 if (!value.empty()) {
193 if (overwrite) {
194 trailer.insert_or_assign(field, value);
195 } else {
196 trailer.insert({field, value});
197 }
198 if (!headers.contains("Trailer")) {
199 set("Trailer", field);
200 } else {
201 headers["Trailer"].append("," + field);
202 }
203 } else {
204 trailer.erase(field);
205 }
206
207 return *this;
208 }

References headers, set(), and trailer.

Referenced by express::Response::setTrailer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ status()

Response & web::http::server::Response::status ( int  statusCode)

Definition at line 99 of file Response.cpp.

99 {
100 this->statusCode = statusCode;
101
102 return *this;
103 }

References statusCode.

Referenced by web::websocket::server::SocketContextUpgradeFactory::create(), sendFile(), sendStatus(), express::Response::status(), and upgrade().

Here is the caller graph for this function:

◆ stopResponse()

void web::http::server::Response::stopResponse ( )

Definition at line 82 of file Response.cpp.

82 {
83 stop();
84 }
void stop()
Definition Sink.cpp:68

References core::pipe::Sink::stop().

Referenced by web::http::server::SocketContext::onDisconnected().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ type()

Response & web::http::server::Response::type ( const std::string &  type)

Definition at line 171 of file Response.cpp.

171 {
172 return set("Content-Type", type);
173 }
Response & type(const std::string &type)
Definition Response.cpp:171

References set().

Referenced by express::Response::type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upgrade()

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 241 of file Response.cpp.

241 {
242 const std::string connectionName = socketContext->getSocketConnection()->getConnectionName();
243
244 std::string name;
245
246 LOG(DEBUG) << connectionName << " HTTP: Initiating upgrade: " << request->method << " " << request->url
247 << " HTTP/" + std::to_string(httpMajor) + "." + std::to_string(httpMinor) << "\n"
248 << httputils::toString(request->method,
249 request->url,
250 "HTTP/" + std::to_string(request->httpMajor) + "." + std::to_string(request->httpMinor),
251 request->queries,
252 request->headers,
253 request->cookies,
254 std::vector<char>());
255
256 if (socketContext != nullptr) {
257 if (request != nullptr) {
258 if (web::http::ciContains(request->get("connection"), "Upgrade")) {
259 SocketContextUpgradeFactory* socketContextUpgradeFactory =
261
262 if (socketContextUpgradeFactory != nullptr) {
263 name = socketContextUpgradeFactory->name();
264
265 LOG(DEBUG) << connectionName << " HTTP upgrade: SocketContextUpgradeFactory create success for: " << name;
266
267 core::socket::stream::SocketContext* socketContextUpgrade =
268 socketContextUpgradeFactory->create(socketContext->getSocketConnection());
269
270 if (socketContextUpgrade != nullptr) {
271 LOG(DEBUG) << connectionName << " HTTP upgrade: SocketContextUpgrade create success for: " << name;
272
273 socketContext->switchSocketContext(socketContextUpgrade);
274 } else {
275 LOG(DEBUG) << connectionName << " HTTP upgrade: SocketContextUpgrade create failed for: " << name;
276
277 set("Connection", "close").status(404);
278 }
279 } else {
280 LOG(DEBUG) << connectionName
281 << " SocketContextUpgradeFactory create failed for all of: " << request->get("upgrade");
282
283 set("Connection", "close").status(404);
284 }
285 } else {
286 LOG(DEBUG) << connectionName << " HTTP upgrade: No upgrade requested";
287
288 set("Connection", "close").status(400);
289 }
290 } else {
291 LOG(ERROR) << connectionName << " HTTP upgrade: Request has gone away";
292
293 set("Connection", "close").status(500);
294 }
295 } else {
296 LOG(ERROR) << connectionName << "HTTP upgrade: Unexpected disconnect";
297 }
298
299 LOG(DEBUG) << connectionName << " HTTP: Upgrade bootstrap " << (!name.empty() ? "success" : "failed");
300 LOG(DEBUG) << " Protocol selected: " << name;
301 LOG(DEBUG) << " requested: " << request->get("upgrade");
302 LOG(DEBUG) << " Subprotocol selected: " << header("upgrade");
303 LOG(DEBUG) << " requested: " << request->get("Sec-WebSocket-Protocol");
304
305 status(name);
306 }
const std::string & getConnectionName() const
SocketConnection * getSocketConnection() const
virtual void switchSocketContext(SocketContext *newSocketContext)
const std::string & header(const std::string &field)
Definition Response.cpp:464
SocketContextUpgradeFactory * select(Request &req, Response &res) override
std::string toString(const std::string &method, const std::string &url, const std::string &version, const web::http::CiStringMap< std::string > &queries, const web::http::CiStringMap< std::string > &header, const web::http::CiStringMap< std::string > &cookies, const std::vector< char > &body)

References web::http::ciContains(), web::http::server::Request::cookies, web::http::SocketContextUpgradeFactory< RequestT, ResponseT >::create(), web::http::server::Request::get(), core::socket::stream::SocketConnection::getConnectionName(), core::socket::stream::SocketContext::getSocketConnection(), header(), web::http::server::Request::headers, web::http::server::Request::httpMajor, httpMajor, web::http::server::Request::httpMinor, httpMinor, web::http::server::SocketContextUpgradeFactorySelector::instance(), web::http::server::Request::method, web::http::SocketContextUpgradeFactory< RequestT, ResponseT >::name(), web::http::server::Request::queries, web::http::server::SocketContextUpgradeFactorySelector::select(), set(), socketContext, status(), core::socket::stream::SocketContext::switchSocketContext(), httputils::toString(), and web::http::server::Request::url.

Referenced by express::Response::upgrade().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ SocketContext

friend class SocketContext
friend

Definition at line 138 of file Response.h.

Member Data Documentation

◆ connectionState

ConnectionState web::http::server::Response::connectionState = ConnectionState::Default
private

Definition at line 135 of file Response.h.

Referenced by init(), web::http::server::SocketContext::responseCompleted(), and set().

◆ contentLength

std::size_t web::http::server::Response::contentLength = 0
private

Definition at line 131 of file Response.h.

Referenced by init(), sendCompleted(), sendFragment(), and set().

◆ contentSent

std::size_t web::http::server::Response::contentSent = 0
private

Definition at line 130 of file Response.h.

Referenced by init(), sendCompleted(), and sendFragment().

◆ cookies

web::http::CiStringMap<web::http::CookieOptions> web::http::server::Response::cookies
protected

Definition at line 126 of file Response.h.

Referenced by cookie(), init(), and sendHeader().

◆ headers

web::http::CiStringMap<std::string> web::http::server::Response::headers
protected

Definition at line 125 of file Response.h.

Referenced by append(), header(), init(), sendHeader(), set(), and setTrailer().

◆ httpMajor

◆ httpMinor

◆ socketContext

web::http::server::SocketContext* web::http::server::Response::socketContext = nullptr
private

◆ statusCode

int web::http::server::Response::statusCode = 200

Definition at line 120 of file Response.h.

Referenced by init(), sendHeader(), and status().

◆ trailer

web::http::CiStringMap<std::string> web::http::server::Response::trailer
protected

Definition at line 127 of file Response.h.

Referenced by init(), sendCompleted(), and setTrailer().

◆ transferEncoding

TransferEncoding web::http::server::Response::transferEncoding = TransferEncoding::HTTP10
private

Definition at line 136 of file Response.h.

Referenced by init(), sendCompleted(), sendFragment(), and set().


The documentation for this class was generated from the following files: