PL::HttpServerTransaction class
-
class HttpServerTransaction
HTTP/HTTPS server transaction class.
Public Functions
-
virtual std::shared_ptr<NetworkStream> GetNetworkStream() = 0
Gets the transaction network stream.
- Returns:
network stream
-
virtual esp_err_t ReadRequestBody(void *dest, size_t size) = 0
Reads the request body.
- Parameters:
dest – destination (can be NULL)
size – number of bytes to read
- Returns:
error code
-
virtual esp_err_t WriteResponse(uint16_t statusCode, const void *body, size_t bodySize) = 0
Writes the response.
- Parameters:
statusCode – status code
body – body
bodySize – body size
- Returns:
error code
-
esp_err_t WriteResponse(uint16_t statusCode, const std::string &body)
Writes the response.
- Parameters:
statusCode – status code
body – body
- Returns:
error code
-
esp_err_t WriteResponse(const void *body, size_t bodySize)
Writes the response with the status code 200.
- Parameters:
body – body
bodySize – body size
- Returns:
error code
-
esp_err_t WriteResponse(const std::string &body)
Writes the response with the status code 200.
- Parameters:
body – body
- Returns:
error code
-
esp_err_t WriteResponse(uint16_t statusCode)
Writes the response with no body.
- Parameters:
statusCode – status code
- Returns:
error code
-
virtual HttpMethod GetRequestMethod() = 0
Gets the request HTTP method.
- Returns:
HTTP method
-
virtual const char *GetRequestUri() = 0
Gets the request URI.
- Returns:
URI
-
virtual const char *GetRequestHeader(const std::string &name) = 0
Gets the request header value.
- Parameters:
name – header name
- Returns:
header value (NULL if no such header in the request)
-
virtual size_t GetRequestBodySize() = 0
Gets the request body size.
- Returns:
body size
-
virtual esp_err_t SetResponseHeader(const std::string &name, const std::string &value) = 0
Sets the response header.
- Parameters:
name – header name
value – header value
- Returns:
error code
-
virtual std::shared_ptr<NetworkStream> GetNetworkStream() = 0