diff --git a/source/as-promise/index.ts b/source/as-promise/index.ts index 2a4291b8f..2d0da2379 100644 --- a/source/as-promise/index.ts +++ b/source/as-promise/index.ts @@ -149,6 +149,8 @@ export default function asPromise(firstRequest: Request): CancelableRequest { message }); }); + +test('formdata retry', withServer, async (t, server, got) => { + server.post('/', echoHeaders); + + const instance = got.extend({ + hooks: { + afterResponse: [ + async (_response, retryWithMergedOptions) => { + return retryWithMergedOptions({ + headers: { + foo: 'bar' + } + }); + } + ] + } + }); + + const form = new FormData(); + form.append('hello', 'world'); + + await t.throwsAsync(instance.post({ + body: form, + headers: form.getHeaders() + }).json<{foo?: string}>(), { + message: 'Cannot retry with consumed body stream' + }); +});