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);
109 void setMethod(Method method);
121 void setUri(
const std::string& uri);
132 void setHttpVersion(
unsigned int major,
unsigned int minor);
144 void setBody(
const std::string& body);
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;
270 Status getStatus()
const;
280 unsigned int getMajorHttpVersion()
const;
290 unsigned int getMinorHttpVersion()
const;
304 const std::string& getBody()
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);
405 Response sendRequest(
const Request& request,
Time timeout =
Time::Zero);
414 std::string m_hostName;
415 unsigned short m_port;
421 #endif // SFML_HTTP_HPP Request in put mode, useful for a REST API.
static const Time Zero
Predefined "zero" time value.
Request in get mode, standard method to retrieve a page.
Status
Enumerate all the valid status codes for a response.
Encapsulate an IPv4 network address.
Utility class that makes any derived class non-copyable.
Method
Enumerate the available HTTP methods for a request.
Specialized socket using the TCP protocol.
Request a page's header only.
Request in post mode, usually to send data to a page.