Outgoing HTTP response sent by the server. 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 | startResponse (int httpCode, StringSpan reasonPhrase) |
| Starts the response with an explicit status code and reason phrase. | |
| Result | startBody (int httpCode, uint64_t contentLength, StringSpan contentType={}) |
| Starts a fixed-size body response and adds Content-Length plus optional Content-Type. | |
| Result | sendBytes (int httpCode, Span< const char > body, StringSpan contentType={}) |
| Sends a caller-owned fixed-size byte response. | |
| Result | sendBody (int httpCode, StringSpan body, StringSpan contentType={}) |
| Sends a caller-owned fixed-size body response. | |
| Result | sendText (int httpCode, StringSpan body) |
| Sends a caller-owned text/plain; charset=utf-8 response body. | |
| Result | sendEmpty (int httpCode) |
Sends an empty response with Content-Length: 0. | |
Public Member Functions inherited from SC::HttpOutgoingMessage | |
| Result | addHeader (StringSpan headerName, StringSpan headerValue) |
| Writes an http header to this response. | |
| Result | addContentLength (uint64_t value) |
Adds a formatted Content-Length header without caller-side temporary formatting. | |
| Result | setChunkedTransferEncoding () |
| Enables chunked transfer-encoding for subsequent body writes. | |
| Result | sendHeaders (Function< void(AsyncBufferView::ID)> callback={}) |
| 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. | |
| AsyncWritableStream & | getWritableStream () |
| 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 |
Additional Inherited Members | |
Protected Types inherited from SC::HttpOutgoingMessage | |
| enum class | KnownHeader : uint8_t { Connection , Host , UserAgent , ContentLength , ContentType , TransferEncoding , ContentEncoding , AcceptEncoding } |
Protected Member Functions inherited from SC::HttpOutgoingMessage | |
| void | setHeaderMemory (Span< char > memory) |
| void | setWritableStream (AsyncWritableStream &stream) |
| bool | hasHeader (KnownHeader header) const |
| bool | hasSentHeaders () const |
| bool | hasEnded () const |
| bool | isChunkedTransferEncodingEnabled () const |
Protected Attributes inherited from SC::HttpOutgoingMessage | |
| HttpFixedBufferWriter | responseHeaders |
| Span< char > | headerMemory |
| bool | headersSent = false |
| bool | endCalled = false |
| bool | forceDisableKeepAlive = false |
| Whether keep alive has been force disabled permanently. | |
| bool | keepAlive = true |
| Whether to keep connection alive (HTTP/1.1 default) | |
| bool | connectionHeaderAdded = false |
| Whether Connection header was manually added. | |
| bool | hostHeaderAdded = false |
| bool | userAgentHeaderAdded = false |
| bool | contentLengthAdded = false |
| bool | contentTypeAdded = false |
| bool | transferEncodingAdded = false |
| bool | contentEncodingAdded = false |
| bool | acceptEncodingAdded = false |
| bool | chunkedTransferEncodingEnabled = false |
| AsyncWritableStream * | destinationStream = nullptr |
| AsyncWritableStream * | writableStream = nullptr |
| ChunkedWritableStream | chunkedWritableStream |
Outgoing HTTP response sent by the server.
| Result SC::HttpResponse::sendBody | ( | int | httpCode, |
| StringSpan | body, | ||
| StringSpan | contentType = {} ) |
Sends a caller-owned fixed-size body response.
| Result SC::HttpResponse::sendBytes | ( | int | httpCode, |
| Span< const char > | body, | ||
| StringSpan | contentType = {} ) |
Sends a caller-owned fixed-size byte response.
| Result SC::HttpResponse::sendEmpty | ( | int | httpCode | ) |
Sends an empty response with Content-Length: 0.
| Result SC::HttpResponse::sendText | ( | int | httpCode, |
| StringSpan | body ) |
Sends a caller-owned text/plain; charset=utf-8 response body.
| Result SC::HttpResponse::startBody | ( | int | httpCode, |
| uint64_t | contentLength, | ||
| StringSpan | contentType = {} ) |
Starts a fixed-size body response and adds Content-Length plus optional Content-Type.
| Result SC::HttpResponse::startResponse | ( | int | httpCode | ) |
Starts the response with a http standard code (200 OK, 404 NOT FOUND etc.)
| Result SC::HttpResponse::startResponse | ( | int | httpCode, |
| StringSpan | reasonPhrase ) |
Starts the response with an explicit status code and reason phrase.