http2-proxy
Advanced tools
Comparing version 5.0.45 to 5.0.46
{ | ||
"name": "http2-proxy", | ||
"version": "5.0.45", | ||
"version": "5.0.46", | ||
"scripts": { | ||
@@ -38,13 +38,13 @@ "test": "jest", | ||
"devDependencies": { | ||
"babel-eslint": "^10.0.3", | ||
"eslint": "^6.2.2", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jest": "^22.16.0", | ||
"eslint-plugin-node": "^9.2.0", | ||
"babel-eslint": "^10.1.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-standard": "^14.1.1", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"husky": "^3.0.0", | ||
"jest": "^24.9.0", | ||
"prettier": "^1.18.2", | ||
"husky": "^4.2.5", | ||
"jest": "^25.4.0", | ||
"prettier": "^2.0.5", | ||
"validate-commit-msg": "^2.14.0" | ||
@@ -51,0 +51,0 @@ }, |
# http2-proxy | ||
A simple http/2 & http/1.1 to http/1.1 spec compliant proxy helper for Node. | ||
A simple http/2 & http/1.1 spec compliant proxy helper for Node. | ||
@@ -153,2 +153,24 @@ ## Features | ||
### Proxy HTTP2 | ||
HTTP proxying can be achieved using http2 client compat | ||
libraries such as: | ||
https://github.com/hisco/http2-client | ||
https://github.com/spdy-http2/node-spdy | ||
https://github.com/grantila/fetch-h2 | ||
https://github.com/szmarczak/http2-wrapper | ||
```js | ||
const http = require('http2-wrapper') | ||
server.on('request', (req, res) => { | ||
proxy.web(req, res, { | ||
hostname: 'localhost' | ||
port: 9000, | ||
onReq: (req, options) => http.request(options) | ||
}, defaultWebHandler) | ||
}) | ||
``` | ||
### Try Multiple Upstream Servers (Advanced) | ||
@@ -165,3 +187,3 @@ | ||
for await (const { port, timeout, hostname } of upstream) { | ||
if (req.aborted || finished) { | ||
if (req.aborted || res.readableEnded) { | ||
return | ||
@@ -171,3 +193,2 @@ } | ||
let error = null | ||
let finished = false | ||
let bytesWritten = 0 | ||
@@ -205,10 +226,5 @@ try { | ||
.on('end', () => { | ||
// WORKAROUND: https://github.com/nodejs/node/pull/27984 | ||
if (!proxyRes.aborted) { | ||
setHeaders() | ||
res.addTrailers(proxyRes.trailers) | ||
res.end() | ||
// WORKAROUND: https://github.com/nodejs/node/pull/24347 | ||
finished = true | ||
} | ||
setHeaders() | ||
res.addTrailers(proxyRes.trailers) | ||
res.end() | ||
}) | ||
@@ -293,22 +309,4 @@ .on('close', () => { | ||
## Node | ||
These are some existing issues in NodeJS to keep in mind when writing proxy code. | ||
- https://github.com/nodejs/node/issues/27981 | ||
- https://github.com/nodejs/node/issues/28001 | ||
- https://github.com/nodejs/node/issues/27880 | ||
- https://github.com/nodejs/node/issues/24743 | ||
- https://github.com/nodejs/node/issues/24742 | ||
And some pending PR's: | ||
- https://github.com/nodejs/node/pull/28004 | ||
- https://github.com/nodejs/node/pull/27984 | ||
- https://github.com/nodejs/node/pull/24347 | ||
Some of these are further referenced in the examples. | ||
## License | ||
[MIT](LICENSE) |
33224
27444
308