Holds the state of an executing HTTP request.
Holds the state of an executing HTTP request.
Headers for the request. Note that if the User-Agent header is not present, one will automatically be added with basic information about your plugin. It is therefore not recommended to pass in a custom User-Agent header.
Whether or not to follow redirects.
Net::HttpRequest@ HttpRequest(const string&in url)
Creates a new GET request with the given URL.
Net::HttpRequest@ Net::HttpRequest@ HttpRequest(const string&in url, const string&in body)
Creates a new POST request with the given URL and body.
Net::HttpRequest@ awaitable@ Start()
Starts executing the request. Does nothing if the request has already started.
awaitable@ awaitable@ StartToFile(const string&in path)
Starts executing the request, writing the response to the given path. Throws an exception if the request has already started.
awaitable@ bool Finished()
Returns true if the request has finished execution. This will return true even in the case of an error.
bool int64 ProgressDownload()
Returns the number of bytes that has been downloaded from the server.
int64 int64 ProgressDownloadTotal()
Returns the total number of bytes that are expected to be returned from the server. Note that this can be 0 before the server has sent its Content-Length header, or if it never sends the header at all.
int64 int64 ProgressUpload()
Returns the number of bytes that has been uploaded to the server.
int64 int64 ProgressUploadTotal()
Returns the total number of bytes that are expected to be uploaded to the server.
int64 void Cancel()
Cancels the request. Throws an exception when the request is not yet started.
string Error()
Returns an error message, if there was an error. Otherwise, this returns an empty string. This function is useful in the rare case that ResponseCode() returns 0.
string string ResponseHeader(const string&in key)
Gets the value of a specific response header. The key is case insensitive.
string void SaveToFile(const string&in path)
Saves the response body to a file. The given path should be an absolute path.