31#include <SFML/System/NonCopyable.hpp>
32#include <SFML/Network/IPAddress.hpp>
33#include <SFML/Network/SocketTCP.hpp>
76 Request(Method RequestMethod = Get,
const std::string& URI =
"/",
const std::string& Body =
"");
85 void SetField(
const std::string& Field,
const std::string& Value);
94 void SetMethod(Method RequestMethod);
103 void SetURI(
const std::string& URI);
113 void SetHttpVersion(
unsigned int Major,
unsigned int Minor);
123 void SetBody(
const std::string& Body);
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;
229 Status GetStatus()
const;
237 unsigned int GetMajorHttpVersion()
const;
245 unsigned int GetMinorHttpVersion()
const;
257 const std::string& GetBody()
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);
324 Response SendRequest(
const Request& Req,
float Timeout = 0.f);
333 std::string myHostName;
334 unsigned short myPort;
This class wraps an HTTP request, which is basically :
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.
This class wraps an HTTP response, which is basically :
Response()
Default constructor.
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.
This class provides methods for manipulating the HTTP protocol (described in RFC 1945).
Http()
Default constructor.
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.