http2-proxy
Advanced tools
Comparing version 5.0.1 to 5.0.2
16
index.js
@@ -32,3 +32,3 @@ const net = require('net') | ||
proxy.ws = function ws (req, socket, head, options, callback) { | ||
const promise = compat(ctx, options) | ||
const promise = compat({ req, socket, head }, options) | ||
if (!callback) { | ||
@@ -42,3 +42,3 @@ return promise | ||
proxy.web = function web (req, res, options, callback) { | ||
const promise = compat(ctx, options) | ||
const promise = compat({ req, res }, options) | ||
if (!callback) { | ||
@@ -53,2 +53,4 @@ return promise | ||
async function compat (ctx, options) { | ||
const { req, res } = ctx | ||
const { | ||
@@ -71,3 +73,3 @@ hostname, | ||
{ ...ctx, proxyName }, | ||
async ureq => { | ||
async ureq => { | ||
ureq.hostname = hostname | ||
@@ -78,5 +80,5 @@ ureq.port = port | ||
if (onReq) { | ||
return await new Promise((resolve, reject) => { | ||
return new Promise((resolve, reject) => { | ||
const promise = onReq(req, options, (err, val) => err ? reject(err) : resolve(val)) | ||
if (promise.then) { | ||
if (promise && promise.then) { | ||
promise.then(resolve).catch(reject) | ||
@@ -100,4 +102,4 @@ } | ||
return new Promise((resolve, reject) => { | ||
const promise = onRes(req, res, proxyRes, (err, val) => err ? reject(err) : callback(val)) | ||
if (promise.then) { | ||
const promise = onRes(req, res, proxyRes, (err, val) => err ? reject(err) : resolve(val)) | ||
if (promise && promise.then) { | ||
promise.then(resolve).catch(reject) | ||
@@ -104,0 +106,0 @@ } |
{ | ||
"name": "http2-proxy", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "nodemon --inspect=9308 src", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18666
365