got 14.6.4 → 14.6.6

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.
@@ -24,8 +24,6 @@ import { generateRequestId, publishRequestCreate, publishRequestStart, publishRe
24
24
  const supportsBrotli = is.string(process.versions.brotli);
25
25
  const supportsZstd = is.string(process.versions.zstd);
26
26
  const methodsWithoutBody = new Set(['GET', 'HEAD']);
27
- // Methods that should auto-end streams when no body is provided
28
- const methodsWithoutBodyStream = new Set(['OPTIONS', 'DELETE', 'PATCH']);
29
27
  const cacheableStore = new WeakableMap();
30
28
  const redirectCodes = new Set([300, 301, 302, 303, 304, 307, 308]);
31
29
  // Track errors that have been processed by beforeError hooks to preserve custom error types
@@ -923,8 +921,7 @@ export default class Request extends Duplex {
923
921
  else if (is.undefined(body)) {
924
922
  // No body to send, end the request
925
923
  const cannotHaveBody = methodsWithoutBody.has(this.options.method) && !(this.options.method === 'GET' && this.options.allowGetBody);
926
- const shouldAutoEndStream = methodsWithoutBodyStream.has(this.options.method);
927
- if ((this._noPipe ?? false) || cannotHaveBody || currentRequest !== this || shouldAutoEndStream) {
924
+ if ((this._noPipe ?? false) || cannotHaveBody || currentRequest !== this) {
928
925
  currentRequest.end();
929
926
  }
930
927
  }
@@ -176,7 +176,9 @@ export type OptionsOfUnknownResponseBodyWrapped = Merge<StrictOptions, {
176
176
  isStream?: false;
177
177
  resolveBodyOnly: false;
178
178
  }>;
179
+ type DefaultResponseBodyType<U extends ExtendOptions> = U['responseType'] extends 'json' ? unknown : U['responseType'] extends 'buffer' ? Buffer : string;
179
180
  export type GotRequestFunction<U extends ExtendOptions = Record<string, unknown>> = {
181
+ (url: string | URL): U['resolveBodyOnly'] extends true ? CancelableRequest<DefaultResponseBodyType<U>> : CancelableRequest<Response<DefaultResponseBodyType<U>>>;
180
182
  (url: string | URL, options?: OptionsOfTextResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<string> : CancelableRequest<Response<string>>;
181
183
  <T>(url: string | URL, options?: OptionsOfJSONResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<T> : CancelableRequest<Response<T>>;
182
184
  (url: string | URL, options?: OptionsOfBufferResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<Buffer> : CancelableRequest<Response<Buffer>>;
@@ -189,6 +191,9 @@ export type GotRequestFunction<U extends ExtendOptions = Record<string, unknown>
189
191
  <T>(url: string | URL, options?: OptionsOfJSONResponseBodyOnly): CancelableRequest<T>;
190
192
  (url: string | URL, options?: OptionsOfBufferResponseBodyOnly): CancelableRequest<Buffer>;
191
193
  (url: string | URL, options?: OptionsOfUnknownResponseBodyOnly): CancelableRequest;
194
+ (options: {
195
+ url: string | URL;
196
+ }): U['resolveBodyOnly'] extends true ? CancelableRequest<DefaultResponseBodyType<U>> : CancelableRequest<Response<DefaultResponseBodyType<U>>>;
192
197
  (options: OptionsOfTextResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<string> : CancelableRequest<Response<string>>;
193
198
  <T>(options: OptionsOfJSONResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<T> : CancelableRequest<Response<T>>;
194
199
  (options: OptionsOfBufferResponseBody): U['resolveBodyOnly'] extends true ? CancelableRequest<Buffer> : CancelableRequest<Response<Buffer>>;
@@ -238,6 +243,8 @@ export type Got<GotOptions extends ExtendOptions = ExtendOptions> = {
238
243
  - uploadProgress
239
244
  - downloadProgress
240
245
  - error
246
+
247
+ Note: For writable request streams, call `stream.end()` when you are not piping a body. `got.stream` does not auto-end for OPTIONS, DELETE, or PATCH so you can pipe or write a body without getting `write after end`.
241
248
  */
242
249
  stream: GotStream;
243
250
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "got",
3
- "version": "14.6.4",
3
+ "version": "14.6.6",
4
4
  "description": "Human-friendly and powerful HTTP request library for Node.js",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/got",
package/readme.md CHANGED
@@ -22,6 +22,22 @@
22
22
  <img src="https://sindresorhus.com/assets/thanks/fame-logo-dark.svg" width="200" alt="Fame Helsinki">
23
23
  </a>
24
24
  <br>
25
+ <br>
26
+ <br>
27
+ <br>
28
+ <a href="https://depot.dev?utm_source=github&utm_medium=sindresorhus">
29
+ <div>
30
+ <picture>
31
+ <source width="180" media="(prefers-color-scheme: dark)" srcset="https://sindresorhus.com/assets/thanks/depot-logo-dark.svg">
32
+ <source width="180" media="(prefers-color-scheme: light)" srcset="https://sindresorhus.com/assets/thanks/depot-logo-light.svg">
33
+ <img width="180" src="https://sindresorhus.com/assets/thanks/depot-logo-light.svg" alt="Depot logo">
34
+ </picture>
35
+ </div>
36
+ <b>Fast remote container builds and GitHub Actions runners.</b>
37
+ </a>
38
+ <br>
39
+ <br>
40
+ <br>
25
41
  </p>
26
42
  <hr>
27
43
  <br>