Sets the request’s method. Overwritten unless set in an interceptor. Generally speaking use get/post/etc. instead.
Class WebRequest
#include <Noahh/utils/web.hpp>Examples0
Public static methods0
Public member functions43
noahh::utils::web::WebFuturesend(std::stringmethod,std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebFuturepost(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebFutureget(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebFutureput(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebFuturepatch(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebResponsesendSync(std::stringmethod,std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebResponsepostSync(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebResponsegetSync(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebResponseputSync(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebResponsepatchSync(std::stringurl,noahh::Mod*mod)
noahh::utils::web::WebRequest&header(std::stringname,std::stringvalue)
noahh::utils::web::WebRequest&removeHeader(std::string_viewname)
noahh::utils::web::WebRequest¶m(std::stringname,std::stringvalue)
template<integral T>noahh::utils::web::WebRequest¶m(std::stringname,Tvalue)
noahh::utils::web::WebRequest&removeParam(std::string_viewname)
noahh::utils::web::WebRequest&method(std::stringmethod)
method
noahh::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
noahh::utils::web::WebRequest&userAgent(std::stringname)
Sets the request’s user agent. Defaults to not sending the User-Agent: header.
name
noahh::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);noahh::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
noahh::utils::web::WebRequest&downloadRange()
Sets the target byte range to request. Defaults to receiving the full request.
byteRange
noahh::utils::web::WebRequest&certVerification(boolenabled)
Enable or disables peer verification in SSL handshake. The default is true.
enabled
noahh::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
noahh::utils::web::WebRequest&followRedirects(boolenabled)
Follow HTTP 3xx redirects. The default is true.
enabled
noahh::utils::web::WebRequest&ignoreContentLength(boolenabled)
Enables or disables ignoring the content length header. The default is false.
enabled
noahh::utils::web::WebRequest&CABundleContent(std::stringcontent)
Sets the Certificate Authority (CA) bundle content. Defaults to sending the Noahh CA bundle, found here: https://github.com/noahh-sdk/net_libs/blob/main/ca_bundle.h
content
noahh::utils::web::WebRequest&proxyOpts(noahh::utils::web::ProxyOptsproxyOpts)
Sets the request’s proxy. Defaults to not using a proxy.
proxyOpts
noahh::utils::web::WebRequest&version(noahh::utils::web::HttpVersionhttpVersion)
Sets the request’s HTTP version. The default is HttpVersion::DEFAULT.
httpVersion
noahh::utils::web::WebRequest&body()
Sets the body of the request to a byte vector.
raw
noahh::utils::web::WebRequest&bodyString()
Sets the body of the request to a string.
str
noahh::utils::web::WebRequest&bodyJSON()
Sets the body of the request to a json object.
json
noahh::utils::web::WebRequest&bodyMultipart()
Sets the body of the request to a multipart form.
form
noahh::utils::web::WebRequest&onProgress(intcallback)
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
noahh::Mod*getMod()const
Gets the mod which owns the request.
noahh::ZStringViewgetMethod()const
Gets the request method as a string
noahh::ZStringViewgetUrl()const
Gets the request URL
intconst&getHeaders()const
Gets the request headers
intconst&getUrlParams()const
Gets the parameters inside the URL
std::optional<noahh::ByteVector>getBody()const
Gets the post body stream
std::optional<std::chrono::seconds>getTimeout()const
Gets the request timeout in seconds
noahh::utils::web::HttpVersiongetHttpVersion()const
Gets HTTP versions applied to the request
noahh::utils::web::WebProgressgetProgress()const
Gets the current progress of the request, if it was sent. Otherwise, default values are returned.