HttpBackend class
HTTP backend used by the Http service that delegates to dart:html's
HttpRequest and deals with Dart bugs.
Never use this service directly, instead use the higher-level Http.
During testing this implementation is swapped with MockHttpBackend which
can be trained with responses.
class HttpBackend {
/**
* Wrapper around dart:html's [HttpRequest.request]
*/
async.Future request(String url,
{String method, bool withCredentials, String responseType,
String mimeType, Map<String, String> requestHeaders, sendData,
void onProgress(dom.ProgressEvent e)}) {
// Complete inside a then to work-around dartbug.com/13051
var c = new async.Completer();
dom.HttpRequest.request(url,
method: method,
withCredentials: withCredentials,
responseType: responseType,
mimeType: mimeType,
requestHeaders: requestHeaders,
sendData: sendData,
onProgress: onProgress).then((x) => c.complete(x));
return c.future;
}
}
Subclasses
Methods
Future request(String url, {String method, bool withCredentials, String responseType, String mimeType, Map<String, String> requestHeaders, sendData, void onProgress(ProgressEvent e)}) #
Wrapper around dart:html's HttpRequest.request
async.Future request(String url,
{String method, bool withCredentials, String responseType,
String mimeType, Map<String, String> requestHeaders, sendData,
void onProgress(dom.ProgressEvent e)}) {
// Complete inside a then to work-around dartbug.com/13051
var c = new async.Completer();
dom.HttpRequest.request(url,
method: method,
withCredentials: withCredentials,
responseType: responseType,
mimeType: mimeType,
requestHeaders: requestHeaders,
sendData: sendData,
onProgress: onProgress).then((x) => c.complete(x));
return c.future;
}