class dom::HttpReq
sys::Obj dom::HttpReq
@Js
HttpReq models the request side of an XMLHttpRequest instance.
See pod doc for details.
- async
-
Bool async := trueIf true then perform this request asynchronously. Defaults to
true - get
-
Convenience for
send("GET", "", c). - headers
-
Str:Str headers := [Str:Str][:]The request headers to send.
- make
-
new make(|This|? f := null)Create a new HttpReq instance.
- onProgress
-
Optional callback to track progress of request transfers, where
loadedis the number of bytes that have been transferred, andtotalis the total number of bytes to be transferred.For
GETrequests, the progress will track the response being downloaded to the browser. ForPUTandPOSTrequests, the progress will track the content being uploaded to the server.Note this callback is only invoked when
lengthComputableistrueon the underlying progress events. - post
-
Void post(Obj content, |HttpRes| c)Convenience for
send("POST", content, c). - postForm
-
Void postForm(Str:Str form, |HttpRes| c)Post the
formmap as a HTML form submission. Formats the map into a valid url-encoded content string, and setsContent-Typeheader toapplication/x-www-form-urlencoded. - postFormMultipart
-
Void postFormMultipart(Str:Obj form, |HttpRes| c)Post the
formas amultipart/form-datasubmission. Formats map into multipart key value pairs, whereDomFilevalues will be encoded with file contents. - resType
-
Str resType := ""The type of data contained in the response. It also lets the author change the response type. If an empty string is set as the value, the default value of
"text"is used. Set this field to "arraybuffer" to access response as Buf. - send
-
Void send(Str method, Obj? content, |HttpRes| c)Send a request with the given content using the given HTTP method (case does not matter). After receiving the response, call the given closure with the resulting HttpRes object.
- uri
-
Uri uri := `#`The Uri to send the request.
- withCredentials
-
Bool withCredentials := falseIndicates whether or not cross-site
Access-Controlrequests should be made using credentials such as cookies, authorization headers or TLS client certificates. SettingwithCredentialshas no effect on same-site requests. The default isfalse.Requests from a different domain cannot set cookie values for their own domain unless
withCredentialsis set totruebefore making the request. The third-party cookies obtained by settingwithCredentialstotruewill still honor same-origin policy and hence can not be accessed by the requesting script throughDoc.cookiesor from response headers.