Skip to content

Commit 7c891d5

Browse files
committed
fix: tests
1 parent 71c9baf commit 7c891d5

File tree

3 files changed

+28
-35
lines changed

3 files changed

+28
-35
lines changed

lib/handler/redirect-handler.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,3 @@ function cleanRequestHeaders (headers, removeContent, unknownOrigin) {
240240
}
241241

242242
module.exports = RedirectHandler
243-
module.exports.cleanRequestHeaders = cleanRequestHeaders

test/clean-request-headers.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/redirect-request.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,34 @@ for (const factory of [
227227
await t.completed
228228
})
229229

230+
test('should remove Host and request body related headers when following HTTP 303 (Header)', async t => {
231+
t = tspl(t, { plan: 3 })
232+
233+
const server = await startRedirectingServer()
234+
235+
const { statusCode, headers, body: bodyStream } = await request(t, server, undefined, `http://${server}/303`, {
236+
method: 'PATCH',
237+
headers: new Headers({
238+
'Content-Encoding': 'gzip',
239+
'X-Foo1': '1',
240+
'X-Foo2': '2',
241+
'Content-Type': 'application/json',
242+
'X-Foo3': '3',
243+
Host: 'localhost',
244+
'X-Bar': '4'
245+
}),
246+
maxRedirections: 10
247+
})
248+
249+
const body = await bodyStream.text()
250+
251+
t.strictEqual(statusCode, 200)
252+
t.ok(!headers.location)
253+
t.strictEqual(body, `GET /5 :: host@${server} connection@keep-alive x-bar@4 x-foo1@1 x-foo2@2 x-foo3@3`)
254+
255+
await t.completed
256+
})
257+
230258
test('should follow redirection after a HTTP 307', async t => {
231259
t = tspl(t, { plan: 3 })
232260

0 commit comments

Comments
 (0)