Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

got

Package Overview
Dependencies
Maintainers
2
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got - npm Package Compare versions

Comparing version 11.0.1 to 11.0.2

5

dist/source/as-promise/core.js

@@ -24,3 +24,6 @@ "use strict";

if (!exports.knownBodyTypes.includes(responseType)) {
throw new TypeError(`Unknown body type '${responseType}'`);
throw new types_1.ParseError({
message: `Unknown body type '${responseType}'`,
name: 'Error'
}, response);
}

@@ -27,0 +30,0 @@ }

14

dist/source/as-promise/index.js

@@ -72,3 +72,4 @@ "use strict";

catch (error) {
request._beforeError(new types_1.ReadError(error, request));
// TODO: Call `request._beforeError`, see https://github.com/nodejs/node/issues/32995
reject(new types_1.ReadError(error, request));
return;

@@ -84,3 +85,4 @@ }

if (isOk()) {
request._beforeError(error);
// TODO: Call `request._beforeError`, see https://github.com/nodejs/node/issues/32995
reject(error);
return;

@@ -120,3 +122,9 @@ }

catch (error) {
request._beforeError(error);
// TODO: Call `request._beforeError`, see https://github.com/nodejs/node/issues/32995
if (error instanceof types_1.RequestError) {
reject(error);
}
else {
reject(new types_1.RequestError(error.message, error, request));
}
return;

@@ -123,0 +131,0 @@ }

/// <reference types="node" />
import PCancelable = require('p-cancelable');
import { CancelError } from 'p-cancelable';
import { Options as RequestOptions, NormalizedOptions as RequestNormalizedOptions, Defaults as RequestDefaults, Hooks as RequestHooks, Response as RequestResponse, RequestError, MaxRedirectsError, CacheError, UploadError, TimeoutError, HTTPError, ReadError, UnsupportedProtocolError, HookEvent as RequestHookEvent, InitHook, BeforeRequestHook, BeforeRedirectHook, BeforeErrorHook, Progress, Headers, RequestFunction, Method, RequestEvents } from '../core';
import { Options as RequestOptions, NormalizedOptions as RequestNormalizedOptions, Defaults as RequestDefaults, Hooks as RequestHooks, Response as RequestResponse, RequestError, MaxRedirectsError, CacheError, UploadError, TimeoutError, HTTPError, ReadError, UnsupportedProtocolError, HookEvent as RequestHookEvent, InitHook, BeforeRequestHook, BeforeRedirectHook, BeforeErrorHook, Progress, Headers, RequestFunction, Agents, Method, PromiseCookieJar, RequestEvents } from '../core';
import PromisableRequest from './core';

@@ -77,2 +77,2 @@ export declare type ResponseType = 'json' | 'buffer' | 'text';

export { InitHook, BeforeRequestHook, BeforeRedirectHook, BeforeErrorHook };
export { Progress, Headers, RequestFunction };
export { Progress, Headers, RequestFunction, Agents, Method, PromiseCookieJar };

@@ -30,2 +30,3 @@ /// <reference types="node" />

declare const kTriggerRead: unique symbol;
declare const kBody: unique symbol;
export declare const kIsNormalizedAlready: unique symbol;

@@ -242,2 +243,3 @@ export interface Agents {

[kTriggerRead]: boolean;
[kBody]: Options['body'];
[kBodySize]?: number;

@@ -244,0 +246,0 @@ [kServerResponsesPiped]: Set<ServerResponse>;

@@ -39,2 +39,3 @@ "use strict";

const kTriggerRead = Symbol('triggerRead');
const kBody = Symbol('body');
exports.kIsNormalizedAlready = Symbol('isNormalizedAlready');

@@ -556,2 +557,3 @@ const supportsBrotli = is_1.default.string(process.versions.brotli);

}
this[kBody] = options.body;
}

@@ -562,3 +564,3 @@ else if (isForm) {

}
options.body = (new url_1.URLSearchParams(options.form)).toString();
this[kBody] = (new url_1.URLSearchParams(options.form)).toString();
}

@@ -569,5 +571,5 @@ else {

}
options.body = JSON.stringify(options.json);
this[kBody] = JSON.stringify(options.json);
}
const uploadBodySize = await get_body_size_1.default(options);
const uploadBodySize = await get_body_size_1.default(this[kBody], options.headers);
// See https://tools.ietf.org/html/rfc7230#section-3.3.2

@@ -605,3 +607,3 @@ // A user agent SHOULD send a Content-Length in a request message when

const typedResponse = response;
typedResponse.statusMessage = typedResponse.statusMessage === '' ? http.STATUS_CODES[statusCode] : typedResponse.statusMessage;
typedResponse.statusMessage = typedResponse.statusMessage ? typedResponse.statusMessage : http.STATUS_CODES[statusCode];
typedResponse.url = options.url.toString();

@@ -770,9 +772,10 @@ typedResponse.requestUrl = this.requestUrl;

// Send body
const body = this[kBody];
const currentRequest = this.redirects.length === 0 ? this : request;
if (is_1.default.nodeStream(options.body)) {
options.body.pipe(currentRequest);
options.body.once('error', (error) => {
if (is_1.default.nodeStream(body)) {
body.pipe(currentRequest);
body.once('error', (error) => {
this._beforeError(new UploadError(error, this));
});
options.body.once('end', () => {
body.once('end', () => {
delete options.body;

@@ -783,4 +786,4 @@ });

this._unlockWrite();
if (!is_1.default.undefined(options.body)) {
this._writeRequest(options.body, null, () => { });
if (!is_1.default.undefined(body)) {
this._writeRequest(body, null, () => { });
currentRequest.end();

@@ -787,0 +790,0 @@ this._lockWrite();

@@ -0,8 +1,5 @@

/// <reference path="timed-out.d.ts" />
/// <reference types="node" />
import { ClientRequestArgs } from 'http';
interface Options {
body?: unknown;
headers: ClientRequestArgs['headers'];
}
declare const _default: (options: Options) => Promise<number | undefined>;
/// <reference types="node/http" />
declare const _default: (body: unknown, headers: import("http").OutgoingHttpHeaders | undefined) => Promise<number | undefined>;
export default _default;

@@ -8,4 +8,3 @@ "use strict";

const statAsync = util_1.promisify(fs_1.stat);
exports.default = async (options) => {
const { body, headers } = options;
exports.default = async (body, headers) => {
if (headers && 'content-length' in headers) {

@@ -12,0 +11,0 @@ return Number(headers['content-length']);

@@ -20,18 +20,21 @@ /// <reference types="node" />

}
export declare type OptionsOfTextResponseBody = Options & {
export declare type OptionsOfTextResponseBody = Merge<Options, {
isStream?: false;
resolveBodyOnly?: false;
responseType?: 'text';
};
export declare type OptionsOfJSONResponseBody = Options & {
}>;
export declare type OptionsOfJSONResponseBody = Merge<Options, {
isStream?: false;
resolveBodyOnly?: false;
responseType: 'json';
};
export declare type OptionsOfBufferResponseBody = Options & {
}>;
export declare type OptionsOfBufferResponseBody = Merge<Options, {
isStream?: false;
resolveBodyOnly?: false;
responseType: 'buffer';
};
}>;
export declare type StrictOptions = Except<Options, 'isStream' | 'responseType' | 'resolveBodyOnly'>;
export declare type StreamOptions = Merge<Options, {
isStream?: true;
}>;
declare type ResponseBodyOnly = {

@@ -54,14 +57,14 @@ resolveBodyOnly: true;

(options: OptionsOfBufferResponseBody): CancelableRequest<Response<Buffer>>;
(url: string | URL, options?: (OptionsOfTextResponseBody & ResponseBodyOnly)): CancelableRequest<string>;
<T>(url: string | URL, options?: (OptionsOfJSONResponseBody & ResponseBodyOnly)): CancelableRequest<T>;
(url: string | URL, options?: (OptionsOfBufferResponseBody & ResponseBodyOnly)): CancelableRequest<Buffer>;
(options: (OptionsOfTextResponseBody & ResponseBodyOnly)): CancelableRequest<string>;
<T>(options: (OptionsOfJSONResponseBody & ResponseBodyOnly)): CancelableRequest<T>;
(options: (OptionsOfBufferResponseBody & ResponseBodyOnly)): CancelableRequest<Buffer>;
(url: string | URL, options?: Options & {
(url: string | URL, options?: (Merge<OptionsOfTextResponseBody, ResponseBodyOnly>)): CancelableRequest<string>;
<T>(url: string | URL, options?: (Merge<OptionsOfJSONResponseBody, ResponseBodyOnly>)): CancelableRequest<T>;
(url: string | URL, options?: (Merge<OptionsOfBufferResponseBody, ResponseBodyOnly>)): CancelableRequest<Buffer>;
(options: (Merge<OptionsOfTextResponseBody, ResponseBodyOnly>)): CancelableRequest<string>;
<T>(options: (Merge<OptionsOfJSONResponseBody, ResponseBodyOnly>)): CancelableRequest<T>;
(options: (Merge<OptionsOfBufferResponseBody, ResponseBodyOnly>)): CancelableRequest<Buffer>;
(url: string | URL, options?: Merge<Options, {
isStream: true;
}): Request;
(options: Options & {
}>): Request;
(options: Merge<Options, {
isStream: true;
}): Request;
}>): Request;
(url: string | URL, options?: Options): CancelableRequest | Request;

@@ -72,8 +75,8 @@ (options: Options): CancelableRequest | Request;

interface GotStreamFunction {
(url: string | URL, options?: Options & {
(url: string | URL, options?: Merge<Options, {
isStream?: true;
}): Request;
(options?: Options & {
}>): Request;
(options?: Merge<Options, {
isStream?: true;
}): Request;
}>): Request;
}

@@ -80,0 +83,0 @@ export declare type GotStream = GotStreamFunction & Record<HTTPAlias, GotStreamFunction>;

{
"name": "got",
"version": "11.0.1",
"version": "11.0.2",
"description": "Human-friendly and powerful HTTP request library for Node.js",

@@ -54,3 +54,3 @@ "license": "MIT",

"get-stream": "^5.0.0",
"http2-wrapper": "^1.0.0-beta.4.3",
"http2-wrapper": "^1.0.0-beta.4.4",
"lowercase-keys": "^2.0.0",

@@ -57,0 +57,0 @@ "p-cancelable": "^2.0.0",

@@ -1199,6 +1199,6 @@ <div align="center">

```ts
import {GotRequestMethod} from 'got';
import {GotRequestFunction} from 'got';
interface Dependencies {
readonly post: GotRequestMethod
readonly post: GotRequestFunction
}

@@ -1205,0 +1205,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc