Comparing version 10.5.7 to 10.6.0
@@ -24,3 +24,3 @@ "use strict"; | ||
} | ||
else if (options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH') { | ||
else if (options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH' || (options.allowGetBody && options.method === 'GET')) { | ||
options.body = input; | ||
@@ -27,0 +27,0 @@ } |
@@ -70,2 +70,3 @@ "use strict"; | ||
methodRewriting: true, | ||
allowGetBody: false, | ||
ignoreInvalidCookies: false, | ||
@@ -72,0 +73,0 @@ context: {}, |
@@ -196,2 +196,3 @@ "use strict"; | ||
options.methodRewriting = Boolean(options.methodRewriting); | ||
options.allowGetBody = Boolean(options.allowGetBody); | ||
options.context = (_f = options.context, (_f !== null && _f !== void 0 ? _f : {})); | ||
@@ -309,3 +310,4 @@ return options; | ||
}; | ||
const withoutBody = new Set(['GET', 'HEAD']); | ||
const withoutBody = new Set(['HEAD']); | ||
const withoutBodyUnlessSpecified = 'GET'; | ||
exports.normalizeRequestArguments = async (options) => { | ||
@@ -325,2 +327,5 @@ var _a, _b, _c; | ||
} | ||
if (!options.allowGetBody && (isBody || isForm || isJson) && withoutBodyUnlessSpecified === options.method) { | ||
throw new TypeError(`The \`${options.method}\` method cannot be used with a body`); | ||
} | ||
if ([isBody, isForm, isJson].filter(isTrue => isTrue).length > 1) { | ||
@@ -372,3 +377,3 @@ throw new TypeError('The `body`, `json` and `form` options are mutually exclusive'); | ||
if (is_1.default.undefined(headers['content-length']) && is_1.default.undefined(headers['transfer-encoding'])) { | ||
if ((options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH' || options.method === 'DELETE') && | ||
if ((options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH' || options.method === 'DELETE' || (options.allowGetBody && options.method === 'GET')) && | ||
!is_1.default.undefined(uploadBodySize)) { | ||
@@ -375,0 +380,0 @@ // @ts-ignore We assign if it is undefined, so this IS correct |
@@ -148,2 +148,3 @@ /// <reference types="node" /> | ||
lookup?: CacheableLookup['lookup']; | ||
allowGetBody?: boolean; | ||
methodRewriting?: boolean; | ||
@@ -177,2 +178,3 @@ } | ||
methodRewriting: boolean; | ||
allowGetBody: boolean; | ||
context: { | ||
@@ -179,0 +181,0 @@ [key: string]: any; |
{ | ||
"name": "got", | ||
"version": "10.5.7", | ||
"version": "10.6.0", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -53,3 +53,3 @@ "license": "MIT", | ||
"lowercase-keys": "^2.0.0", | ||
"mimic-response": "^2.0.0", | ||
"mimic-response": "^2.1.0", | ||
"p-cancelable": "^2.0.0", | ||
@@ -62,3 +62,3 @@ "p-event": "^4.0.0", | ||
"devDependencies": { | ||
"@ava/typescript": "^1.1.0", | ||
"@ava/typescript": "^1.1.1", | ||
"@sindresorhus/tsconfig": "^0.7.0", | ||
@@ -85,3 +85,3 @@ "@types/duplexer3": "^0.1.0", | ||
"lolex": "^6.0.0", | ||
"nock": "^11.8.2", | ||
"nock": "^12.0.0", | ||
"np": "^6.0.0", | ||
@@ -88,0 +88,0 @@ "nyc": "^15.0.0", |
@@ -191,3 +191,3 @@ <div align="center"> | ||
**Note #3:** If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError`. | ||
**Note #3:** If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError` unless the method is `GET` and the `allowGetBody` option is set to `true`. | ||
@@ -414,2 +414,11 @@ The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / `fs.createReadStream` instance / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`. | ||
###### allowGetBody | ||
Type: `boolean`\ | ||
Default: `false` | ||
**Note:** The [RFC 7321](https://tools.ietf.org/html/rfc7231#section-4.3.1) doesn't specify any particular behavior for the GET method having a payload, therefore **it's considered an [anti-pattern](https://en.wikipedia.org/wiki/Anti-pattern)**. | ||
Set this to `true` to allow sending body for the `GET` method. However, the [HTTP/2 specification](https://tools.ietf.org/html/rfc7540#section-8.1.3) says that `An HTTP GET request includes request header fields and no payload body`, therefore when using the HTTP/2 protocol this option will have no effect. This option is only meant to interact with non-compliant servers when you have no other choice. | ||
###### maxRedirects | ||
@@ -416,0 +425,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164829
2404
1737
Updatedmimic-response@^2.1.0