Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# fast-proxy

[![Greenkeeper badge](https://badges.greenkeeper.io/fastify/fast-proxy.svg)](https://greenkeeper.io/)
[![NPM version](https://img.shields.io/npm/v/fast-proxy.svg?style=flat)](https://www.npmjs.com/package/fast-proxy)

Node.js framework agnostic library that enables you to forward an http request to another HTTP server.
Supported protocols: HTTP, HTTPS, HTTP2
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ module.exports = (opts) => {
copyHeaders(rewriteHeaders(headers), res)
}

// set origin response code
res.statusCode = statusCode

if (onResponse) {
onResponse(req, res, stream)
} else {
res.statusCode = statusCode
pump(stream, res)
}
})
Expand Down
20 changes: 10 additions & 10 deletions 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 Expand Up @@ -34,27 +34,27 @@
},
"homepage": "https://github.com/fastify/fast-proxy",
"devDependencies": {
"0http": "^2.2.4",
"0http": "^2.5.2",
"body-parser": "^1.19.0",
"chai": "^4.2.0",
"fastify": "^2.13.1",
"fastify": "^2.15.1",
"fastify-reply-from": "^2.1.0",
"follow-redirects": "^1.11.0",
"h2url": "^0.2.0",
"http-proxy": "^1.18.0",
"mocha": "^7.1.1",
"http-proxy": "^1.18.1",
"mocha": "^7.2.0",
"nock": "^12.0.3",
"nyc": "^15.0.1",
"nyc": "^15.1.0",
"pem": "^1.14.4",
"restana": "^4.3.2",
"standard": "^14.3.3",
"restana": "^4.6.1",
"standard": "^14.3.4",
"supertest": "^4.0.2"
},
"dependencies": {
"end-of-stream": "^1.4.4",
"pump": "^3.0.0",
"semver": "^7.3.2",
"tiny-lru": "^7.0.2",
"undici": "^0.5.0"
"tiny-lru": "^7.0.6",
"undici": "^1.0.3"
}
}
19 changes: 15 additions & 4 deletions test/4.opts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,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 +91,12 @@ describe('fast-proxy smoke', () => {
})
})

it('should retrieve http status from origin', async () => {
await request(gHttpServer)
.get('/service/302')
.expect(302)
})

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