got 12.0.4 → 12.1.0
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.
|
@@ -19,6 +19,7 @@ import calculateRetryDelay from './calculate-retry-delay.js';
|
|
|
19
19
|
import Options from './options.js';
|
|
20
20
|
import { isResponseOk } from './response.js';
|
|
21
21
|
import isClientRequest from './utils/is-client-request.js';
|
|
22
|
+
import isUnixSocketURL from './utils/is-unix-socket-url.js';
|
|
22
23
|
import { RequestError, ReadError, MaxRedirectsError, HTTPError, TimeoutError, UploadError, CacheError, } from './errors.js';
|
|
23
24
|
const supportsBrotli = is.string(process.versions.brotli);
|
|
24
25
|
const methodsWithoutBody = new Set(['GET', 'HEAD']);
|
|
@@ -557,6 +558,7 @@ export default class Request extends Duplex {
|
|
|
557
558
|
typedResponse.isFromCache = this._nativeResponse.fromCache ?? false;
|
|
558
559
|
typedResponse.ip = this.ip;
|
|
559
560
|
typedResponse.retryCount = this.retryCount;
|
|
561
|
+
typedResponse.ok = isResponseOk(typedResponse);
|
|
560
562
|
this._isFromCache = typedResponse.isFromCache;
|
|
561
563
|
this._responseSize = Number(response.headers['content-length']) || undefined;
|
|
562
564
|
this.response = typedResponse;
|
|
@@ -630,6 +632,10 @@ export default class Request extends Duplex {
|
|
|
630
632
|
// We need this in order to support UTF-8
|
|
631
633
|
const redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();
|
|
632
634
|
const redirectUrl = new URL(redirectBuffer, url);
|
|
635
|
+
if (!isUnixSocketURL(url) && isUnixSocketURL(redirectUrl)) {
|
|
636
|
+
this._beforeError(new RequestError('Cannot redirect to UNIX socket', {}, this));
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
633
639
|
// Redirecting to a different site, clear sensitive data.
|
|
634
640
|
if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) {
|
|
635
641
|
if ('host' in updatedOptions.headers) {
|
|
@@ -80,6 +80,12 @@ export interface PlainResponse extends IncomingMessageWithTimings {
|
|
|
80
80
|
The result of the request.
|
|
81
81
|
*/
|
|
82
82
|
body?: unknown;
|
|
83
|
+
/**
|
|
84
|
+
Whether the response was successful.
|
|
85
|
+
|
|
86
|
+
__Note__: Got throws automatically when `response.ok` is `false` and `throwHttpErrors` is `true`.
|
|
87
|
+
*/
|
|
88
|
+
ok: boolean;
|
|
83
89
|
}
|
|
84
90
|
export interface Response<T = unknown> extends PlainResponse {
|
|
85
91
|
/**
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -46,6 +46,72 @@
|
|
|
46
46
|
<br>
|
|
47
47
|
<br>
|
|
48
48
|
<br>
|
|
49
|
+
<a href="https://neverinstall.com/spaces/devtools?utm_source=github&utm_medium=sponsor&utm_campaign=sindre#gh-light-mode-only">
|
|
50
|
+
<div>
|
|
51
|
+
<img src="https://sindresorhus.com/assets/thanks/neverinstall-logo-light.svg" width="200" alt="neverinstall">
|
|
52
|
+
</div>
|
|
53
|
+
<br>
|
|
54
|
+
<b>All your favourite IDE's now available on the cloud</b>
|
|
55
|
+
<div>
|
|
56
|
+
<sub>
|
|
57
|
+
Neverinstall gives you an uninterrupted development experience and improved accessibility,
|
|
58
|
+
<br>
|
|
59
|
+
allowing you to code faster, better and on-the-go on your favourite IDEs like
|
|
60
|
+
<br>
|
|
61
|
+
Android Studio, VS Code, Jupyter and PyCharm using your browser.
|
|
62
|
+
</sub>
|
|
63
|
+
</div>
|
|
64
|
+
</a>
|
|
65
|
+
<a href="https://neverinstall.com/spaces/devtools?utm_source=github&utm_medium=sponsor&utm_campaign=sindre#gh-dark-mode-only">
|
|
66
|
+
<div>
|
|
67
|
+
<img src="https://sindresorhus.com/assets/thanks/neverinstall-logo-dark.svg" width="200" alt="neverinstall">
|
|
68
|
+
</div>
|
|
69
|
+
<br>
|
|
70
|
+
<b>All your favourite IDE's now available on the cloud</b>
|
|
71
|
+
<div>
|
|
72
|
+
<sub>
|
|
73
|
+
Neverinstall gives you an uninterrupted development experience and improved accessibility,
|
|
74
|
+
<br>
|
|
75
|
+
allowing you to code faster, better and on-the-go on your favourite IDEs like
|
|
76
|
+
<br>
|
|
77
|
+
Android Studio, VS Code, Jupyter and PyCharm using your browser.
|
|
78
|
+
</sub>
|
|
79
|
+
</div>
|
|
80
|
+
</a>
|
|
81
|
+
<br>
|
|
82
|
+
<br>
|
|
83
|
+
<br>
|
|
84
|
+
<a href="https://www.useanvil.com/?utm_source=sindresorhus#gh-light-mode-only">
|
|
85
|
+
<div>
|
|
86
|
+
<img src="https://sindresorhus.com/assets/thanks/anvil-logo-light.svg" width="200" alt="Anvil">
|
|
87
|
+
</div>
|
|
88
|
+
<br>
|
|
89
|
+
<b>Paperwork that makes the data work.</b>
|
|
90
|
+
<div>
|
|
91
|
+
<sub>
|
|
92
|
+
Easy APIs for paperwork. PDF generation, e-signature and embeddable no-code webforms.
|
|
93
|
+
<br>
|
|
94
|
+
The easiest way to build paperwork automation into your product.
|
|
95
|
+
</sub>
|
|
96
|
+
</div>
|
|
97
|
+
</a>
|
|
98
|
+
<a href="https://www.useanvil.com/?utm_source=sindresorhus#gh-dark-mode-only">
|
|
99
|
+
<div>
|
|
100
|
+
<img src="https://sindresorhus.com/assets/thanks/anvil-logo-dark.svg" width="200" alt="Anvil">
|
|
101
|
+
</div>
|
|
102
|
+
<br>
|
|
103
|
+
<b>Paperwork that makes the data work.</b>
|
|
104
|
+
<div>
|
|
105
|
+
<sub>
|
|
106
|
+
Easy APIs for paperwork. PDF generation, e-signature and embeddable no-code webforms.
|
|
107
|
+
<br>
|
|
108
|
+
The easiest way to build paperwork automation into your product.
|
|
109
|
+
</sub>
|
|
110
|
+
</div>
|
|
111
|
+
</a>
|
|
112
|
+
<br>
|
|
113
|
+
<br>
|
|
114
|
+
<br>
|
|
49
115
|
<br>
|
|
50
116
|
</p>
|
|
51
117
|
<br>
|