Skip to content

307 & 308 redirect should preserve body per RFC #2459

Description

@winewine

got starting from version 15 started dropping request body when followRedirect: true

The comment is wrong in the source code

got/source/core/index.ts

Lines 1088 to 1089 in e5e645a

// 301/302 POST already drops the body (converted to GET above).
// 307/308 preserve the method per RFC, but the body must not be

and the shouldDropBody flag
this._stripCrossOriginState(updatedOptions, redirectUrl, shouldDropBody);

should be false when http status code is 307 or 308

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308

all other major http clients (including ky) I have tested retains the body on POST method when encountering 308 redirect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions