Skip to content

Commit

Permalink
Remove enable from the option name
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Nov 25, 2019
1 parent 336f914 commit 1d3432c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -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`<br>
Default: `true`
Expand Down
2 changes: 1 addition & 1 deletion source/index.ts
Expand Up @@ -57,7 +57,7 @@ const defaults: Defaults = {
resolveBodyOnly: false,
maxRedirects: 10,
prefixUrl: '',
enableMethodRewriting: true
methodRewriting: true
},
handlers: [defaultHandler],
mutableDefaults: false
Expand Down
2 changes: 1 addition & 1 deletion source/request-as-event-emitter.ts
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion source/utils/types.ts
Expand Up @@ -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<Options, keyof URLOptions> {
Expand Down
2 changes: 1 addition & 1 deletion test/redirects.ts
Expand Up @@ -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 => {
Expand Down

0 comments on commit 1d3432c

Please sign in to comment.