31#include <SFML/Network/Export.hpp>
32#include <SFML/Network/IpAddress.hpp>
33#include <SFML/Network/TcpSocket.hpp>
34#include <SFML/System/NonCopyable.hpp>
35#include <SFML/System/Time.hpp>
82 Request(
const std::string& uri =
"/",
Method method = Get,
const std::string& body =
"");
97 void setField(
const std::string& field,
const std::string& value);
159 std::string prepare()
const;
171 bool hasField(
const std::string& field)
const;
176 typedef std::map<std::string, std::string> FieldTable;
184 unsigned int m_majorVersion;
185 unsigned int m_minorVersion;
209 PartialContent = 206,
212 MultipleChoices = 300,
213 MovedPermanently = 301,
214 MovedTemporarily = 302,
222 RangeNotSatisfiable = 407,
225 InternalServerError = 500,
226 NotImplemented = 501,
228 ServiceNotAvailable = 503,
229 GatewayTimeout = 504,
230 VersionNotSupported = 505,
233 InvalidResponse = 1000,
234 ConnectionFailed = 1001
257 const std::string&
getField(
const std::string& field)
const;
319 void parse(
const std::string& data);
331 void parseFields(std::istream &in);
336 typedef std::map<std::string, std::string> FieldTable;
343 unsigned int m_majorVersion;
344 unsigned int m_minorVersion;
368 Http(
const std::string& host,
unsigned short port = 0);
385 void setHost(
const std::string& host,
unsigned short port = 0);
414 std::string m_hostName;
415 unsigned short m_port;
void setUri(const std::string &uri)
Set the requested URI.
Method
Enumerate the available HTTP methods for a request.
@ Head
Request a page's header only.
@ Put
Request in put mode, useful for a REST API.
@ Get
Request in get mode, standard method to retrieve a page.
@ Post
Request in post mode, usually to send data to a page.
Request(const std::string &uri="/", Method method=Get, const std::string &body="")
Default constructor.
void setHttpVersion(unsigned int major, unsigned int minor)
Set the HTTP version for the request.
void setMethod(Method method)
Set the request method.
void setBody(const std::string &body)
Set the body of the request.
void setField(const std::string &field, const std::string &value)
Set the value of a field.
Response()
Default constructor.
Status getStatus() const
Get the response status code.
Status
Enumerate all the valid status codes for a response.
unsigned int getMajorHttpVersion() const
Get the major HTTP version number of the response.
const std::string & getBody() const
Get the body of the response.
const std::string & getField(const std::string &field) const
Get the value of a field.
unsigned int getMinorHttpVersion() const
Get the minor 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 client with the target host.
Response sendRequest(const Request &request, Time timeout=Time::Zero)
Send a HTTP request and return the server's response.
Http()
Default constructor.
Encapsulate an IPv4 network address.
Utility class that makes any derived class non-copyable.
Specialized socket using the TCP protocol.