@superhero/http-request 4.0.9 → 4.0.10
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.
- package/LICENCE +21 -0
- package/index.js +3 -3
- package/index.test.js +2 -2
- package/package.json +1 -1
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Erik Landvall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/index.js
CHANGED
|
@@ -465,7 +465,7 @@ export default class Request
|
|
|
465
465
|
{
|
|
466
466
|
const errorTrace = []
|
|
467
467
|
|
|
468
|
-
let retry = Math.abs(Math.floor(options.retry))
|
|
468
|
+
let retry = Math.abs(Math.floor(options.retry))
|
|
469
469
|
|
|
470
470
|
while(retry--)
|
|
471
471
|
{
|
|
@@ -603,8 +603,8 @@ export default class Request
|
|
|
603
603
|
#createBodyHeaderDelimiter(body, isStreamed)
|
|
604
604
|
{
|
|
605
605
|
return isStreamed
|
|
606
|
-
? { 'transfer-encoding': 'chunked' }
|
|
607
|
-
: { 'content-length'
|
|
606
|
+
? { 'transfer-encoding' : 'chunked' }
|
|
607
|
+
: { 'content-length' : body?.length || 0 }
|
|
608
608
|
}
|
|
609
609
|
|
|
610
610
|
/**
|
package/index.test.js
CHANGED
|
@@ -376,14 +376,14 @@ suite('@superhero/http-request', () =>
|
|
|
376
376
|
const options =
|
|
377
377
|
{
|
|
378
378
|
url : '/retry-on-status',
|
|
379
|
-
retry : 2,
|
|
379
|
+
retry : 2,
|
|
380
380
|
retryDelay : 100,
|
|
381
381
|
retryOnStatus : [ 503 ]
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
await assert.rejects(
|
|
385
385
|
request.get(options),
|
|
386
|
-
|
|
386
|
+
{ code:'E_HTTP_REQUEST_INVALID_RESPONSE_STATUS' },
|
|
387
387
|
'Should throw an error after the second attempt')
|
|
388
388
|
|
|
389
389
|
assert.equal(attempt, 2, 'Should make exactly 2 attempts')
|