Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 23, 2024
1 parent 5489889 commit 6e1b3a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
22 changes: 21 additions & 1 deletion test/interceptors/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ for (const factory of [
headers,
body: bodyStream
} = await request(t, server, undefined, `http://${server}/301`, {
method: 'POST',
method: 'PUT',
body: createReadable('REQUEST'),
maxRedirections: 10
})
Expand All @@ -576,6 +576,26 @@ for (const factory of [
t.strictEqual(body.length, 0)
await t.completed
})

test('should follow redirects when using Readable request bodies w/ POST 101', async t => {
t = tspl(t, { plan: 1 })

const server = await startRedirectingServer()

const {
statusCode,
body: bodyStream
} = await request(t, server, undefined, `http://${server}/301`, {
method: 'POST',
body: createReadable('REQUEST'),
maxRedirections: 10
})

await bodyStream.text()

t.strictEqual(statusCode, 200)
await t.completed
})
}

test('should follow redirections when going cross origin', async t => {
Expand Down
19 changes: 18 additions & 1 deletion test/redirect-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ for (const factory of [
const server = await startRedirectingServer()

const { statusCode, headers, body: bodyStream } = await request(t, server, undefined, `http://${server}/301`, {
method: 'POST',
method: 'PUT',
body: createReadable('REQUEST'),
maxRedirections: 10
})
Expand All @@ -517,6 +517,23 @@ for (const factory of [
t.strictEqual(body.length, 0)
await t.completed
})

test('should follow redirects when using Readable request bodies for POST 301', async t => {
t = tspl(t, { plan: 1 })

const server = await startRedirectingServer()

const { statusCode, body: bodyStream } = await request(t, server, undefined, `http://${server}/301`, {
method: 'POST',
body: createReadable('REQUEST'),
maxRedirections: 10
})

await bodyStream.text()

t.strictEqual(statusCode, 200)
await t.completed
})
}

test('should follow redirections when going cross origin', async t => {
Expand Down

0 comments on commit 6e1b3a8

Please sign in to comment.