goog.labs.net.xhr
Functions
get( url, opt_options ) → goog.Promise<string, ?>
goog.Promise<string, ?>
Sends a get request, returning a promise that will be resolved with the response text once the request completes.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
getBlob( url, opt_options ) → goog.Promise<Blob, ?>
goog.Promise<Blob, ?>
Sends a get request, returning a promise that will be resolved with the response as a Blob.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
getBytes( url, opt_options ) → goog.Promise<(Uint8Array|Array<number>), ?>
goog.Promise<(Uint8Array|Array<number>), ?>
Sends a get request, returning a promise that will be resolved with the response as an array of bytes.
Supported in all XMLHttpRequest level 2 browsers, as well as IE9. IE8 and earlier are not supported.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
getJson( url, opt_options ) → goog.Promise<(Object|null), ?>
goog.Promise<(Object|null), ?>
Sends a get request, returning a promise that will be resolved with the parsed response text once the request completes.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
parseJson( responseText, opt_xssiPrefix ) → Object
Object
post( url, data, opt_options ) → goog.Promise<string, ?>
goog.Promise<string, ?>
Sends a post request, returning a promise that will be resolved with the response text once the request completes.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
postJson( url, data, opt_options ) → goog.Promise<(Object|null), ?>
goog.Promise<(Object|null), ?>
Sends a post request, returning a promise that will be resolved with the parsed response text once the request completes.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
send( method, url, data, opt_options ) → goog.Promise<(goog.net.XhrLike|XMLHttpRequest), ?>
goog.Promise<(goog.net.XhrLike|XMLHttpRequest), ?>
Sends a request, returning a promise that will be resolved with the XHR object once the request completes.
If content type hasn't been set in opt_options headers, and hasn't been explicitly set to null, default to form-urlencoded/UTF8 for POSTs.
Parameters |
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Properties
CONTENT_TYPE_HEADER → string
string
The Content-Type HTTP header name.
FORM_CONTENT_TYPE → string
string
The Content-Type HTTP header value for a url-encoded form.
Options → {headers: (Object<?, string>|null|undefined), mimeType: (string|undefined), responseType: (goog.labs.net.xhr.ResponseType|undefined), timeoutMs: (number|undefined), withCredentials: (boolean|undefined), xmlHttpFactory: (goog.net.XmlHttpFactory|null|undefined), xssiPrefix: (string|undefined)}
{headers: (Object<?, string>|null|undefined), mimeType: (string|undefined), responseType: (goog.labs.net.xhr.ResponseType|undefined), timeoutMs: (number|undefined), withCredentials: (boolean|undefined), xmlHttpFactory: (goog.net.XmlHttpFactory|null|undefined), xssiPrefix: (string|undefined)}
Configuration options for an XMLHttpRequest.
- headers: map of header key/value pairs.
- timeoutMs: number of milliseconds after which the request will be timed out by the client. Default is to allow the browser to handle timeouts.
- withCredentials: whether user credentials are to be included in a cross-origin request. See: http://www.w3.org/TR/XMLHttpRequest/#the-withcredentials-attribute
- mimeType: allows the caller to override the content-type and charset for the request. See: http://www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-overridemimetype
- responseType: may be set to change the response type to an arraybuffer or blob for downloading binary data. See: http://www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-responsetype]
- xmlHttpFactory: allows the caller to override the factory used to create XMLHttpRequest objects.
- xssiPrefix: Prefix used for protecting against XSSI attacks, which should be removed before parsing the response as JSON.
PostData → (ArrayBuffer|ArrayBufferView|Blob|Document|FormData|string|null|undefined)
(ArrayBuffer|ArrayBufferView|Blob|Document|FormData|string|null|undefined)
Defines the types that are allowed as post data.