Compare commits

..

No commits in common. "master" and "1.17.0" have entirely different histories.

25 changed files with 3025 additions and 3514 deletions

View File

@ -1,6 +0,0 @@
{
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": true,
"commitLimit": false
}

1
.gitattributes vendored
View File

@ -1 +0,0 @@
package-lock.json binary

View File

@ -2,8 +2,6 @@ test
examples examples
doc doc
benchmark benchmark
coverage
.nyc_output
.travis.yml .travis.yml
CHANGELOG.md CHANGELOG.md
UPGRADING.md UPGRADING.md

View File

@ -1,12 +1,16 @@
sudo: false sudo: false
language: node_js language: node_js
node_js: node_js:
- "4"
- "6"
- "8" - "8"
- "10"
- "12"
script: script:
- npm test - npm test
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash)
matrix: matrix:
fast_finish: true fast_finish: true
notifications:
email:
- travis@nodejitsu.com
irc: "irc.freenode.org#nodejitsu"

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <https://github.com/http-party/node-http-proxy>. All reported by contacting the project team at <https://github.com/nodejitsu/node-http-proxy>. All
complaints will be reviewed and investigated and will result in a response that complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident. obligated to maintain confidentiality with regard to the reporter of an incident.

View File

@ -1,8 +1,8 @@
<p align="center"> <p align="center">
<img src="https://raw.github.com/http-party/node-http-proxy/master/doc/logo.png"/> <img src="https://raw.github.com/nodejitsu/node-http-proxy/master/doc/logo.png"/>
</p> </p>
# node-http-proxy [![Build Status](https://travis-ci.org/http-party/node-http-proxy.svg?branch=master)](https://travis-ci.org/http-party/node-http-proxy) [![codecov](https://codecov.io/gh/http-party/node-http-proxy/branch/master/graph/badge.svg)](https://codecov.io/gh/http-party/node-http-proxy) # node-http-proxy [![Build Status](https://travis-ci.org/nodejitsu/node-http-proxy.svg?branch=master)](https://travis-ci.org/nodejitsu/node-http-proxy) [![codecov](https://codecov.io/gh/nodejitsu/node-http-proxy/branch/master/graph/badge.svg)](https://codecov.io/gh/nodejitsu/node-http-proxy)
`node-http-proxy` is an HTTP programmable proxying library that supports `node-http-proxy` is an HTTP programmable proxying library that supports
websockets. It is suitable for implementing components such as reverse websockets. It is suitable for implementing components such as reverse
@ -45,7 +45,7 @@ Click [here](UPGRADING.md)
### Core Concept ### Core Concept
A new proxy is created by calling `createProxyServer` and passing A new proxy is created by calling `createProxyServer` and passing
an `options` object as argument ([valid properties are available here](lib/http-proxy.js#L26-L42)) an `options` object as argument ([valid properties are available here](lib/http-proxy.js#L22-L50))
```javascript ```javascript
var httpProxy = require('http-proxy'); var httpProxy = require('http-proxy');
@ -137,7 +137,7 @@ var proxy = httpProxy.createProxyServer({});
var server = http.createServer(function(req, res) { var server = http.createServer(function(req, res) {
// You can define here your custom logic to handle the request // You can define here your custom logic to handle the request
// and then proxy the request. // and then proxy the request.
proxy.web(req, res, { target: 'http://127.0.0.1:5050' }); proxy.web(req, res, { target: 'http://127.0.0.1:5060' });
}); });
console.log("listening on port 5050") console.log("listening on port 5050")
@ -175,7 +175,7 @@ var server = http.createServer(function(req, res) {
// You can define here your custom logic to handle the request // You can define here your custom logic to handle the request
// and then proxy the request. // and then proxy the request.
proxy.web(req, res, { proxy.web(req, res, {
target: 'http://127.0.0.1:5050' target: 'http://127.0.0.1:5060'
}); });
}); });
@ -501,12 +501,12 @@ data.
selfHandleResponse : true selfHandleResponse : true
}; };
proxy.on('proxyRes', function (proxyRes, req, res) { proxy.on('proxyRes', function (proxyRes, req, res) {
var body = []; var body = new Buffer('');
proxyRes.on('data', function (chunk) { proxyRes.on('data', function (data) {
body.push(chunk); body = Buffer.concat([body, data]);
}); });
proxyRes.on('end', function () { proxyRes.on('end', function () {
body = Buffer.concat(body).toString(); body = body.toString();
console.log("res from proxied server:", body); console.log("res from proxied server:", body);
res.end("my response to cli"); res.end("my response to cli");
}); });
@ -534,7 +534,7 @@ Logo created by [Diego Pasquali](http://dribbble.com/diegopq)
### Contributing and Issues ### Contributing and Issues
* Read carefully our [Code Of Conduct](https://github.com/http-party/node-http-proxy/blob/master/CODE_OF_CONDUCT.md) * Read carefully our [Code Of Conduct](https://github.com/nodejitsu/node-http-proxy/blob/master/CODE_OF_CONDUCT.md)
* Search on Google/Github * Search on Google/Github
* If you can't find anything, open an issue * If you can't find anything, open an issue
* If you feel comfortable about fixing the issue, fork the repo * If you feel comfortable about fixing the issue, fork the repo

View File

@ -12,11 +12,11 @@ httpProxy.createServer({
}).listen(8003); }).listen(8003);
``` ```
Check the [README.md](https://github.com/http-party/node-http-proxy/blob/caronte/README.md) for a more detailed explanation of the parameters. Check the [README.md](https://github.com/nodejitsu/node-http-proxy/blob/caronte/README.md) for a more detailed explanation of the parameters.
## Proxying ## Proxying
Web proxying is done by calling the `.web()` method on a Proxy instance. You can check among some use cases in the [examples folder](https://github.com/http-party/node-http-proxy/tree/caronte/examples/http) Web proxying is done by calling the `.web()` method on a Proxy instance. You can check among some use cases in the [examples folder](https://github.com/nodejitsu/node-http-proxy/tree/caronte/examples/http)
```javascript ```javascript
// //
@ -32,7 +32,7 @@ httpProxy.createProxyServer({
``` ```
Websockets are proxied by the `.ws()` method. The [examples folder](https://github.com/http-party/node-http-proxy/tree/caronte/examples/websocket) again provides a lot of useful snippets! Websockets are proxied by the `.ws()` method. The [examples folder](https://github.com/nodejitsu/node-http-proxy/tree/caronte/examples/websocket) again provides a lot of useful snippets!
```javascript ```javascript
var proxy = new httpProxy.createProxyServer({ var proxy = new httpProxy.createProxyServer({
@ -90,7 +90,7 @@ which were in the core and delegate them to eventual "userland" modules.
### Middleware API ### Middleware API
The new API makes it really easy to implement code that behaves like the old Middleware API. You can check some examples [here](https://github.com/http-party/node-http-proxy/tree/caronte/examples/middleware) The new API makes it really easy to implement code that behaves like the old Middleware API. You can check some examples [here](https://github.com/nodejitsu/node-http-proxy/tree/caronte/examples/middleware)
### ProxyTable API ### ProxyTable API

View File

@ -1,4 +1,4 @@
var httpProxy = require('../../lib/http-proxy'); var httpProxy = require('http-proxy');
var Agent = require('agentkeepalive'); var Agent = require('agentkeepalive');
var agent = new Agent({ var agent = new Agent({

View File

@ -23,7 +23,7 @@
var http = require('http'), var http = require('http'),
net = require('net'), net = require('net'),
httpProxy = require('../../lib/http-proxy'), httpProxy = require('http-proxy'),
url = require('url'), url = require('url'),
util = require('util'); util = require('util');
@ -31,9 +31,8 @@ var proxy = httpProxy.createServer();
var server = http.createServer(function (req, res) { var server = http.createServer(function (req, res) {
util.puts('Receiving reverse proxy request for:' + req.url); util.puts('Receiving reverse proxy request for:' + req.url);
var parsedUrl = url.parse(req.url);
var target = parsedUrl.protocol + '//' + parsedUrl.hostname; proxy.web(req, res, {target: req.url, secure: false});
proxy.web(req, res, {target: target, secure: false});
}).listen(8213); }).listen(8213);
server.on('connect', function (req, socket) { server.on('connect', function (req, socket) {

View File

@ -29,7 +29,6 @@ var http = require('http'),
request = require('request'), request = require('request'),
colors = require('colors'), colors = require('colors'),
util = require('util'), util = require('util'),
queryString = require('querystring'),
bodyParser = require('body-parser'), bodyParser = require('body-parser'),
httpProxy = require('../../lib/http-proxy'), httpProxy = require('../../lib/http-proxy'),
proxy = httpProxy.createProxyServer({}); proxy = httpProxy.createProxyServer({});
@ -37,23 +36,12 @@ var http = require('http'),
//restream parsed body before proxying //restream parsed body before proxying
proxy.on('proxyReq', function(proxyReq, req, res, options) { proxy.on('proxyReq', function(proxyReq, req, res, options) {
if (!req.body || !Object.keys(req.body).length) { if(req.body) {
return; let bodyData = JSON.stringify(req.body);
} // incase if content-type is application/x-www-form-urlencoded -> we need to change to application/json
proxyReq.setHeader('Content-Type','application/json');
var contentType = proxyReq.getHeader('Content-Type');
var bodyData;
if (contentType === 'application/json') {
bodyData = JSON.stringify(req.body);
}
if (contentType === 'application/x-www-form-urlencoded') {
bodyData = queryString.stringify(req.body);
}
if (bodyData) {
proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData)); proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
// stream the content
proxyReq.write(bodyData); proxyReq.write(bodyData);
} }
}); });
@ -106,3 +94,5 @@ http.createServer(app1).listen(9013, function(){
console.log('return for urlencoded request:' ,err, data) console.log('return for urlencoded request:' ,err, data)
}) })
}); });

View File

@ -28,26 +28,24 @@ var util = require('util'),
colors = require('colors'), colors = require('colors'),
http = require('http'), http = require('http'),
connect = require('connect'), connect = require('connect'),
app = connect(),
httpProxy = require('../../lib/http-proxy'); httpProxy = require('../../lib/http-proxy');
// //
// Basic Connect App // Basic Connect App
// //
app.use(function (req, res, next) { connect.createServer(
var _write = res.write; function (req, res, next) {
var _write = res.write;
res.write = function (data) { res.write = function (data) {
_write.call(res, data.toString().replace("Ruby", "http-party")); _write.call(res, data.toString().replace("Ruby", "nodejitsu"));
}
next();
},
function (req, res) {
proxy.web(req, res);
} }
next(); ).listen(8013);
});
app.use(function (req, res) {
proxy.web(req, res)
});
http.createServer(app).listen(8013);
// //
// Basic Http Proxy Server // Basic Http Proxy Server
@ -61,7 +59,7 @@ var proxy = httpProxy.createProxyServer({
// //
http.createServer(function (req, res) { http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' }); res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello, I love Ruby\n'); res.end('Hello, I know Ruby\n');
}).listen(9013); }).listen(9013);
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8013'.yellow); util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8013'.yellow);

View File

@ -3,12 +3,13 @@
"description": "packages required to run the examples", "description": "packages required to run the examples",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"agentkeepalive": "^4.0.0", "agentkeepalive": "^2.0.3",
"colors": "~1.3.0", "colors": "~0.6.2",
"connect": "~2.11.0",
"connect-restreamer": "~1.0.0", "connect-restreamer": "~1.0.0",
"request": "~2.88.0", "request": "~2.27.0",
"socket.io": "~0.9.16", "socket.io": "~0.9.16",
"socket.io-client": "~0.9.16", "socket.io-client": "~0.9.16",
"sse": "0.0.8" "sse": "0.0.6"
} }
} }

View File

@ -37,9 +37,9 @@ function createProxyServer(options) {
* changeOrigin: <true/false, Default: false - changes the origin of the host header to the target URL> * changeOrigin: <true/false, Default: false - changes the origin of the host header to the target URL>
* preserveHeaderKeyCase: <true/false, Default: false - specify whether you want to keep letter case of response header key > * preserveHeaderKeyCase: <true/false, Default: false - specify whether you want to keep letter case of response header key >
* auth : Basic authentication i.e. 'user:password' to compute an Authorization header. * auth : Basic authentication i.e. 'user:password' to compute an Authorization header.
* hostRewrite: rewrites the location hostname on (201/301/302/307/308) redirects, Default: null. * hostRewrite: rewrites the location hostname on (301/302/307/308) redirects, Default: null.
* autoRewrite: rewrites the location host/port on (201/301/302/307/308) redirects based on requested host/port. Default: false. * autoRewrite: rewrites the location host/port on (301/302/307/308) redirects based on requested host/port. Default: false.
* protocolRewrite: rewrites the location protocol on (201/301/302/307/308) redirects to 'http' or 'https'. Default: null. * protocolRewrite: rewrites the location protocol on (301/302/307/308) redirects to 'http' or 'https'. Default: null.
* } * }
* *
* NOTE: `options.ws` and `options.ssl` are optional. * NOTE: `options.ws` and `options.ssl` are optional.

View File

@ -82,7 +82,7 @@ module.exports = {
values[header]; values[header];
}); });
req.headers['x-forwarded-host'] = req.headers['x-forwarded-host'] || req.headers['host'] || ''; req.headers['x-forwarded-host'] = req.headers['host'] || '';
}, },
/** /**
@ -129,9 +129,7 @@ module.exports = {
// Enable developers to modify the proxyReq before headers are sent // Enable developers to modify the proxyReq before headers are sent
proxyReq.on('socket', function(socket) { proxyReq.on('socket', function(socket) {
if(server && !proxyReq.getHeader('expect')) { if(server) { server.emit('proxyReq', proxyReq, req, res, options); }
server.emit('proxyReq', proxyReq, req, res, options);
}
}); });
// allow outgoing socket to timeout so that we could // allow outgoing socket to timeout so that we could

4352
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
{ {
"name": "http-proxy", "name": "http-proxy",
"version": "1.18.1", "version": "1.17.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/http-party/node-http-proxy.git" "url": "https://github.com/nodejitsu/node-http-proxy.git"
}, },
"description": "HTTP proxying for the masses", "description": "HTTP proxying for the masses",
"author": "Charlie Robbins <charlie.robbins@gmail.com>", "author": "Charlie Robbins <charlie.robbins@gmail.com>",
@ -12,30 +12,28 @@
], ],
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"eventemitter3": "^4.0.0", "eventemitter3": "^3.0.0",
"requires-port": "^1.0.0", "requires-port": "^1.0.0",
"follow-redirects": "^1.0.0" "follow-redirects": "^1.0.0"
}, },
"devDependencies": { "devDependencies": {
"async": "^3.0.0", "async": "^2.0.0",
"auto-changelog": "^1.15.0", "concat-stream": "^1.6.2",
"concat-stream": "^2.0.0",
"expect.js": "~0.3.1", "expect.js": "~0.3.1",
"mocha": "^3.5.3", "mocha": "^3.5.3",
"nyc": "^14.0.0", "nyc": "^11.7.1",
"semver": "^5.0.3", "semver": "^5.0.3",
"socket.io": "^2.1.0", "socket.io": "^2.1.0",
"socket.io-client": "^2.1.0", "socket.io-client": "^2.1.0",
"sse": "0.0.8", "sse": "0.0.6",
"ws": "^3.0.0" "ws": "^0.8.0"
}, },
"scripts": { "scripts": {
"mocha": "mocha test/*-test.js", "mocha": "mocha test/*-test.js",
"test": "nyc --reporter=text --reporter=lcov npm run mocha", "test": "nyc --reporter=text --reporter=lcov npm run mocha"
"version": "auto-changelog -p && git add CHANGELOG.md"
}, },
"engines": { "engines": {
"node": ">=8.0.0" "node": ">=4.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -1,19 +0,0 @@
{
"platform": "github",
"autodiscover": false,
"requireConfig": true,
"ignoreNpmrcFile": true,
"rangeStrategy": "replace",
"packageRules": [
{
"packagePatterns": [
"*"
],
"minor": {
"groupName": "all non-major dependencies",
"groupSlug": "all-minor-patch"
}
}
],
"commitMessagePrefix": "[dist]"
}

View File

@ -1,25 +1,13 @@
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIEIDCCAggCCQChRDh/XiBF+zANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJ1 MIIB7DCCAZYCCQC7gs0MDNn6MTANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJV
czETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEeMBwGA1UE UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO
AwwVRHVtbXkgSW50ZXJtZWRpYXRlIENBMB4XDTE4MDYyMjIwMzEwNFoXDTMyMDIy BgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEgMB4GCSqGSIb3DQEJARYR
OTIwMzEwNFowUDELMAkGA1UEBhMCdXMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAO cnlAdGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEy
BgNVBAcMB1NlYXR0bGUxGjAYBgNVBAMMEWR1bW15LmV4YW1wbGUuY29tMIIBIjAN WjB9MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYD
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvSQq3d8AeZMTvtqZ13jWCckikyXJ VQQKEwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEg
SACvkGCQUCJqOceESbg6IHdRzQdoccE4P3sbvNsf9BlbdJKM+neCxabqKaU1PPje MB4GCSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwXDANBgkqhkiG9w0BAQEF
4P0tHT57t6y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KwtP6TXga96PdMUy/p98KIM8RZlDoxB
Xy9dcZBFNn/zrqjW7R0CCWCUriDIFSmEP0wDZ91YYa6BVuJMb5uL/USkTLpjZS4/
HNGvug==
-----END CERTIFICATE----- -----END CERTIFICATE-----

10
test/fixtures/agent2-csr.pem vendored Normal file
View File

@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH
EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD
EwZhZ2VudDIxIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ
KoZIhvcNAQEBBQADSwAwSAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf
+6fVgdpVhYg5QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAaAlMCMGCSqG
SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB
AJnll2pt5l0pzskQSpjjLVTlFDFmJr/AZ3UK8v0WxBjYjCe5Jx4YehkChpxIyDUm
U3J9q9MDUf0+Y2+EGkssFfk=
-----END CERTIFICATE REQUEST-----

View File

@ -1,27 +1,9 @@
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAvSQq3d8AeZMTvtqZ13jWCckikyXJSACvkGCQUCJqOceESbg6 MIIBOgIBAAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf+6fVgdpVhYg5
IHdRzQdoccE4P3sbvNsf9BlbdJKM+neCxabqKaU1PPje4P0tHT57t6yJrMuUh9Nx QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAQJBAMT6Bf34+UHKY1ObpsbH
Ez3Bgh1srNHVS7saKvwHmcKm79jc+wxlioPm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u4Tf34ygptpapdmIFSUhfq4iOiEnRGNg/
tuNqhNCIb3LNpJbhRPEzqN7E7qiF/mp7AcJgbuxLZBm12QuLuJdG3nrisKPFXcY1
lA4A7CFmNgH3E4THFfgwzyDXsBOxVLXleTqn+rECgYEA9up1P6J3dtOJuV2d5P/3
ugRz/X173LfTSxJXw36jZDAy8D/feG19/RT4gnplcKvGNhQiVOhbOOnbw0U8n2fQ
TCmbs+cZqyxnH/+AxNsPvvk+RVHZ93xMsY/XIldP4l65B8jFDA+Zp06IESI2mEeM
pzi+bd1Phh+dRSCA2865W2MCgYEAlxYsgmQ1WyX0dFpHYU+zzfXRYzDQyrhOYc2Z
duVK+yCto1iad7pfCY/zgmRJkI+sT7DV9kJIRjXDQuTLkEyHJF8vFGe6KhxCS8aw
DIsI2g4NTd6vg1J8UryoIUqNpqsQoqNNxUVBQVdG0ReuMGsPO8R/W50AIFz0txVP
o/rP0LECgYEA7e/mOwCnR+ovmS/CAksmos3oIqvkRkXNKpKe513FVmp3TpTU38ex
cBkFNU3hEO31FyrX1hGIKp3N5mHYSQ1lyODHM6teHW0OLWWTwIe8rIGvR2jfRLe0
bbkdj40atYVkfeFmpz9uHHG24CUYxJdPc360jbXTVp4i3q8zqgL5aMY=
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----

19
test/fixtures/agent2.cnf vendored Normal file
View File

@ -0,0 +1,19 @@
[ req ]
default_bits = 1024
days = 999
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
[ req_distinguished_name ]
C = US
ST = CA
L = SF
O = Joyent
OU = Node.js
CN = agent2
emailAddress = ry@tinyclouds.org
[ req_attributes ]
challengePassword = A challenge password

View File

@ -126,50 +126,6 @@ describe('#createProxyServer.web() using own http server', function () {
http.request('http://127.0.0.1:8081', function() {}).end(); http.request('http://127.0.0.1:8081', function() {}).end();
}); });
it('should skip proxyReq event when handling a request with header "expect: 100-continue" [https://www.npmjs.com/advisories/1486]', function (done) {
var proxy = httpProxy.createProxyServer({
target: 'http://127.0.0.1:8080',
});
proxy.on('proxyReq', function(proxyReq, req, res, options) {
proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');
});
function requestHandler(req, res) {
proxy.web(req, res);
}
var proxyServer = http.createServer(requestHandler);
var source = http.createServer(function(req, res) {
source.close();
proxyServer.close();
expect(req.headers['x-special-proxy-header']).to.not.eql('foobar');
done();
});
proxyServer.listen('8081');
source.listen('8080');
const postData = ''.padStart(1025, 'x');
const postOptions = {
hostname: '127.0.0.1',
port: 8081,
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData),
'expect': '100-continue'
}
};
const req = http.request(postOptions, function() {});
req.write(postData);
req.end();
});
it('should proxy the request and handle error via callback', function(done) { it('should proxy the request and handle error via callback', function(done) {
var proxy = httpProxy.createProxyServer({ var proxy = httpProxy.createProxyServer({
target: 'http://127.0.0.1:8080' target: 'http://127.0.0.1:8080'

View File

@ -562,8 +562,8 @@ describe('lib/http-proxy.js', function() {
}); });
}); });
destiny.on('connection', function (socket, upgradeReq) { destiny.on('connection', function (socket) {
expect(upgradeReq.headers['x-special-proxy-header']).to.eql('foobar'); expect(socket.upgradeReq.headers['x-special-proxy-header']).to.eql('foobar');
socket.on('message', function (msg) { socket.on('message', function (msg) {
expect(msg).to.be('hello there'); expect(msg).to.be('hello there');

View File

@ -168,7 +168,7 @@ describe('lib/http-proxy.js', function() {
proxy.on('error', function (err, req, res) { proxy.on('error', function (err, req, res) {
expect(err).to.be.an(Error); expect(err).to.be.an(Error);
if (semver.gt(process.versions.node, '0.12.0')) { if (semver.gt(process.versions.node, '0.12.0')) {
expect(err.toString()).to.be('Error: unable to verify the first certificate') expect(err.toString()).to.be('Error: self signed certificate')
} else { } else {
expect(err.toString()).to.be('Error: DEPTH_ZERO_SELF_SIGNED_CERT') expect(err.toString()).to.be('Error: DEPTH_ZERO_SELF_SIGNED_CERT')
} }