Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::HttpResponse Struct Reference

Outgoing message from the perspective of the participants of an HTTP transaction. More...

#include <HttpConnection.h>

Public Member Functions

Result startResponse (int httpCode)
 Starts the response with a http standard code (200 OK, 404 NOT FOUND etc.)
 
Result addHeader (StringSpan headerName, StringSpan headerValue)
 Writes an http header to this response.
 
Result sendHeaders ()
 Start sending response headers, before sending any data.
 
void reset ()
 Resets this object for it to be re-usable.
 
Result end ()
 Finalizes the writable stream after sending all in progress writes.
 
AsyncWritableStreamgetWritableStream ()
 Obtain writable stream for sending content back to connected client.
 
void setKeepAlive (bool keepAlive)
 Sets whether to keep the connection alive after this response.
 
bool getKeepAlive () const
 Gets whether the connection should be kept alive after this response.
 

Friends

struct HttpConnectionsPool
 
struct HttpAsyncServer
 

Detailed Description

Outgoing message from the perspective of the participants of an HTTP transaction.

Member Function Documentation

◆ addHeader()

Result SC::HttpResponse::addHeader ( StringSpan headerName,
StringSpan headerValue )

Writes an http header to this response.

Returns
Valid Result if header was added successfully.
Warning
Adding a "Connection" header can fail if keep-alive has been force disabled

◆ end()

Result SC::HttpResponse::end ( )

Finalizes the writable stream after sending all in progress writes.

◆ getKeepAlive()

bool SC::HttpResponse::getKeepAlive ( ) const
inlinenodiscard

Gets whether the connection should be kept alive after this response.

Returns
true if connection should be kept alive

◆ getWritableStream()

AsyncWritableStream & SC::HttpResponse::getWritableStream ( )
inline

Obtain writable stream for sending content back to connected client.

◆ reset()

void SC::HttpResponse::reset ( )

Resets this object for it to be re-usable.

◆ sendHeaders()

Result SC::HttpResponse::sendHeaders ( )

Start sending response headers, before sending any data.

◆ setKeepAlive()

void SC::HttpResponse::setKeepAlive ( bool keepAlive)

Sets whether to keep the connection alive after this response.

Parameters
keepAlivetrue to keep connection open for more requests, false to close after response
Warning
HttpConnection can force disable keep-alive when running out of connections to prevent server deadlock

◆ startResponse()

Result SC::HttpResponse::startResponse ( int httpCode)

Starts the response with a http standard code (200 OK, 404 NOT FOUND etc.)


The documentation for this struct was generated from the following file: