Home Reference Source Repository
import Request from 'rx-http/src/request.js'
public class | source

Request

A Request should only ever be created by an instance of Http

Constructor Summary

Public Constructor
public

constructor(config: Object)

Method Summary

Public Methods
public

body(value: Object | FormData | Blob | File | String, serializer: Serializer): Object | FormData | Blob | File | String | Request

public

Convenience method for getting/setting the Content-Type header.

public
public

headers(name: String | Object, value: *): Object | String | Request

public
public
public
public

XHRProvider only - sets the responseType field of the XMLHttpRequest

public
public
public

url(value: Url): Url | Request

public

user(value: String): String | Request

public
public
public

Public Constructors

public constructor(config: Object) source

Params:

NameTypeAttributeDescription
config Object

Override default settings for this Request only.

Public Methods

public body(value: Object | FormData | Blob | File | String, serializer: Serializer): Object | FormData | Blob | File | String | Request source

Params:

NameTypeAttributeDescription
value Object | FormData | Blob | File | String
  • optional

The body for this request

serializer Serializer
  • optional

The serializer for the body

Return:

Object | FormData | Blob | File | String | Request

If value is specified, sets the body for this request and returns the current Request. If value is ommitted, returns the current body

public contentType(value: String): String | Request source

Convenience method for getting/setting the Content-Type header.

Params:

NameTypeAttributeDescription
value String
  • optional

The value of the Content-Type header

Return:

String | Request

If value is specified, sets the Content-Type header. If value is ommitted, returns the current value of the Content-Type header (or undefined);

public execute(): Object source

Return:

Object

Executes the request and returns an object containing the response, uploadProgress, and downloadProgress streams.

Example:

var streams = request.execute();
streams.flatMap(response => response.body()).forEach((body) => console.log(body));
streams.flatmap(response => response.uploadProgress()).forEach((event) => console.log(event));
streams.flatMap(response => response.downloadProgress()).forEach((event) => console.log(event));

public headers(name: String | Object, value: *): Object | String | Request source

Params:

NameTypeAttributeDescription
name String | Object
  • optional

The name of the header

value *
  • optional

The value of the header

Return:

Object | String | Request

If no parameters are specified - returns a copy of the entire headers hash.

Example:

request.headers() // returns { "foo": "bar" }
If only name is specified, and name is a string - returns the value for the key in the headers hash.
request.headers("foo") // returns "bar"
If only name is specified, and name is an object - replaces the entire headers hash
and returns the current Request.
request.headers({ "foo": "bar", "baz": 1 })
If name and value are specified - sets the value of name in the headers hash
and returns the current Request.
request.headers("foo", "bar")

public interceptors(value: Interceptor[]): Interceptor[] | Request source

Params:

NameTypeAttributeDescription
value Interceptor[]
  • optional

The set of interceptors to be run against this Request and/or Response

Return:

Interceptor[] | Request

If value is specified, overrides the current set of interceptors for this Request and/or Response and returns the current Request. If value is ommitted, returns the current set of interceptors.

public method(value: String): String | Request source

Params:

NameTypeAttributeDescription
value String
  • optional

The HTTP method for this request

Return:

String | Request

If value is specified, sets the HTTP method for this request and returns the current Request. If value is ommitted, returns the current HTTP method

public password(value: String): String | Request source

Params:

NameTypeAttributeDescription
value String
  • optional

Basic auth password

Return:

String | Request

If the value is specified, sets the password and returns the current Request. If value is ommitted, retursn the current password.

public responseType(value: String): String | Request source

XHRProvider only - sets the responseType field of the XMLHttpRequest

Params:

NameTypeAttributeDescription
value String
  • optional

The expected responseType

Return:

String | Request

If value is specified, sets the responseType for this request, and returns the current request. If value is ommitted, returns the current responseType value.

public serializer(value: Serializer): Serializer | Request source

Params:

NameTypeAttributeDescription
value Serializer
  • optional

The serializer for the body

Return:

Serializer | Request

If value is specified, sets the Serializer for this request and returns the current Request. If value is ommitted, returns the current Serializer

public timeout(value: Number): Number | Request source

Params:

NameTypeAttributeDescription
value Number
  • optional

The request timeout in milliseconds

Return:

Number | Request

If value is specified, sets the timeout for this request, and returns the current request. If value is ommitted, returns the current timeout value.

public url(value: Url): Url | Request source

Params:

NameTypeAttributeDescription
value Url
  • optional

The Url for this request.

Return:

Url | Request

If value is specified, sets the Url for this request and returns the current Request. If value is ommitted, returns the current Url.

public user(value: String): String | Request source

Params:

NameTypeAttributeDescription
value String
  • optional

Basic auth user

Return:

String | Request

If the value is specified, sets the user and returns the current Request. If value is ommitted, retursn the current user.

public withCredentials(value: Boolean): Boolean | Request source

Params:

NameTypeAttributeDescription
value Boolean
  • optional

Flag indicating whether cross-site AccessControl requests should be made using cookies, authorization headers, or TLS client certificates. More detail: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials

Return:

Boolean | Request

If the value is specified, sets the withCredentials flag and returns the current Request. If value is ommitted, returns the current value of the flag.

public xsrfCookieName(value: String): String | Request source

Params:

NameTypeAttributeDescription
value String
  • optional

The name of the XSRF cookie

Return:

String | Request

If the value is specified, sets the name of the XSRF Cookie and returns the current Request. If value is ommitted, returns the current name.

public xsrfHeaderName(value: String): String | Request source

Params:

NameTypeAttributeDescription
value String
  • optional

The name of the XSRF header

Return:

String | Request

If the value is specified, sets the name of the XSRF Header and returns the current Request. If value is ommitted, returns the current name.