class dom::HttpReq
sys::Obj dom::HttpReq
@Js
HttpReq models the request side of an XMLHttpRequest instance.
See pod doc for details.
- asynch
-
Bool asynch := true
If true then perform this request asynchronously. Defaults to
true
- get
-
Void get(Func<Void,HttpRes> c)
Convenience for
send("GET", "", c)
. - headers
-
Map<Str,Str> headers := Map<Str,Str>[:]
The request headers to send.
- make
-
new make(Func<Void,This>? f := null)
Create a new HttpReq instance.
- onProgress
-
Void onProgress(Func<Void,Int,Int> f)
Optional callback to track progress of request transfers, where
loaded
is the number of bytes that have been transferred, andtotal
is the total number of bytes to be transferred.For
GET
requests, the progress will track the response being downloaded to the browser. ForPUT
andPOST
requests, the progress will track the content being uploaded to the server.Note this callback is only invoked when
lengthComputable
istrue
on the underlying progress events. - post
-
Void post(Obj content, Func<Void,HttpRes> c)
Convenience for
send("POST", content, c)
. - postForm
-
Void postForm(Map<Str,Str> form, Func<Void,HttpRes> c)
Post the
form
map as a HTML form submission. Formats the map into a valid url-encoded content string, and setsContent-Type
header toapplication/x-www-form-urlencoded
. - send
-
Void send(Str method, Obj? content, Func<Void,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 := false
Indicates whether or not cross-site
Access-Control
requests should be made using credentials such as cookies, authorization headers or TLS client certificates. SettingwithCredentials
has no effect on same-site requests. The default isfalse
.Requests from a different domain cannot set cookie values for their own domain unless
withCredentials
is set totrue
before making the request. The third-party cookies obtained by settingwithCredentials
totrue
will still honor same-origin policy and hence can not be accessed by the requesting script throughDoc.cookies
or from response headers.