Sets the request’s method. Overwritten unless set in an interceptor. Generally speaking use get/post/etc. instead.
Class WebRequest
#include <Geode/utils/web.hpp>Examples0
Public static methods0
Public member functions43
geode::utils::web::WebFuturesend(std::stringmethod,std::stringurl,geode::Mod*mod)
geode::utils::web::WebFuturepost(std::stringurl,geode::Mod*mod)
geode::utils::web::WebFutureget(std::stringurl,geode::Mod*mod)
geode::utils::web::WebFutureput(std::stringurl,geode::Mod*mod)
geode::utils::web::WebFuturepatch(std::stringurl,geode::Mod*mod)
geode::utils::web::WebResponsesendSync(std::stringmethod,std::stringurl,geode::Mod*mod)
geode::utils::web::WebResponsepostSync(std::stringurl,geode::Mod*mod)
geode::utils::web::WebResponsegetSync(std::stringurl,geode::Mod*mod)
geode::utils::web::WebResponseputSync(std::stringurl,geode::Mod*mod)
geode::utils::web::WebResponsepatchSync(std::stringurl,geode::Mod*mod)
geode::utils::web::WebRequest&header(std::stringname,std::stringvalue)
geode::utils::web::WebRequest&removeHeader(std::string_viewname)
geode::utils::web::WebRequest¶m(std::stringname,std::stringvalue)
template<integral T>geode::utils::web::WebRequest¶m(std::stringname,Tvalue)
geode::utils::web::WebRequest&removeParam(std::string_viewname)
geode::utils::web::WebRequest&method(std::stringmethod)
method
geode::utils::web::WebRequest&url(std::stringurl)
Sets the request’s URL. Overwritten unless set in an interceptor. Generally speaking use get/post/etc. instead.
url
geode::utils::web::WebRequest&userAgent(std::stringname)
Sets the request’s user agent. Defaults to not sending the User-Agent: header.
name
geode::utils::web::WebRequest&acceptEncoding(std::stringencodingType)
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::stringcontent)
Sets the Certificate Authority (CA) bundle content. Defaults to sending the Geode CA bundle, found here: https://github.com/geode-sdk/net_libs/blob/main/ca_bundle.h
content
geode::utils::web::WebRequest&proxyOpts(geode::utils::web::ProxyOptsproxyOpts)
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::DEFAULT.
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
geode::utils::web::WebRequest&bodyMultipart()
Sets the body of the request to a multipart form.
form
geode::utils::web::WebRequest&onProgress()
Sets the function that will be called when progress is made on the request. This is an alternative to manually polling it via getProgress().
size_tgetID()const
Gets the unique request ID
geode::Mod*getMod()const
Gets the mod which owns the request.
geode::ZStringViewgetMethod()const
Gets the request method as a string
geode::ZStringViewgetUrl()const
Gets the request URL
std::unordered_map<std::vector<std::string>>const&getHeaders()const
Gets the request headers
std::unordered_map<std::string>const&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
geode::utils::web::WebProgressgetProgress()const
Gets the current progress of the request, if it was sent. Otherwise, default values are returned.