diff --git a/readme.md b/readme.md index c51ff1c91..a11a52de1 100644 --- a/readme.md +++ b/readme.md @@ -408,7 +408,7 @@ Defines if redirect responses should be followed automatically. Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), Got will automatically request the resource pointed to in the location header via `GET`. This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4). -###### enableMethodRewriting +###### methodRewriting Type: `boolean`
Default: `true` diff --git a/source/index.ts b/source/index.ts index 871074ee7..49ef41b14 100644 --- a/source/index.ts +++ b/source/index.ts @@ -57,7 +57,7 @@ const defaults: Defaults = { resolveBodyOnly: false, maxRedirects: 10, prefixUrl: '', - enableMethodRewriting: true + methodRewriting: true }, handlers: [defaultHandler], mutableDefaults: false diff --git a/source/request-as-event-emitter.ts b/source/request-as-event-emitter.ts index 36b72775c..9b82276b9 100644 --- a/source/request-as-event-emitter.ts +++ b/source/request-as-event-emitter.ts @@ -96,7 +96,7 @@ export default (options: NormalizedOptions) => { if (options.followRedirect && Reflect.has(typedResponse.headers, 'location') && redirectCodes.has(statusCode)) { typedResponse.resume(); // We're being redirected, we don't care about the response. - if (statusCode === 303 || options.enableMethodRewriting === false) { + if (statusCode === 303 || options.methodRewriting === false) { if (options.method !== 'GET' && options.method !== 'HEAD') { // Server responded with "see other", indicating that the resource exists at another location, // and the client should request it from that location via GET or HEAD. diff --git a/source/utils/types.ts b/source/utils/types.ts index 9aadf8a76..e5a90aa08 100644 --- a/source/utils/types.ts +++ b/source/utils/types.ts @@ -153,7 +153,7 @@ export interface Options extends URLOptions { context?: {[key: string]: unknown}; maxRedirects?: number; lookup?: CacheableLookup['lookup']; - enableMethodRewriting?: boolean; + methodRewriting?: boolean; } export interface NormalizedOptions extends Except { diff --git a/test/redirects.ts b/test/redirects.ts index b77d2ddaa..b2c40f357 100644 --- a/test/redirects.ts +++ b/test/redirects.ts @@ -377,7 +377,7 @@ test('method overwriting can be turned off', withServer, async (t, server, got) const {body} = await got.post('redirect', { body: 'foobar', - enableMethodRewriting: false, + methodRewriting: false, hooks: { beforeRedirect: [ options => {