76 Request(
Method RequestMethod =
Get,
const std::string& URI =
"/",
const std::string& Body =
"");
85 void SetField(
const std::string& Field,
const std::string& Value);
135 std::string ToString()
const;
145 bool HasField(
const std::string& Field)
const;
150 typedef std::map<std::string, std::string> FieldTable;
158 unsigned int myMajorVersion;
159 unsigned int myMinorVersion;
221 const std::string&
GetField(
const std::string& Field)
const;
269 void FromString(
const std::string& Data);
274 typedef std::map<std::string, std::string> FieldTable;
281 unsigned int myMajorVersion;
282 unsigned int myMinorVersion;
299 Http(
const std::string& Host,
unsigned short Port = 0);
308 void SetHost(
const std::string& Host,
unsigned short Port = 0);
333 std::string myHostName;
334 unsigned short myPort;
This class wraps an HTTP request, which is basically :
void SetField(const std::string &Field, const std::string &Value)
Set the value of a field; the field is added if it doesn't exist.
void SetBody(const std::string &Body)
Set the body of the request.
void SetMethod(Method RequestMethod)
Set the request method.
void SetURI(const std::string &URI)
Set the target URI of the request.
Method
Enumerate the available HTTP methods for a request.
@ Head
Request a page's header only.
@ Get
Request in get mode, standard method to retrieve a page.
@ Post
Request in post mode, usually to send data to a page.
Request(Method RequestMethod=Get, const std::string &URI="/", const std::string &Body="")
Default constructor.
void SetHttpVersion(unsigned int Major, unsigned int Minor)
Set the HTTP version of the request.
This class wraps an HTTP response, which is basically :
Status GetStatus() const
Get the header's status code.
Response()
Default constructor.
const std::string & GetField(const std::string &Field) const
Get the value of a field.
Status
Enumerate all the valid status codes returned in a HTTP response.
@ Ok
Most common code returned when operation was successful.
@ MovedTemporarily
The requested page has temporarily moved to a new location.
@ NotModified
For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed.
@ Created
The resource has successfully been created.
@ InvalidResponse
Response is not a valid HTTP one.
@ MovedPermanently
The requested page has permanently moved to a new location.
@ BadRequest
The server couldn't understand the request (syntax error).
@ Forbidden
The requested page cannot be accessed at all, even with authentification.
@ NotImplemented
The server doesn't implement a requested feature.
@ ConnectionFailed
Connection with server failed.
@ BadGateway
The gateway server has received an error from the source server.
@ Unauthorized
The requested page needs an authentification to be accessed.
@ ServiceNotAvailable
The server is temporarily unavailable (overloaded, in maintenance, ...).
@ Accepted
The request has been accepted, but will be processed later by the server.
@ InternalServerError
The server encountered an unexpected error.
@ MultipleChoices
The requested page can be accessed from several locations.
@ NoContent
Sent when the server didn't send any data in return.
@ NotFound
The requested page doesn't exist.
const std::string & GetBody() const
Get the body of the response.
unsigned int GetMinorHttpVersion() const
Get the major HTTP version number of the response.
unsigned int GetMajorHttpVersion() const
Get the major HTTP version number of the response.
void SetHost(const std::string &Host, unsigned short Port=0)
Set the target host.
Http(const std::string &Host, unsigned short Port=0)
Construct the Http instance with the target host.
Http()
Default constructor.
Response SendRequest(const Request &Req, float Timeout=0.f)
Send a HTTP request and return the server's response.
IPAddress provides easy manipulation of IP v4 addresses.
SocketTCP wraps a socket using TCP protocol to send data safely (but a bit slower).
NonCopyable()
The default constructor won't be generated, so provide it.