mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b96cd7251 | ||
|
|
335aeeba2f | ||
|
|
dba39668ba | ||
|
|
9bbe486c5e | ||
|
|
6e4bef4d1c | ||
|
|
d05624167c | ||
|
|
244303b994 | ||
|
|
b4028ba78b | ||
|
|
77a98159d2 | ||
|
|
c662f9ebcd | ||
|
|
806e4927c9 | ||
|
|
c8fa599983 | ||
|
|
0d9ed366b1 | ||
|
|
9d75b981a1 | ||
|
|
192b2b980b | ||
|
|
4a657a7126 | ||
|
|
7a154f81d1 | ||
|
|
749eec65c3 | ||
|
|
e588213644 | ||
|
|
59c4403e9d | ||
|
|
dd1d08b631 | ||
|
|
16d4f8a951 | ||
|
|
fc93520d74 | ||
|
|
7e4a0e511b | ||
|
|
a9b09cce43 | ||
|
|
b00911c937 | ||
|
|
36bfe566a7 | ||
|
|
91fee3e943 | ||
|
|
235f0aa047 | ||
|
|
acdbec09c6 | ||
|
|
569e2ac4fb | ||
|
|
cb3171abfa | ||
|
|
a3fe02d651 |
6
.auto-changelog
Normal file
6
.auto-changelog
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": true,
|
||||
"commitLimit": false
|
||||
}
|
||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
package-lock.json binary
|
||||
@ -2,6 +2,8 @@ test
|
||||
examples
|
||||
doc
|
||||
benchmark
|
||||
coverage
|
||||
.nyc_output
|
||||
.travis.yml
|
||||
CHANGELOG.md
|
||||
UPGRADING.md
|
||||
UPGRADING.md
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4"
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
||||
- "12"
|
||||
script:
|
||||
- npm test
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
matrix:
|
||||
fast_finish: true
|
||||
notifications:
|
||||
email:
|
||||
- travis@nodejitsu.com
|
||||
irc: "irc.freenode.org#nodejitsu"
|
||||
|
||||
1872
CHANGELOG.md
Normal file
1872
CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
||||
## Enforcement
|
||||
|
||||
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
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
|
||||
20
README.md
20
README.md
@ -1,8 +1,8 @@
|
||||
<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>
|
||||
|
||||
# node-http-proxy [](https://travis-ci.org/nodejitsu/node-http-proxy) [](https://codecov.io/gh/nodejitsu/node-http-proxy)
|
||||
# node-http-proxy [](https://travis-ci.org/http-party/node-http-proxy) [](https://codecov.io/gh/http-party/node-http-proxy)
|
||||
|
||||
`node-http-proxy` is an HTTP programmable proxying library that supports
|
||||
websockets. It is suitable for implementing components such as reverse
|
||||
@ -45,7 +45,7 @@ Click [here](UPGRADING.md)
|
||||
### Core Concept
|
||||
|
||||
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
|
||||
var httpProxy = require('http-proxy');
|
||||
@ -137,7 +137,7 @@ var proxy = httpProxy.createProxyServer({});
|
||||
var server = http.createServer(function(req, res) {
|
||||
// You can define here your custom logic to handle 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")
|
||||
@ -175,7 +175,7 @@ var server = http.createServer(function(req, res) {
|
||||
// You can define here your custom logic to handle the request
|
||||
// and then proxy the request.
|
||||
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
|
||||
};
|
||||
proxy.on('proxyRes', function (proxyRes, req, res) {
|
||||
var body = new Buffer('');
|
||||
proxyRes.on('data', function (data) {
|
||||
body = Buffer.concat([body, data]);
|
||||
var body = [];
|
||||
proxyRes.on('data', function (chunk) {
|
||||
body.push(chunk);
|
||||
});
|
||||
proxyRes.on('end', function () {
|
||||
body = body.toString();
|
||||
body = Buffer.concat(body).toString();
|
||||
console.log("res from proxied server:", body);
|
||||
res.end("my response to cli");
|
||||
});
|
||||
@ -534,7 +534,7 @@ Logo created by [Diego Pasquali](http://dribbble.com/diegopq)
|
||||
|
||||
### 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
|
||||
* If you can't find anything, open an issue
|
||||
* If you feel comfortable about fixing the issue, fork the repo
|
||||
|
||||
@ -12,11 +12,11 @@ httpProxy.createServer({
|
||||
}).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
|
||||
|
||||
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
|
||||
//
|
||||
@ -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
|
||||
var proxy = new httpProxy.createProxyServer({
|
||||
@ -90,7 +90,7 @@ which were in the core and delegate them to eventual "userland" modules.
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var httpProxy = require('http-proxy');
|
||||
var httpProxy = require('../../lib/http-proxy');
|
||||
var Agent = require('agentkeepalive');
|
||||
|
||||
var agent = new Agent({
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
var http = require('http'),
|
||||
net = require('net'),
|
||||
httpProxy = require('http-proxy'),
|
||||
httpProxy = require('../../lib/http-proxy'),
|
||||
url = require('url'),
|
||||
util = require('util');
|
||||
|
||||
@ -31,8 +31,9 @@ var proxy = httpProxy.createServer();
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
util.puts('Receiving reverse proxy request for:' + req.url);
|
||||
|
||||
proxy.web(req, res, {target: req.url, secure: false});
|
||||
var parsedUrl = url.parse(req.url);
|
||||
var target = parsedUrl.protocol + '//' + parsedUrl.hostname;
|
||||
proxy.web(req, res, {target: target, secure: false});
|
||||
}).listen(8213);
|
||||
|
||||
server.on('connect', function (req, socket) {
|
||||
|
||||
@ -29,6 +29,7 @@ var http = require('http'),
|
||||
request = require('request'),
|
||||
colors = require('colors'),
|
||||
util = require('util'),
|
||||
queryString = require('querystring'),
|
||||
bodyParser = require('body-parser'),
|
||||
httpProxy = require('../../lib/http-proxy'),
|
||||
proxy = httpProxy.createProxyServer({});
|
||||
@ -36,12 +37,23 @@ var http = require('http'),
|
||||
|
||||
//restream parsed body before proxying
|
||||
proxy.on('proxyReq', function(proxyReq, req, res, options) {
|
||||
if(req.body) {
|
||||
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');
|
||||
if (!req.body || !Object.keys(req.body).length) {
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
// stream the content
|
||||
proxyReq.write(bodyData);
|
||||
}
|
||||
});
|
||||
@ -94,5 +106,3 @@ http.createServer(app1).listen(9013, function(){
|
||||
console.log('return for urlencoded request:' ,err, data)
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -28,24 +28,26 @@ var util = require('util'),
|
||||
colors = require('colors'),
|
||||
http = require('http'),
|
||||
connect = require('connect'),
|
||||
app = connect(),
|
||||
httpProxy = require('../../lib/http-proxy');
|
||||
|
||||
//
|
||||
// Basic Connect App
|
||||
//
|
||||
connect.createServer(
|
||||
function (req, res, next) {
|
||||
var _write = res.write;
|
||||
app.use(function (req, res, next) {
|
||||
var _write = res.write;
|
||||
|
||||
res.write = function (data) {
|
||||
_write.call(res, data.toString().replace("Ruby", "nodejitsu"));
|
||||
}
|
||||
next();
|
||||
},
|
||||
function (req, res) {
|
||||
proxy.web(req, res);
|
||||
res.write = function (data) {
|
||||
_write.call(res, data.toString().replace("Ruby", "http-party"));
|
||||
}
|
||||
).listen(8013);
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function (req, res) {
|
||||
proxy.web(req, res)
|
||||
});
|
||||
|
||||
http.createServer(app).listen(8013);
|
||||
|
||||
//
|
||||
// Basic Http Proxy Server
|
||||
@ -59,7 +61,7 @@ var proxy = httpProxy.createProxyServer({
|
||||
//
|
||||
http.createServer(function (req, res) {
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
res.end('Hello, I know Ruby\n');
|
||||
res.end('Hello, I love Ruby\n');
|
||||
}).listen(9013);
|
||||
|
||||
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8013'.yellow);
|
||||
|
||||
@ -3,13 +3,12 @@
|
||||
"description": "packages required to run the examples",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"agentkeepalive": "^2.0.3",
|
||||
"colors": "~0.6.2",
|
||||
"connect": "~2.11.0",
|
||||
"agentkeepalive": "^4.0.0",
|
||||
"colors": "~1.3.0",
|
||||
"connect-restreamer": "~1.0.0",
|
||||
"request": "~2.27.0",
|
||||
"request": "~2.88.0",
|
||||
"socket.io": "~0.9.16",
|
||||
"socket.io-client": "~0.9.16",
|
||||
"sse": "0.0.6"
|
||||
"sse": "0.0.8"
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ function createProxyServer(options) {
|
||||
* 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 >
|
||||
* 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.
|
||||
* 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 (301/302/307/308) redirects to 'http' or 'https'. Default: null.
|
||||
* hostRewrite: rewrites the location hostname on (201/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.
|
||||
* 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.
|
||||
|
||||
@ -82,7 +82,7 @@ module.exports = {
|
||||
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
|
||||
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
|
||||
|
||||
4378
package-lock.json
generated
4378
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "http-proxy",
|
||||
"version": "1.17.0",
|
||||
"version": "1.18.1",
|
||||
"repository": {
|
||||
"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",
|
||||
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
|
||||
@ -12,28 +12,30 @@
|
||||
],
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"eventemitter3": "^3.0.0",
|
||||
"eventemitter3": "^4.0.0",
|
||||
"requires-port": "^1.0.0",
|
||||
"follow-redirects": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"async": "^2.0.0",
|
||||
"concat-stream": "^1.6.2",
|
||||
"async": "^3.0.0",
|
||||
"auto-changelog": "^1.15.0",
|
||||
"concat-stream": "^2.0.0",
|
||||
"expect.js": "~0.3.1",
|
||||
"mocha": "^3.5.3",
|
||||
"nyc": "^11.7.1",
|
||||
"nyc": "^14.0.0",
|
||||
"semver": "^5.0.3",
|
||||
"socket.io": "^2.1.0",
|
||||
"socket.io-client": "^2.1.0",
|
||||
"sse": "0.0.6",
|
||||
"ws": "^0.8.0"
|
||||
"sse": "0.0.8",
|
||||
"ws": "^3.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"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": {
|
||||
"node": ">=4.0.0"
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
19
renovate.json
Normal file
19
renovate.json
Normal 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]"
|
||||
}
|
||||
34
test/fixtures/agent2-cert.pem
vendored
34
test/fixtures/agent2-cert.pem
vendored
@ -1,13 +1,25 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB7DCCAZYCCQC7gs0MDNn6MTANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJV
|
||||
UzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYDVQQKEwZKb3llbnQxEDAO
|
||||
BgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEgMB4GCSqGSIb3DQEJARYR
|
||||
cnlAdGlueWNsb3Vkcy5vcmcwHhcNMTEwMzE0MTgyOTEyWhcNMzgwNzI5MTgyOTEy
|
||||
WjB9MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExCzAJBgNVBAcTAlNGMQ8wDQYD
|
||||
VQQKEwZKb3llbnQxEDAOBgNVBAsTB05vZGUuanMxDzANBgNVBAMTBmFnZW50MjEg
|
||||
MB4GCSqGSIb3DQEJARYRcnlAdGlueWNsb3Vkcy5vcmcwXDANBgkqhkiG9w0BAQEF
|
||||
AANLADBIAkEAyXb8FrRdKbhrKLgLSsn61i1C7w7fVVVd7OQsmV/7p9WB2lWFiDlC
|
||||
WKGU9SiIz/A6wNZDUAuc2E+VwtpCT561AQIDAQABMA0GCSqGSIb3DQEBBQUAA0EA
|
||||
C8HzpuNhFLCI3A5KkBS5zHAQax6TFUOhbpBCR0aTDbJ6F1liDTK1lmU/BjvPoj+9
|
||||
1LHwrmh29rK8kBPEjmymCQ==
|
||||
MIIEIDCCAggCCQChRDh/XiBF+zANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJ1
|
||||
czETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEeMBwGA1UE
|
||||
AwwVRHVtbXkgSW50ZXJtZWRpYXRlIENBMB4XDTE4MDYyMjIwMzEwNFoXDTMyMDIy
|
||||
OTIwMzEwNFowUDELMAkGA1UEBhMCdXMx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2Dg
|
||||
T477pICLfETZfA499Fd1tOaIsoLCrILAia/+Yd76uf94MuXUIqykDng/4H7xCc47
|
||||
BZhNFJiPC6XHaXzN7NYSEUNX9VOwY8ncxKwtP6TXga96PdMUy/p98KIM8RZlDoxB
|
||||
Xy9dcZBFNn/zrqjW7R0CCWCUriDIFSmEP0wDZ91YYa6BVuJMb5uL/USkTLpjZS4/
|
||||
HNGvug==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
10
test/fixtures/agent2-csr.pem
vendored
10
test/fixtures/agent2-csr.pem
vendored
@ -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-----
|
||||
32
test/fixtures/agent2-key.pem
vendored
32
test/fixtures/agent2-key.pem
vendored
@ -1,9 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBOgIBAAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf+6fVgdpVhYg5
|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END RSA PRIVATE KEY-----
|
||||
|
||||
19
test/fixtures/agent2.cnf
vendored
19
test/fixtures/agent2.cnf
vendored
@ -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
|
||||
|
||||
@ -126,6 +126,50 @@ describe('#createProxyServer.web() using own http server', function () {
|
||||
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) {
|
||||
var proxy = httpProxy.createProxyServer({
|
||||
target: 'http://127.0.0.1:8080'
|
||||
|
||||
@ -562,8 +562,8 @@ describe('lib/http-proxy.js', function() {
|
||||
});
|
||||
});
|
||||
|
||||
destiny.on('connection', function (socket) {
|
||||
expect(socket.upgradeReq.headers['x-special-proxy-header']).to.eql('foobar');
|
||||
destiny.on('connection', function (socket, upgradeReq) {
|
||||
expect(upgradeReq.headers['x-special-proxy-header']).to.eql('foobar');
|
||||
|
||||
socket.on('message', function (msg) {
|
||||
expect(msg).to.be('hello there');
|
||||
|
||||
@ -168,7 +168,7 @@ describe('lib/http-proxy.js', function() {
|
||||
proxy.on('error', function (err, req, res) {
|
||||
expect(err).to.be.an(Error);
|
||||
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 {
|
||||
expect(err.toString()).to.be('Error: DEPTH_ZERO_SELF_SIGNED_CERT')
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user