ASL
|
An HTTP request that servers can read from.
An HttpRequest has a method (such as GET or POST), optional headers, and optional body. The body can be a String, a ByteArray or a Var. In the case of a Var it will be encoded as JSON and the request content type header automatically set.
#include <Http.h>
Public Member Functions | |
HttpRequest (const String &method, const String &url) | |
Constructs an HttpRequest with the given method. | |
HttpRequest (const String &method, const String &url, const Dic<> &headers) | |
Constructs an HttpRequest with the given method and headers. | |
template<class T > | |
HttpRequest (const String &method, const String &url, const T &data) | |
Constructs an HttpRequest with the given method and body (a String, a ::ByteArray, a Var (sent as JSON) or a File) | |
template<class T > | |
HttpRequest (const String &method, const String &url, const T &data, const Dic<> &headers) | |
Constructs an HttpRequest with the given method, headers and body (a String, a ::ByteArray, a Var (sent as JSON) or a File) | |
const String & | method () const |
Returns the HTTP method (GET, POST, etc) | |
const String & | url () const |
Returns the destination URL. | |
bool | is (const char *meth, const String &pat) |
Returns true if the method is meth and the path matches pat. | |
bool | is (const String &pat) |
Returns true if the path matches pat. More... | |
const String & | suffix () |
After a call to is() returns the part of the path that substitutes the * in the pattern. | |
const InetAddress & | sender () |
Returns the address of the remote host (the client) | |
const String & | querystring () const |
Returns the complete query string that follows the ? character in the URL path. | |
const Dic & | query () |
Returns the query converted to a Dic, assuming that it consists of keys and values like key1=value1&key2=value2 . | |
const String & | query (const String &key) |
Returns the unescaped value associated with the named key in the query; For example if the query was key1=value1&key2=value2%26 , then request.query("key2") would return "value1&". | |
HttpRequest & | setFollowRedirects (bool enable) |
Enables or disables automatic HTTP redirection. | |
bool is | ( | const String & | pat | ) |
Returns true if the path matches pat.
pat can be a fixed path name or a pattern including a *
wildcard such as "/api/clients/ *"
.