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;
421 #endif // SFML_HTTP_HPP
@ Get
Request in get mode, standard method to retrieve a page.
Http(const std::string &host, unsigned short port=0)
Construct the HTTP client with the target host.
unsigned int getMajorHttpVersion() const
Get the major HTTP version number of the response.
@ Head
Request a page's header only.
void setHost(const std::string &host, unsigned short port=0)
Set the target host.
Status
Enumerate all the valid status codes for a response.
Request(const std::string &uri="/", Method method=Get, const std::string &body="")
Default constructor.
Response sendRequest(const Request &request, Time timeout=Time::Zero)
Send a HTTP request and return the server's response.
Encapsulate an IPv4 network address.
void setUri(const std::string &uri)
Set the requested URI.
void setBody(const std::string &body)
Set the body of the request.
void setHttpVersion(unsigned int major, unsigned int minor)
Set the HTTP version for the request.
unsigned int getMinorHttpVersion() const
Get the minor HTTP version number of the response.
void setMethod(Method method)
Set the request method.
Response()
Default constructor.
static const Time Zero
Predefined "zero" time value.
Status getStatus() const
Get the response status code.
Http()
Default constructor.
Specialized socket using the TCP protocol.
Utility class that makes any derived class non-copyable.
@ Post
Request in post mode, usually to send data to a page.
@ Put
Request in put mode, useful for a REST API.
void setField(const std::string &field, const std::string &value)
Set the value of a field.
const std::string & getField(const std::string &field) const
Get the value of a field.
Method
Enumerate the available HTTP methods for a request.
const std::string & getBody() const
Get the body of the response.