# RequestModule

#### new RequestModule()

Source:
  - constructors/request.js, line 3

### Members

#### (static) READY_STATE_DONE :number

Source:
  - constructors/request.js, line 452
Default Value:
  - 4

Downloading is done

##### Type:

- number

#### (static) READY_STATE_HEADERS_RECEIVED :number

Source:
  - constructors/request.js, line 438
Default Value:
  - 2

send() has been called, and headers and status are available.

##### Type:

- number

#### (static) READY_STATE_LOADING :number

Source:
  - constructors/request.js, line 445
Default Value:
  - 3

Downloading; responseText holds partial data.

##### Type:

- number

#### (static) READY_STATE_OPENED :number

Source:
  - constructors/request.js, line 431
Default Value:
  - 1

open() has been called.

##### Type:

- number

#### (static) READY_STATE_UNSENT :number

Source:
  - constructors/request.js, line 424
Default Value:
  - 0

Client has been created. open() not called yet.

##### Type:

- number

### Methods

#### (static) ParamsParser(value, pattern, optsopt) → {Object.<string, string>}

Source:
  - constructors/request/params-parser.js, line 1

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`value` | string |  |
`pattern` | string |  |

`opts`

object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`cache` | object | <optional> |  | object where reg expressions will be cached
`mapper` | function | <optional> |  | function that will decode value, default is decodeURIComponent
`boud` | string | <optional> | `"\x02\x00\x00\x03"` | function that will decode value, default is decodeURIComponent
`ret` | object | <optional> |  | object to be updated with found params
`tableIndex` | Array.<string> | <optional> |  | list of parameters' names ( @experimental )
`pRegExp` | string | <optional> | `"\\:([a-z][a-z0-9]+)"` | RegExp params' chars
`matchGroup` | string | <optional> | `"([^\\/]+)"` | RegExp value
`fixedEnd` | string | <optional> | `true` | RegExp value

##### Returns:

Type
  Object.<string, string>

#### async() → {boolean}

Source:
  - constructors/request.js, line 487
See:
  - RequestModule.RequestConfig

returns `RequestModule.RequestConfig["async"]`

##### Returns:

Type
  boolean

#### async(status) → {RequestModule}

Source:
  - constructors/request.js, line 494

##### Parameters:

Name | Type | Description
--- | --- | ---
`status` | boolean | enable/disable XMLHttpRequest async mode

##### Returns:

Type
  RequestModule

#### config() → {RequestModule.RequestConfig}

Source:
  - constructors/request.js, line 111

##### Returns:

Type
  RequestModule.RequestConfig

#### configurator(template) → {RequestModule}

Source:
  - constructors/request.js, line 120

##### Parameters:

Name | Type | Description
--- | --- | ---
`template` | 'multipart' | 'blob' | 'binary' | 'POST' | 'prepare-multipart' | 'retrieve-blob' | 'retrieve-binary-string' | 'prepare-post' | 'check-status-code' | 'ignore-status-code' | configuration name

##### Returns:

Type
  RequestModule

#### headers() → {string}

Source:
  - constructors/request.js, line 612

##### Returns:

Type
  string

#### headers(name, value) → {RequestModule}

Source:
  - constructors/request.js, line 621

set a new header

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string |
`value` | string |

##### Returns:

Type
  RequestModule

#### method() → {string}

Source:
  - constructors/request.js, line 508
See:
  - RequestModule.RequestConfig

returns `RequestModule.RequestConfig["method"]`

##### Returns:

Type
  string

#### method(status) → {RequestModule}

Source:
  - constructors/request.js, line 515

##### Parameters:

Name | Type | Description
--- | --- | ---
`status` | string | XMLHttpRequest method name, default is `"GET"`

##### Returns:

Type
  RequestModule

#### open(methodopt, urlopt, asyncopt, timeoutopt) → {RequestModule}

Source:
  - constructors/request.js, line 549

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`method` | string | <optional> | `"GET"` |
`url` | string | <optional> |  |
`async` | boolean | <optional> |  |
`timeout` | number | <optional> |  | request timeout in seconds

##### Returns:

Type
  RequestModule

#### readyState() → {RequestModule.readyStateType}

Source:
  - constructors/request.js, line 455

##### Returns:

Type
  RequestModule.readyStateType

#### request() → {XMLHttpRequest}

Source:
  - constructors/request.js, line 191

##### Returns:

Type
  XMLHttpRequest

#### response(typeopt, optionsopt) → {RequestModule|Promise.<ArrayBuffer>|Promise.<Blob>|Promise.<HTMLElement>|Promise.<DocumentFragment>|Promise.<string>|ArrayBuffer|Blob|HTMLElement|string}

Source:
  - constructors/request.js, line 198

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`type` | '' | 'request' | 'blob' | 'arraybuffer' | 'text' | 'json' | 'document' | <optional> |

`options`

object

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`type` | string | <optional> | `"application/octet-stream"` | Blob constructor's params

##### Returns:

Type
  RequestModule | Promise.<ArrayBuffer> | Promise.<Blob> | Promise.<HTMLElement> | Promise.<DocumentFragment> | Promise.<string> | ArrayBuffer | Blob | HTMLElement | string

#### send(dataopt, typeopt, headersopt) → {RequestModule}

Source:
  - constructors/request.js, line 569

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`data` | string | FormData | MediaStream | <optional> | `''` |
`type` | "asFormData" | "json" | "urlencoded" | <optional> | `null` |
`headers` | Object.<string, string> | <optional> |  |

##### Returns:

Type
  RequestModule

#### status() → {number}

Source:
  - constructors/request.js, line 468

##### Returns:

Type
  number

#### statusText() → {string}

Source:
  - constructors/request.js, line 477

##### Returns:

Type
  string

#### timeout() → {number}

Source:
  - constructors/request.js, line 374

current XMLHttpRequest timeout in seconds

##### Returns:

Type
  number

#### timeout(seconds) → {RequestModule}

Source:
  - constructors/request.js, line 381

update XMLHttpRequest timeout in seconds

##### Parameters:

Name | Type | Description
--- | --- | ---
`seconds` | number | set 0 to unlimited

##### Returns:

Type
  RequestModule

#### url() → {string}

Source:
  - constructors/request.js, line 529
See:
  - RequestModule.RequestConfig

returns `RequestModule.RequestConfig["url"]`

##### Returns:

Type
  string

#### url(url) → {RequestModule}

Source:
  - constructors/request.js, line 529

##### Parameters:

Name | Type | Description
--- | --- | ---
`url` | string | setup the url that should be processed

##### Returns:

Type
  RequestModule

#### withCredentials() → {boolean}

Source:
  - constructors/request.js, line 396

current XMLHttpRequest withCredentials status

##### Returns:

Type
  boolean

#### withCredentials(status) → {RequestModule}

Source:
  - constructors/request.js, line 403

update XMLHttpRequest withCredentials flag

##### Parameters:

Name | Type | Description
--- | --- | ---
`status` | boolean |

##### Returns:

Type
  RequestModule

### Type Definitions

#### readyStateType

Source:
  - constructors/request.js, line 71

##### Properties:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`READY_STATE_UNSENT` | number | <optional> | `0` |
`READY_STATE_OPENED` | number | <optional> | `1` |
`READY_STATE_HEADERS_RECEIVED` | number | <optional> | `2` |
`READY_STATE_LOADING` | number | <optional> | `3` |
`READY_STATE_DONE` | number | <optional> | `4` |

##### Type:

- object

#### RequestConfig

Source:
  - constructors/request.js, line 46

##### Properties:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`method` | boolean | <optional> | `"GET"` |
`url` | boolean | <optional> | `"#"` |
`async` | boolean | <optional> | `true` |
`opened` | boolean | <optional> | `false` |
`isSent` | boolean | <optional> | `false` |
`isLoaded` | boolean | <optional> | `false` |
`isUploaded` | boolean | <optional> | `false` |
`ignoreStatusCode` | boolean | <optional> | `false` |

##### Type:

- Object