Class HTTP::Response#
Defined in File HTTP.h
Nested Relationships#
This class is a nested type of Class HTTP.
Class Documentation#
-
class Response
Define a HTTP response.
Public Types
-
enum class Status
Enumerate all the valid status codes for a response.
Values:
-
enumerator OK
-
enumerator Created
-
enumerator Accepted
-
enumerator NoContent
-
enumerator ResetContent
-
enumerator PartialContent
-
enumerator MultipleChoices
-
enumerator MovedPermanently
-
enumerator MovedTemporarily
-
enumerator NotModified
-
enumerator BadRequest
-
enumerator Unauthorized
-
enumerator Forbidden
-
enumerator NotFound
-
enumerator RangeNotSatisfiable
-
enumerator InternalServerError
-
enumerator NotImplemented
-
enumerator BadGateway
-
enumerator ServiceNotAvailable
-
enumerator GatewayTimeout
-
enumerator VersionNotSupported
-
enumerator InvalidResponse
-
enumerator ConnectionFailed
-
enumerator OK
Public Functions
-
Response() noexcept
Constructor.
-
Response(const Response&) = default
Copy constructor.
-
Response(Response&&) noexcept = default
Move constructor.
-
~Response() = default
Destructor.
-
std::string GetField(const std::string &field) const
Get the value of a field.
If the field field is not found in the response header, the empty string is returned. This function uses case-insensitive comparisons.
- Parameters:
field – Name of the field to get.
- Returns:
Value of the field, or empty string if not found.
-
constexpr Status GetStatus() const noexcept
Get the response status code.
The status code should be the first thing to be checked after receiving a response, it defines whether it is a success, a failure or anything else (see the Status enumeration).
- Returns:
Status code of the response.
-
constexpr u32 GetMajorHTTPVersion() const noexcept
Get the major HTTP version number of the response.
- Returns:
Major HTTP version number.
-
constexpr u32 GetMinorHTTPVersion() const noexcept
Get the minor HTTP version number of the response.
- Returns:
Minor HTTP version number.
-
constexpr std::string GetBody() const noexcept
Get the body of the response.
The body of a response may contain:
the requested page (for GET requests)
a response from the server (for POST requests)
nothing (for HEAD requests)
an error message (in case of an error)
- Returns:
The response body.
-
enum class Status