axios 1.5.1 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.6.1](https://github.com/axios/axios/compare/v1.6.0...v1.6.1) (2023-11-08)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **formdata:** fixed content-type header normalization for non-standard browser environments; ([#6056](https://github.com/axios/axios/issues/6056)) ([dd465ab](https://github.com/axios/axios/commit/dd465ab22bbfa262c6567be6574bf46a057d5288))
9
+ * **platform:** fixed emulated browser detection in node.js environment; ([#6055](https://github.com/axios/axios/issues/6055)) ([3dc8369](https://github.com/axios/axios/commit/3dc8369e505e32a4e12c22f154c55fd63ac67fbb))
10
+
11
+ ### Contributors to this release
12
+
13
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+432/-65 (#6059 #6056 #6055 )")
14
+ - <img src="https://avatars.githubusercontent.com/u/3982806?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Fabian Meyer](https://github.com/meyfa "+5/-2 (#5835 )")
15
+
16
+ # [1.6.0](https://github.com/axios/axios/compare/v1.5.1...v1.6.0) (2023-10-26)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **CSRF:** fixed CSRF vulnerability CVE-2023-45857 ([#6028](https://github.com/axios/axios/issues/6028)) ([96ee232](https://github.com/axios/axios/commit/96ee232bd3ee4de2e657333d4d2191cd389e14d0))
22
+ * **dns:** fixed lookup function decorator to work properly in node v20; ([#6011](https://github.com/axios/axios/issues/6011)) ([5aaff53](https://github.com/axios/axios/commit/5aaff532a6b820bb9ab6a8cd0f77131b47e2adb8))
23
+ * **types:** fix AxiosHeaders types; ([#5931](https://github.com/axios/axios/issues/5931)) ([a1c8ad0](https://github.com/axios/axios/commit/a1c8ad008b3c13d53e135bbd0862587fb9d3fc09))
24
+
25
+ ### PRs
26
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
27
+ ```
28
+
29
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
30
+ ```
31
+
32
+ ### Contributors to this release
33
+
34
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+449/-114 (#6032 #6021 #6011 #5932 #5931 )")
35
+ - <img src="https://avatars.githubusercontent.com/u/63700910?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Valentin Panov](https://github.com/valentin-panov "+4/-4 (#6028 )")
36
+ - <img src="https://avatars.githubusercontent.com/u/76877078?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Rinku Chaudhari](https://github.com/therealrinku "+1/-1 (#5889 )")
37
+
3
38
  ## [1.5.1](https://github.com/axios/axios/compare/v1.5.0...v1.5.1) (2023-09-26)
4
39
 
5
40
 
@@ -19,6 +54,13 @@
19
54
  - <img src="https://avatars.githubusercontent.com/u/132928043?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Przemyslaw Motacki](https://github.com/sfc-gh-pmotacki "+2/-1 (#5892 )")
20
55
  - <img src="https://avatars.githubusercontent.com/u/5492927?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+1/-1 ()")
21
56
 
57
+ ### PRs
58
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
59
+ ```
60
+
61
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
62
+ ```
63
+
22
64
  # [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26)
23
65
 
24
66
 
@@ -42,6 +84,13 @@
42
84
  - <img src="https://avatars.githubusercontent.com/u/65978976?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )")
43
85
  - <img src="https://avatars.githubusercontent.com/u/5492927?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )")
44
86
 
87
+ ### PRs
88
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
89
+ ```
90
+
91
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
92
+ ```
93
+
45
94
  # [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27)
46
95
 
47
96
 
@@ -67,6 +116,13 @@
67
116
  - <img src="https://avatars.githubusercontent.com/u/47537704?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )")
68
117
  - <img src="https://avatars.githubusercontent.com/u/43876655?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )")
69
118
 
119
+ ### PRs
120
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
121
+ ```
122
+
123
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
124
+ ```
125
+
70
126
  ## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19)
71
127
 
72
128
 
@@ -80,6 +136,13 @@
80
136
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+48/-10 (#5665 #5661 #5663 )")
81
137
  - <img src="https://avatars.githubusercontent.com/u/5492927?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+2/-0 (#5445 )")
82
138
 
139
+ ### PRs
140
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
141
+ ```
142
+
143
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
144
+ ```
145
+
83
146
  ## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05)
84
147
 
85
148
 
@@ -92,6 +155,13 @@
92
155
 
93
156
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+28/-10 (#5633 #5584 )")
94
157
 
158
+ ### PRs
159
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
160
+ ```
161
+
162
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
163
+ ```
164
+
95
165
  ## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22)
96
166
 
97
167
 
@@ -106,6 +176,13 @@
106
176
  - <img src="https://avatars.githubusercontent.com/u/19550000?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [lcysgsg](https://github.com/lcysgsg "+4/-0 (#5548 )")
107
177
  - <img src="https://avatars.githubusercontent.com/u/5492927?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-0 (#5444 )")
108
178
 
179
+ ### PRs
180
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
181
+ ```
182
+
183
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
184
+ ```
185
+
109
186
  ## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13)
110
187
 
111
188
 
@@ -120,6 +197,13 @@
120
197
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+11/-7 (#5545 #5535 #5542 )")
121
198
  - <img src="https://avatars.githubusercontent.com/u/19842213?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [陈若枫](https://github.com/ruofee "+2/-2 (#5467 )")
122
199
 
200
+ ### PRs
201
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
202
+ ```
203
+
204
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
205
+ ```
206
+
123
207
  ## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03)
124
208
 
125
209
 
@@ -132,6 +216,13 @@
132
216
 
133
217
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+2/-1 (#5530 #5528 )")
134
218
 
219
+ ### PRs
220
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
221
+ ```
222
+
223
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
224
+ ```
225
+
135
226
  ## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01)
136
227
 
137
228
 
@@ -144,6 +235,13 @@
144
235
 
145
236
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )")
146
237
 
238
+ ### PRs
239
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
240
+ ```
241
+
242
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
243
+ ```
244
+
147
245
  # [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31)
148
246
 
149
247
 
@@ -162,6 +260,13 @@
162
260
  - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )")
163
261
  - <img src="https://avatars.githubusercontent.com/u/35015993?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )")
164
262
 
263
+ ### PRs
264
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
265
+ ```
266
+
267
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
268
+ ```
269
+
165
270
  ## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28)
166
271
 
167
272
 
@@ -174,6 +279,13 @@
174
279
 
175
280
  - ![avatar](https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )")
176
281
 
282
+ ### PRs
283
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
284
+ ```
285
+
286
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
287
+ ```
288
+
177
289
  ## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26)
178
290
 
179
291
 
@@ -186,6 +298,13 @@
186
298
  - ![avatar](https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+82/-54 (#5499 )")
187
299
  - ![avatar](https://avatars.githubusercontent.com/u/20516159?v&#x3D;4&amp;s&#x3D;16) [Elliot Ford](https://github.com/EFord36 "+1/-1 (#5462 )")
188
300
 
301
+ ### PRs
302
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
303
+ ```
304
+
305
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
306
+ ```
307
+
189
308
  ## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22)
190
309
 
191
310
 
@@ -199,6 +318,13 @@
199
318
  - ![avatar](https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+242/-108 (#5486 #5482 )")
200
319
  - ![avatar](https://avatars.githubusercontent.com/u/9430821?v&#x3D;4&amp;s&#x3D;16) [Daniel Hillmann](https://github.com/hilleer "+1/-1 (#5478 )")
201
320
 
321
+ ### PRs
322
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
323
+ ```
324
+
325
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
326
+ ```
327
+
202
328
  ## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10)
203
329
 
204
330
 
@@ -210,6 +336,13 @@
210
336
 
211
337
  - ![avatar](https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+938/-442 (#5456 #5455 #5453 #5451 #5449 #5447 #5446 #5443 #5442 #5439 #5420 )")
212
338
 
339
+ ### PRs
340
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
341
+ ```
342
+
343
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
344
+ ```
345
+
213
346
  ## [1.2.2] - 2022-12-29
214
347
 
215
348
  ### Fixed
@@ -264,6 +397,13 @@
264
397
  - [Ivan Barsukov](https://github.com/ovarn)
265
398
  - [Arthur Fiorette](https://github.com/arthurfiorette)
266
399
 
400
+ ### PRs
401
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
402
+ ```
403
+
404
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
405
+ ```
406
+
267
407
  ## [1.2.0] - 2022-11-10
268
408
 
269
409
  ### Changed
@@ -330,6 +470,13 @@
330
470
  - [AZM](https://github.com/aziyatali)
331
471
  - [relbns](https://github.com/relbns)
332
472
 
473
+ ### PRs
474
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
475
+ ```
476
+
477
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
478
+ ```
479
+
333
480
  ## [1.1.3] - 2022-10-15
334
481
 
335
482
  ### Added
@@ -364,6 +511,13 @@
364
511
  - [littledian](https://github.com/littledian)
365
512
  - [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime)
366
513
 
514
+ ### PRs
515
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
516
+ ```
517
+
518
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
519
+ ```
520
+
367
521
  ## [1.1.2] - 2022-10-07
368
522
 
369
523
  ### Fixed
@@ -374,6 +528,13 @@
374
528
 
375
529
  - [Jason Saayman](https://github.com/jasonsaayman)
376
530
 
531
+ ### PRs
532
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
533
+ ```
534
+
535
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
536
+ ```
537
+
377
538
  ## [1.1.1] - 2022-10-07
378
539
 
379
540
  ### Fixed
@@ -384,6 +545,13 @@
384
545
 
385
546
  - [Jason Saayman](https://github.com/jasonsaayman)
386
547
 
548
+ ### PRs
549
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
550
+ ```
551
+
552
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
553
+ ```
554
+
387
555
  ## [1.1.0] - 2022-10-06
388
556
 
389
557
  ### Fixed
@@ -403,6 +571,13 @@
403
571
  - [Ivan Pepelko](https://github.com/ivanpepelko)
404
572
  - [Richard Kořínek](https://github.com/risa)
405
573
 
574
+ ### PRs
575
+ - CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) )
576
+ ```
577
+
578
+ ⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
579
+ ```
580
+
406
581
  ## [1.0.0] - 2022-10-04
407
582
 
408
583
  ### Added
package/README.md CHANGED
@@ -66,6 +66,7 @@
66
66
  - [HTML Form Posting](#-html-form-posting-browser)
67
67
  - [🆕 Progress capturing](#-progress-capturing)
68
68
  - [🆕 Rate limiting](#-progress-capturing)
69
+ - [🆕 AxiosHeaders](#-axiosheaders)
69
70
  - [Semver](#semver)
70
71
  - [Promises](#promises)
71
72
  - [TypeScript](#typescript)
@@ -1270,7 +1271,7 @@ const {data} = await axios.post(SERVER_URL, readableStream, {
1270
1271
  ````
1271
1272
 
1272
1273
  > **Note:**
1273
- > Capturing FormData upload progress is currently not currently supported in node.js environments.
1274
+ > Capturing FormData upload progress is not currently supported in node.js environments.
1274
1275
 
1275
1276
  > **⚠️ Warning**
1276
1277
  > It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment,
@@ -1291,6 +1292,260 @@ const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, {
1291
1292
  });
1292
1293
  ```
1293
1294
 
1295
+ ## 🆕 AxiosHeaders
1296
+
1297
+ Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work.
1298
+ Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons
1299
+ and for a workaround when servers mistakenly consider the header's case.
1300
+ The old approach of directly manipulating headers object is still available, but deprecated and not recommended for future usage.
1301
+
1302
+ ### Working with headers
1303
+
1304
+ An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic.
1305
+ The final headers object with string values is obtained by Axios by calling the `toJSON` method.
1306
+
1307
+ > Note: By JSON here we mean an object consisting only of string values intended to be sent over the network.
1308
+
1309
+ The header value can be one of the following types:
1310
+ - `string` - normal string value that will be sent to the server
1311
+ - `null` - skip header when rendering to JSON
1312
+ - `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true`
1313
+ to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`)
1314
+ - `undefined` - value is not set
1315
+
1316
+ > Note: The header value is considered set if it is not equal to undefined.
1317
+
1318
+ The headers object is always initialized inside interceptors and transformers:
1319
+
1320
+ ```ts
1321
+ axios.interceptors.request.use((request: InternalAxiosRequestConfig) => {
1322
+ request.headers.set('My-header', 'value');
1323
+
1324
+ request.headers.set({
1325
+ "My-set-header1": "my-set-value1",
1326
+ "My-set-header2": "my-set-value2"
1327
+ });
1328
+
1329
+ request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios
1330
+
1331
+ request.headers.setContentType('text/plain');
1332
+
1333
+ request.headers['My-set-header2'] = 'newValue' // direct access is deprecated
1334
+
1335
+ return request;
1336
+ }
1337
+ );
1338
+ ````
1339
+
1340
+ You can iterate over an `AxiosHeaders` instance using a `for...of` statement:
1341
+
1342
+ ````js
1343
+ const headers = new AxiosHeaders({
1344
+ foo: '1',
1345
+ bar: '2',
1346
+ baz: '3'
1347
+ });
1348
+
1349
+ for(const [header, value] of headers) {
1350
+ console.log(header, value);
1351
+ }
1352
+
1353
+ // foo 1
1354
+ // bar 2
1355
+ // baz 3
1356
+ ````
1357
+
1358
+ ### new AxiosHeaders(headers?)
1359
+
1360
+ Constructs a new `AxiosHeaders` instance.
1361
+
1362
+ ```
1363
+ constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
1364
+ ```
1365
+
1366
+ If the headers object is a string, it will be parsed as RAW HTTP headers.
1367
+
1368
+ ````js
1369
+ const headers = new AxiosHeaders(`
1370
+ Host: www.bing.com
1371
+ User-Agent: curl/7.54.0
1372
+ Accept: */*`);
1373
+
1374
+ console.log(headers);
1375
+
1376
+ // Object [AxiosHeaders] {
1377
+ // host: 'www.bing.com',
1378
+ // 'user-agent': 'curl/7.54.0',
1379
+ // accept: '*/*'
1380
+ // }
1381
+ ````
1382
+
1383
+ ### AxiosHeaders#set
1384
+
1385
+ ```ts
1386
+ set(headerName, value: Axios, rewrite?: boolean);
1387
+ set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean);
1388
+ set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean);
1389
+ ```
1390
+
1391
+ The `rewrite` argument controls the overwriting behavior:
1392
+ - `false` - do not overwrite if header's value is set (is not `undefined`)
1393
+ - `undefined` (default) - overwrite the header unless its value is set to `false`
1394
+ - `true` - rewrite anyway
1395
+
1396
+ The option can also accept a user-defined function that determines whether the value should be overwritten or not.
1397
+
1398
+ Returns `this`.
1399
+
1400
+ ### AxiosHeaders#get(header)
1401
+
1402
+ ```
1403
+ get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
1404
+ get(headerName: string, parser: RegExp): RegExpExecArray | null;
1405
+ ````
1406
+
1407
+ Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`,
1408
+ matcher function or internal key-value parser.
1409
+
1410
+ ```ts
1411
+ const headers = new AxiosHeaders({
1412
+ 'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h'
1413
+ });
1414
+
1415
+ console.log(headers.get('Content-Type'));
1416
+ // multipart/form-data; boundary=Asrf456BGe4h
1417
+
1418
+ console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters:
1419
+ // [Object: null prototype] {
1420
+ // 'multipart/form-data': undefined,
1421
+ // boundary: 'Asrf456BGe4h'
1422
+ // }
1423
+
1424
+
1425
+ console.log(headers.get('Content-Type', (value, name, headers) => {
1426
+ return String(value).replace(/a/g, 'ZZZ');
1427
+ }));
1428
+ // multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h
1429
+
1430
+ console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]);
1431
+ // boundary=Asrf456BGe4h
1432
+
1433
+ ```
1434
+
1435
+ Returns the value of the header.
1436
+
1437
+ ### AxiosHeaders#has(header, matcher?)
1438
+
1439
+ ```
1440
+ has(header: string, matcher?: AxiosHeaderMatcher): boolean;
1441
+ ```
1442
+
1443
+ Returns `true` if the header is set (has no `undefined` value).
1444
+
1445
+ ### AxiosHeaders#delete(header, matcher?)
1446
+
1447
+ ```
1448
+ delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
1449
+ ```
1450
+
1451
+ Returns `true` if at least one header has been removed.
1452
+
1453
+ ### AxiosHeaders#clear(matcher?)
1454
+
1455
+ ```
1456
+ clear(matcher?: AxiosHeaderMatcher): boolean;
1457
+ ```
1458
+
1459
+ Removes all headers.
1460
+ Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value.
1461
+
1462
+ ```ts
1463
+ const headers = new AxiosHeaders({
1464
+ 'foo': '1',
1465
+ 'x-foo': '2',
1466
+ 'x-bar': '3',
1467
+ });
1468
+
1469
+ console.log(headers.clear(/^x-/)); // true
1470
+
1471
+ console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' }
1472
+ ```
1473
+
1474
+ Returns `true` if at least one header has been cleared.
1475
+
1476
+ ### AxiosHeaders#normalize(format);
1477
+
1478
+ If the headers object was changed directly, it can have duplicates with the same name but in different cases.
1479
+ This method normalizes the headers object by combining duplicate keys into one.
1480
+ Axios uses this method internally after calling each interceptor.
1481
+ Set `format` to true for converting headers name to lowercase and capitalize the initial letters (`cOntEnt-type` => `Content-Type`)
1482
+
1483
+ ```js
1484
+ const headers = new AxiosHeaders({
1485
+ 'foo': '1',
1486
+ });
1487
+
1488
+ headers.Foo = '2';
1489
+ headers.FOO = '3';
1490
+
1491
+ console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' }
1492
+ console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' }
1493
+ console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' }
1494
+ ```
1495
+
1496
+ Returns `this`.
1497
+
1498
+ ### AxiosHeaders#concat(...targets)
1499
+
1500
+ ```
1501
+ concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
1502
+ ```
1503
+
1504
+ Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers.
1505
+
1506
+ Returns a new `AxiosHeaders` instance.
1507
+
1508
+ ### AxiosHeaders#toJSON(asStrings?)
1509
+
1510
+ ````
1511
+ toJSON(asStrings?: boolean): RawAxiosHeaders;
1512
+ ````
1513
+
1514
+ Resolve all internal headers values into a new null prototype object.
1515
+ Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas.
1516
+
1517
+ ### AxiosHeaders.from(thing?)
1518
+
1519
+ ````
1520
+ from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
1521
+ ````
1522
+
1523
+ Returns a new `AxiosHeaders` instance created from the raw headers passed in,
1524
+ or simply returns the given headers object if it's an `AxiosHeaders` instance.
1525
+
1526
+ ### AxiosHeaders.concat(...targets)
1527
+
1528
+ ````
1529
+ concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;
1530
+ ````
1531
+
1532
+ Returns a new `AxiosHeaders` instance created by merging the target objects.
1533
+
1534
+ ### Shortcuts
1535
+
1536
+ The following shortcuts are available:
1537
+
1538
+ - `setContentType`, `getContentType`, `hasContentType`
1539
+
1540
+ - `setContentLength`, `getContentLength`, `hasContentLength`
1541
+
1542
+ - `setAccept`, `getAccept`, `hasAccept`
1543
+
1544
+ - `setUserAgent`, `getUserAgent`, `hasUserAgent`
1545
+
1546
+ - `setContentEncoding`, `getContentEncoding`, `hasContentEncoding`
1547
+
1548
+
1294
1549
  ## Semver
1295
1550
 
1296
1551
  Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes.