http2-proxy
Advanced tools
Comparing version 0.2.18 to 0.2.19
21
index.js
@@ -68,3 +68,3 @@ const http2 = require('http2') | ||
(req.stream || req).on('error', onError) | ||
req.on('error', onError) | ||
resOrSocket.on('error', onError) | ||
@@ -74,3 +74,3 @@ | ||
if (req.method !== 'GET') { | ||
onError(createError('method not allowed', null, 405)) | ||
return onError(createError('method not allowed', null, 405)) | ||
} | ||
@@ -80,3 +80,3 @@ | ||
req.headers[HTTP2_HEADER_UPGRADE].toLowerCase() !== 'websocket') { | ||
onError(createError('bad request', null, 400)) | ||
return onError(createError('bad request', null, 400)) | ||
} | ||
@@ -86,3 +86,3 @@ } | ||
if (req.httpVersion !== '1.1' && req.httpVersion !== '2.0') { | ||
onError(createError('http version not supported', null, 505)) | ||
return onError(createError('http version not supported', null, 505)) | ||
} | ||
@@ -96,3 +96,3 @@ | ||
) { | ||
onError(createError('loop detected', null, 508)) | ||
return onError(createError('loop detected', null, 508)) | ||
} | ||
@@ -248,2 +248,6 @@ | ||
function getRequestHeaders (req) { | ||
const host = req.headers[HTTP2_HEADER_AUTHORITY] || req.headers[HTTP2_HEADER_HOST] | ||
const upgrade = req.headers[HTTP2_HEADER_UPGRADE] | ||
const forwarded = req.headers[HTTP2_HEADER_FORWARDED] | ||
const headers = setupHeaders(Object.assign({}, req.headers)) | ||
@@ -257,3 +261,3 @@ | ||
if (req.headers[HTTP2_HEADER_UPGRADE]) { | ||
if (upgrade) { | ||
headers[HTTP2_HEADER_CONNECTION] = 'upgrade' | ||
@@ -266,6 +270,6 @@ headers[HTTP2_HEADER_UPGRADE] = 'websocket' | ||
if (req.headers[HTTP2_HEADER_FORWARDED]) { | ||
if (forwarded) { | ||
const expr = /for=\s*([^\s]+)/ig | ||
while (true) { | ||
const m = expr.exec(req.headers[HTTP2_HEADER_FORWARDED]) | ||
const m = expr.exec(forwarded) | ||
if (!m) { | ||
@@ -278,3 +282,2 @@ break | ||
const host = req.headers[HTTP2_HEADER_AUTHORITY] || req.headers[HTTP2_HEADER_HOST] | ||
if (host) { | ||
@@ -281,0 +284,0 @@ headers[HTTP2_HEADER_FORWARDED] += `; host=${host}` |
{ | ||
"name": "http2-proxy", | ||
"version": "0.2.18", | ||
"version": "0.2.19", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "nodemon --inspect=9308 --expose-http2 src", |
@@ -9,3 +9,2 @@ # node-http2-proxy | ||
- Simple and easy to follow implementation | ||
- GC friendly with minimal allocations | ||
- [Hop by hop header handling](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) | ||
@@ -12,0 +11,0 @@ - [Connection header handling](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15001
279
5
119