Skip to content

Commit ff0d459

Browse files
committed
feat: major major ✨
1 parent 17fe873 commit ff0d459

10 files changed

+903
-535
lines changed

README.md

+29-20
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ and [http2.request](https://nodejs.org/api/http2.html#http2_clienthttp2session_r
88

99
* Fetch-alike
1010
* Cool-beans config options (with defaults)
11-
* Automatic HTTP2 support (ALPN negotiation)
11+
* Automatic HTTP/2 support (ALPN negotiation)
1212
* Automatic or opt-in body parse (with non-UTF-8 charset decoding)
1313
* Automatic and simplistic `Cookies` treatment (with built-in jar)
1414
* Automatic decompression (with opt-in body compression)
1515
* Built-in streamable `File` & `FormData` interfaces
16-
* Support redirects with fine-grained tune-ups
16+
* Support redirects & retries with fine-grained tune-ups
1717
* Support all legit request body types (include blobs & streams)
1818
* Support both CJS and ESM module systems
1919
* Fully promise-able and pipe-able
@@ -120,54 +120,63 @@ console.log(res.body);
120120
extra [http2.ClientSessionOptions](https://nodejs.org/api/http2.html#http2_http2_connect_authority_options_listener)
121121
& [http2.ClientSessionRequestOptions](https://nodejs.org/api/http2.html#http2_clienthttp2session_request_headers_options)
122122
and [tls.ConnectionOptions](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback)
123-
for the HTTP2 attunes
123+
for HTTP/2 attunes
124124
* `body` **{string | Array | AsyncIterator | Blob | Buffer | File | FromData | Iterator | Object | Readable |
125-
Uint8Array | URLSearchParams}** Body to send with the request
126-
* `cookies` **{boolean | Array[[key, value]] | Cookies | Object | URLSearchParams}** `Default: true` Cookies to add to
125+
Uint8Array | URLSearchParams}** The body to send with the request
126+
* `cookies` **{boolean | Array<[k, v]> | Cookies | Object | URLSearchParams}** `Default: true` The cookies to add to
127127
the request
128-
* `digest` **{boolean}** `Default: true` Read response stream, or simply add a mixin
129-
* `follow` **{number}** `Default: 20` Number of redirects to follow
130-
* `h2` **{boolean}** `Default: false` Forces use of the HTTP2 protocol
131-
* `headers` **{Object}** Headers to add to the request
132-
* `parse` **{boolean}** `Default: true` Parse response body, or simply return a buffer
133-
* `redirect` **{error | follow | manual}** `Default: 'follow'` Controls redirect flow
134-
* `thenable` **{boolean}** `Default: false` Controls promise resolutions
128+
* `digest` **{boolean}** `Default: true` Controls whether to read the response stream or just add a mixin
129+
* `follow` **{number}** `Default: 20` The number of redirects to follow
130+
* `h2` **{boolean}** `Default: false` Forces the use of HTTP/2 protocol
131+
* `headers` **{Object}** The headers to add to the request
132+
* `maxRetryAfter` **{number}** The upper limit of `retry-after` header. If unset, it will use `timeout` value
133+
* `parse` **{boolean}** `Default: true` Controls whether to parse response body or simply return a buffer
134+
* `redirect` **{error | follow | manual}** `Default: follow` Controls the redirect flows
135+
* `retry` **{Object}** Represents the retry options
136+
* `attempts` **{number}** `Default: 0` The number of retry attempts
137+
* `backoffStrategy` **{string}** `Default: interval * Math.log(Math.random() * (Math.E * Math.E - Math.E) + Math.E)`
138+
The backoff strategy algorithm that increases logarithmically. To fixate set value to `interval * 1`
139+
* `interval` **{number}** `Default: 1e3` The initial retry interval
140+
* `retryAfter` **{boolean}** `Default: true` Controls `retry-after` header receptiveness
141+
* `statusCodes` **{number[]}** `Default: [429, 503]` The list of status codes to retry on
142+
* `thenable` **{boolean}** `Default: false` Controls the promise resolutions
143+
* `timeout` **{number}** `Default: 3e5` The number of milliseconds a request can take before termination
135144
* **Returns:** Promise that resolves to
136145
extended [http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
137146
or [http2.ClientHttp2Stream](https://nodejs.org/api/http2.html#http2_class_clienthttp2stream) which is respectively
138147
readable and duplex streams
139148
* if `degist: true` & `parse: true`
140-
* `body` **{string | Array | Buffer | Object}** Body based on its content type
149+
* `body` **{string | Array | Buffer | Object}** The body based on its content type
141150
* if `degist: false`
142151
* `arrayBuffer` **{AsyncFunction}** Reads the response and returns **ArrayBuffer**
143152
* `blob` **{AsyncFunction}** Reads the response and returns **Blob**
144153
* `body` **{AsyncFunction}** Reads the response and returns **Buffer** if `parse: false`
145154
* `json` **{AsyncFunction}** Reads the response and returns **Object**
146155
* `text` **{AsyncFunction}** Reads the response and returns **String**
147-
* `bodyUsed` **{boolean}** Whether the response were read or not
148-
* `cookies` **{undefined | Cookies}** Cookies sent and received with the response
149-
* `headers` **{Object}** Headers received with the response
156+
* `bodyUsed` **{boolean}** Indicates whether the response were read or not
157+
* `cookies` **{undefined | Cookies}** The cookies sent and received with the response
158+
* `headers` **{Object}** The headers received with the response
150159
* `httpVersion` **{string}** Indicates protocol version negotiated with the server
151160
* `ok` **{boolean}** Indicates if the response was successful (statusCode: **200-299**)
152161
* `redirected` **{boolean}** Indicates if the response is the result of a redirect
153162
* `statusCode` **{number}** Indicates the status code of the response
154-
* `trailers` **{undefined | Object}** Trailer headers received with the response
163+
* `trailers` **{undefined | Object}** The trailer headers received with the response
155164

156165
---
157166

158167
#### `rekwest.defaults`
159168

160-
Object to fill with default [options](#rekwesturl-options)
169+
The object to fulfill with default [options](#rekwesturl-options)
161170

162171
---
163172

164173
#### `rekwest.stream(url[, options])`
165174

166-
Method with limited functionality to use with streams and pipes
175+
The method with limited functionality to use with streams and/or pipes
167176

168177
* No automata
169178
* No redirects
170-
* Pass `h2: true` in options to use the HTTP2 protocol
179+
* Pass `h2: true` in options to use HTTP/2 protocol
171180
* Or use `ackn({ url: URL })` method in advance to probe the available protocols
172181

173182
---

0 commit comments

Comments
 (0)