Define a HTTP response. More...
#include <Http.hpp>
Public Types | |
enum | Status { Ok = 200, Created = 201, Accepted = 202, NoContent = 204, ResetContent = 205, PartialContent = 206, MultipleChoices = 300, MovedPermanently = 301, MovedTemporarily = 302, NotModified = 304, BadRequest = 400, Unauthorized = 401, Forbidden = 403, NotFound = 404, RangeNotSatisfiable = 407, InternalServerError = 500, NotImplemented = 501, BadGateway = 502, ServiceNotAvailable = 503, GatewayTimeout = 504, VersionNotSupported = 505, InvalidResponse = 1000, ConnectionFailed = 1001 } |
Enumerate all the valid status codes for a response. More... | |
Public Member Functions | |
Response () | |
Default constructor. More... | |
const std::string & | getField (const std::string &field) const |
Get the value of a field. More... | |
Status | getStatus () const |
Get the response status code. More... | |
unsigned int | getMajorHttpVersion () const |
Get the major HTTP version number of the response. More... | |
unsigned int | getMinorHttpVersion () const |
Get the minor HTTP version number of the response. More... | |
const std::string & | getBody () const |
Get the body of the response. More... | |
Friends | |
class | Http |
Enumerate all the valid status codes for a response.
Enumerator | |
---|---|
Ok |
Most common code returned when operation was successful. |
Created |
The resource has successfully been created. |
Accepted |
The request has been accepted, but will be processed later by the server. |
NoContent |
The server didn't send any data in return. |
ResetContent |
The server informs the client that it should clear the view (form) that caused the request to be sent. |
PartialContent |
The server has sent a part of the resource, as a response to a partial GET request. |
MultipleChoices |
The requested page can be accessed from several locations. |
MovedPermanently |
The requested page has permanently moved to a new location. |
MovedTemporarily |
The requested page has temporarily moved to a new location. |
NotModified |
For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed. |
BadRequest |
The server couldn't understand the request (syntax error) |
Unauthorized |
The requested page needs an authentication to be accessed. |
Forbidden |
The requested page cannot be accessed at all, even with authentication. |
NotFound |
The requested page doesn't exist. |
RangeNotSatisfiable |
The server can't satisfy the partial GET request (with a "Range" header field) |
InternalServerError |
The server encountered an unexpected error. |
NotImplemented |
The server doesn't implement a requested feature. |
BadGateway |
The gateway server has received an error from the source server. |
ServiceNotAvailable |
The server is temporarily unavailable (overloaded, in maintenance, ...) |
GatewayTimeout |
The gateway server couldn't receive a response from the source server. |
VersionNotSupported |
The server doesn't support the requested HTTP version. |
InvalidResponse |
Response is not a valid HTTP one. |
ConnectionFailed |
Connection with server failed. |
sf::Http::Response::Response | ( | ) |
Default constructor.
Constructs an empty response.
const std::string& sf::Http::Response::getBody | ( | ) | const |
Get the body of the response.
The body of a response may contain:
const std::string& sf::Http::Response::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.
field | Name of the field to get |
unsigned int sf::Http::Response::getMajorHttpVersion | ( | ) | const |
Get the major HTTP version number of the response.
unsigned int sf::Http::Response::getMinorHttpVersion | ( | ) | const |
Get the minor HTTP version number of the response.
Status sf::Http::Response::getStatus | ( | ) | const |
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).