Sets the request’s user agent. Defaults to not sending the User-Agent: header.
Class WebRequest
#include <Geode/utils/web.hpp>
Examples0
Public static methods0
Public member functions32
geode::utils::web::WebTasksend(std::string_viewmethod,)
geode::utils::web::WebTaskpost()
geode::utils::web::WebTaskget()
geode::utils::web::WebTaskput()
geode::utils::web::WebTaskpatch()
geode::utils::web::WebRequest&header(std::string_viewname,std::string_viewvalue)
geode::utils::web::WebRequest&removeHeader(std::string_viewname)
geode::utils::web::WebRequest¶m(std::string_viewname,std::string_viewvalue)
template<integral T>geode::utils::web::WebRequest¶m(std::string_viewname,Tvalue)
geode::utils::web::WebRequest&removeParam(std::string_viewname)
geode::utils::web::WebRequest&userAgent(std::string_viewname)
name
geode::utils::web::WebRequest&acceptEncoding(std::string_viewencodingType)
Sets the response’s encoding. Valid values include: br, gzip, deflate, … You can set multiple encoding types by calling this method with a comma separated list of the encodings of your choosing. Defaults to not sending an Accept-Encoding: header, and in turn, does not decompress received contents automatically.
encodingType
auto req = web::WebRequest()
.acceptEncoding("gzip, deflate")
.get(url);
geode::utils::web::WebRequest&timeout()
Sets the maximum amount of seconds to allow the entire transfer operation to take. The default timeout is 0, which means the request never times out during transfer.
time
geode::utils::web::WebRequest&downloadRange()
Sets the target byte range to request. Defaults to receiving the full request.
byteRange
geode::utils::web::WebRequest&certVerification(boolenabled)
Enable or disables peer verification in SSL handshake. The default is true.
enabled
geode::utils::web::WebRequest&transferBody(boolenabled)
Enables or disabled getting the body of a request. For HTTP(S), this does a HEAD request. For most other protocols it means just not asking to transfer the body data. The default is true.
enabled
geode::utils::web::WebRequest&followRedirects(boolenabled)
Follow HTTP 3xx redirects. The default is true.
enabled
geode::utils::web::WebRequest&ignoreContentLength(boolenabled)
Enables or disables ignoring the content length header. The default is false.
enabled
geode::utils::web::WebRequest&CABundleContent(std::string_viewcontent)
Sets the Certificate Authority (CA) bundle content. Defaults to not sending a CA bundle.
content
geode::utils::web::WebRequest&proxyOpts(geode::utils::web::ProxyOptsconst&proxyOpts)
Sets the request’s proxy. Defaults to not using a proxy.
proxyOpts
geode::utils::web::WebRequest&version(geode::utils::web::HttpVersionhttpVersion)
Sets the request’s HTTP version. The default is HttpVersion::VERSION_2TLS.
httpVersion
geode::utils::web::WebRequest&body()
Sets the body of the request to a byte vector.
raw
geode::utils::web::WebRequest&bodyString()
Sets the body of the request to a string.
str
geode::utils::web::WebRequest&bodyJSON()
Sets the body of the request to a json object.
json
_::size_tgetID()const
Gets the unique request ID
std::stringgetMethod()const
Gets the request method as a string
std::stringgetUrl()const
Gets the request URL
std::unordered_map<std::string,std::string>getHeaders()const
Gets the request headers
std::unordered_map<std::string,std::string>getUrlParams()const
Gets the parameters inside the URL
std::optional<geode::ByteVector>getBody()const
Gets the post body stream
std::optional<std::chrono::seconds>getTimeout()const
Gets the request timeout in seconds
geode::utils::web::HttpVersiongetHttpVersion()const
Gets HTTP versions applied to the request