Compare commits

...

33 Commits

Author SHA1 Message Date
Jarrett Cruger
9b96cd7251 1.18.1 2020-05-17 17:26:59 -04:00
Jason
335aeeba2f
Skip sending the proxyReq event when the expect header is present (#1447)
* Skip sending the proxyReq event when the expect header is present

* Adjust padding to match advisory

Co-authored-by: Smylnycky, Jason M <jason.smylnycky@cengage.com>
2020-05-17 17:18:42 -04:00
Jason
dba39668ba
Remove node6 support, add node12 to build (#1397) 2020-05-17 17:16:55 -04:00
indexzero
9bbe486c5e [dist] Version bump. 1.18.0 2019-09-17 21:40:59 -04:00
Jason
6e4bef4d1c
Added in auto-changelog module set to keepachangelog format (#1373)
Removed last nodejitsu reference
2019-09-05 14:11:16 -04:00
Nick Gilligan
d05624167c fix 'Modify Response' readme section to avoid unnecessary array copying (#1300) 2019-08-22 02:40:15 -05:00
IdeaHunter
244303b994 Fix incorrect target name for reverse proxy example (#1135) 2019-08-22 02:39:14 -05:00
Ben Costolo
b4028ba78b Fix modify response middleware example (#1139)
* declare app variable to house middleware

* remove deprecated connect.createServer() function call

* specify middleware with app.use() and pass app middleware to an http
server
2019-08-22 02:38:28 -05:00
renovate[bot]
77a98159d2 [dist] Update dependency async to v3 (#1359) 2019-08-22 02:37:57 -05:00
Kristoffer Lundén
c662f9ebcd Fix path to local http-proxy in examples. (#1072) 2019-08-22 02:35:20 -05:00
Li Bin
806e4927c9 fix reverse-proxy example require path (#1067) 2019-08-22 02:34:29 -05:00
Subomi Oluwalana
c8fa599983 Update README.md (#970)
There were errors in the examples highlighted, check issue #969
2019-08-22 02:31:44 -05:00
renovate[bot]
0d9ed366b1 [dist] Update dependency request to ~2.88.0 [SECURITY] (#1357) 2019-08-22 02:30:06 -05:00
renovate[bot]
9d75b981a1 [dist] Update dependency eventemitter3 to v4 (#1365) 2019-08-22 02:29:37 -05:00
renovate[bot]
192b2b980b [dist] Update dependency colors to v1 (#1360) 2019-08-22 02:29:14 -05:00
renovate[bot]
4a657a7126 [dist] Update all non-major dependencies (#1356) 2019-08-22 02:24:41 -05:00
renovate[bot]
7a154f81d1 [dist] Update dependency agentkeepalive to v4 (#1358) 2019-08-22 02:24:25 -05:00
renovate[bot]
749eec65c3 [dist] Update dependency nyc to v14 (#1367) 2019-08-22 02:21:15 -05:00
renovate[bot]
e588213644 [dist] Update dependency concat-stream to v2 (#1363) 2019-08-22 02:16:50 -05:00
indexzero
59c4403e9d [fix] Latest versions. 2019-08-22 02:12:51 -05:00
indexzero
dd1d08b631 [fix test] Update tests. 2019-08-22 02:12:51 -05:00
indexzero
16d4f8a951 [dist] Regenerate package-lock.json. 2019-08-22 02:12:51 -05:00
indexzero
fc93520d74 [dist] .gitattributes all the things. 2019-08-22 02:12:51 -05:00
indexzero
7e4a0e511b [dist] New test fixtures. 2019-08-22 02:12:51 -05:00
indexzero
a9b09cce43 [dist] End of an era. 2019-08-22 02:12:51 -05:00
Renovate Bot
b00911c937 [dist] Update dependency ws to v3 [SECURITY] 2019-08-22 02:12:51 -05:00
Jaggernoth
36bfe566a7 x-forwarded-host overwrite for mutli level proxies (#1267)
With more than 1 proxy the original host was lost, now it will be passed down the proxy chain
2019-08-22 02:09:26 -05:00
Charlie Robbins
91fee3e943
[refactor doc] Complete rename to http-party org. (#1362) 2019-08-22 01:46:16 -05:00
Justin Russell
235f0aa047 Highlight correct lines for createProxyServer (#1117) 2019-08-22 01:41:47 -05:00
Stein Martin Hustad
acdbec09c6 Fix docs for rewrite options - 201 also handled (#1147)
Updates options documentation for location rewrite to include 201 responses. See #1024
2019-08-22 01:40:03 -05:00
Marcin K
569e2ac4fb Update .nyc_output (#1339)
Currently published version includes .nyc_output and coverage
2019-08-22 01:39:17 -05:00
renovate[bot]
cb3171abfa Configure Renovate (#1355)
* Add renovate.json

* [dist] Configure renovate more.
2019-08-22 01:38:48 -05:00
任侠
a3fe02d651 [examples] Restream body before proxying, support for Content-Type of application/x-www-form-urlencoded (#1264) 2018-06-06 12:39:50 -04:00
25 changed files with 3527 additions and 3038 deletions

6
.auto-changelog Normal file
View File

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

1
.gitattributes vendored Normal file
View File

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

View File

@ -2,6 +2,8 @@ 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,16 +1,12 @@
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"

1872
CHANGELOG.md Normal file

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/nodejitsu/node-http-proxy>. All reported by contacting the project team at <https://github.com/http-party/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/nodejitsu/node-http-proxy/master/doc/logo.png"/> <img src="https://raw.github.com/http-party/node-http-proxy/master/doc/logo.png"/>
</p> </p>
# 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 [![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` 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#L22-L50)) an `options` object as argument ([valid properties are available here](lib/http-proxy.js#L26-L42))
```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:5060' }); proxy.web(req, res, { target: 'http://127.0.0.1:5050' });
}); });
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:5060' target: 'http://127.0.0.1:5050'
}); });
}); });
@ -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 = new Buffer(''); var body = [];
proxyRes.on('data', function (data) { proxyRes.on('data', function (chunk) {
body = Buffer.concat([body, data]); body.push(chunk);
}); });
proxyRes.on('end', function () { proxyRes.on('end', function () {
body = body.toString(); body = Buffer.concat(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/nodejitsu/node-http-proxy/blob/master/CODE_OF_CONDUCT.md) * Read carefully our [Code Of Conduct](https://github.com/http-party/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/nodejitsu/node-http-proxy/blob/caronte/README.md) for a more detailed explanation of the parameters. Check the [README.md](https://github.com/http-party/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/nodejitsu/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/http-party/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/nodejitsu/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/http-party/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/nodejitsu/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/http-party/node-http-proxy/tree/caronte/examples/middleware)
### ProxyTable API ### ProxyTable API

View File

@ -1,4 +1,4 @@
var httpProxy = require('http-proxy'); var httpProxy = require('../../lib/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('http-proxy'), httpProxy = require('../../lib/http-proxy'),
url = require('url'), url = require('url'),
util = require('util'); util = require('util');
@ -31,8 +31,9 @@ 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);
proxy.web(req, res, {target: req.url, secure: false}); var target = parsedUrl.protocol + '//' + parsedUrl.hostname;
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,6 +29,7 @@ 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({});
@ -36,12 +37,23 @@ 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) { if (!req.body || !Object.keys(req.body).length) {
let bodyData = JSON.stringify(req.body); return;
// 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);
} }
}); });
@ -94,5 +106,3 @@ 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,24 +28,26 @@ 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
// //
connect.createServer( app.use(function (req, res, next) {
function (req, res, next) { var _write = res.write;
var _write = res.write;
res.write = function (data) { res.write = function (data) {
_write.call(res, data.toString().replace("Ruby", "nodejitsu")); _write.call(res, data.toString().replace("Ruby", "http-party"));
}
next();
},
function (req, res) {
proxy.web(req, res);
} }
).listen(8013); next();
});
app.use(function (req, res) {
proxy.web(req, res)
});
http.createServer(app).listen(8013);
// //
// Basic Http Proxy Server // Basic Http Proxy Server
@ -59,7 +61,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 know Ruby\n'); res.end('Hello, I love 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,13 +3,12 @@
"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": "^2.0.3", "agentkeepalive": "^4.0.0",
"colors": "~0.6.2", "colors": "~1.3.0",
"connect": "~2.11.0",
"connect-restreamer": "~1.0.0", "connect-restreamer": "~1.0.0",
"request": "~2.27.0", "request": "~2.88.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.6" "sse": "0.0.8"
} }
} }

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 (301/302/307/308) redirects, Default: null. * hostRewrite: rewrites the location hostname on (201/301/302/307/308) redirects, Default: null.
* autoRewrite: rewrites the location host/port on (301/302/307/308) redirects based on requested host/port. Default: false. * autoRewrite: rewrites the location host/port on (201/301/302/307/308) redirects based on requested host/port. Default: false.
* protocolRewrite: rewrites the location protocol on (301/302/307/308) redirects to 'http' or 'https'. Default: null. * protocolRewrite: rewrites the location protocol on (201/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['host'] || ''; req.headers['x-forwarded-host'] = req.headers['x-forwarded-host'] || req.headers['host'] || '';
}, },
/** /**
@ -129,7 +129,9 @@ 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) { server.emit('proxyReq', proxyReq, req, res, options); } if(server && !proxyReq.getHeader('expect')) {
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

4378
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.17.0", "version": "1.18.1",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/nodejitsu/node-http-proxy.git" "url": "https://github.com/http-party/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,28 +12,30 @@
], ],
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"eventemitter3": "^3.0.0", "eventemitter3": "^4.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": "^2.0.0", "async": "^3.0.0",
"concat-stream": "^1.6.2", "auto-changelog": "^1.15.0",
"concat-stream": "^2.0.0",
"expect.js": "~0.3.1", "expect.js": "~0.3.1",
"mocha": "^3.5.3", "mocha": "^3.5.3",
"nyc": "^11.7.1", "nyc": "^14.0.0",
"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.6", "sse": "0.0.8",
"ws": "^0.8.0" "ws": "^3.0.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": ">=4.0.0" "node": ">=8.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

19
renovate.json Normal file
View File

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

View File

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

View File

@ -1,9 +1,27 @@
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf+6fVgdpVhYg5 MIIEpQIBAAKCAQEAvSQq3d8AeZMTvtqZ13jWCckikyXJSACvkGCQUCJqOceESbg6
QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAQJBAMT6Bf34+UHKY1ObpsbH IHdRzQdoccE4P3sbvNsf9BlbdJKM+neCxabqKaU1PPje4P0tHT57t6yJrMuUh9Nx
9u2jsVblFq1rWvs8GPMY6oertzvwm3DpuSUp7PTgOB1nLTLYtCERbQ4ovtN8tn3p Ez3Bgh1srNHVS7saKvwHmcK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RPEzqN7E7qiF/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-----

View File

@ -1,19 +0,0 @@
[ 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,6 +126,50 @@ 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) { destiny.on('connection', function (socket, upgradeReq) {
expect(socket.upgradeReq.headers['x-special-proxy-header']).to.eql('foobar'); expect(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: self signed certificate') expect(err.toString()).to.be('Error: unable to verify the first 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')
} }