Skip to content

Commit

Permalink
https://github.com/fastify/fast-proxy/issues/30
Browse files Browse the repository at this point in the history
  • Loading branch information
yohay-ma committed Jul 3, 2020
1 parent a2a0bc6 commit 47b07b4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ typings/
# dotenv environment variables file
.env

.vscode/
.vscode/

# jetbrains webstorm
.idea
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = (opts) => {
}

if (onResponse) {
onResponse(req, res, stream)
onResponse(req, res, stream, response)
} else {
res.statusCode = statusCode
pump(stream, res)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fast-proxy",
"version": "1.6.2",
"version": "1.6.3",
"description": "Forward your HTTP request to another server.",
"main": "index.js",
"scripts": {
Expand Down
22 changes: 17 additions & 5 deletions test/4.opts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe('fast-proxy smoke', () => {
proxy(req, res, req.url, {
base: req.headers.base,
queryString: { age: 33 },
onResponse (req, res, stream) {
onResponse (req, res, stream, response) {
res.statusCode = response.statusCode
pump(stream, res)
}
})
Expand All @@ -50,10 +51,15 @@ describe('fast-proxy smoke', () => {
service = require('restana')()
service.use(bodyParser.json())

service.get('/service/headers', (req, res) => {
res.setHeader('url', req.url)
res.send()
})
service
.get('/service/headers', (req, res) => {
res.setHeader('url', req.url)
res.send()
})
.get('/service/302', (req, res) => {
res.statusCode = 302
res.end()
})

await service.start(3000)
})
Expand Down Expand Up @@ -86,6 +92,12 @@ describe('fast-proxy smoke', () => {
})
})

it('should support http status in on response', async () => {
await request(gHttpServer)
.get('/service/302')
.expect(302)
})

it('close all', async () => {
close()
await gateway.close()
Expand Down

0 comments on commit 47b07b4

Please sign in to comment.