mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Updating docs and adding more tests.
This commit is contained in:
parent
50f58b4cd9
commit
f5c2381395
12
README.md
12
README.md
@ -342,6 +342,18 @@ proxyServer.listen(8015);
|
|||||||
"*": ""
|
"*": ""
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
* **cookiePathRewrite**: rewrites path of `set-cookie` headers. Possible values:
|
||||||
|
* `false` (default): disable cookie rewriting
|
||||||
|
* String: new path, for example `cookiePathRewrite: "/newPath/"`. To remove the path, use `cookiePathRewrite: ""`. To set path to root use `cookiePathRewrite: "/"`.
|
||||||
|
* Object: mapping of paths to new paths, use `"*"` to match all paths.
|
||||||
|
For example keep one path unchanged, rewrite one path and remove other paths:
|
||||||
|
```
|
||||||
|
cookiePathRewrite: {
|
||||||
|
"/unchanged.path/": "/unchanged.path/",
|
||||||
|
"/old.path/": "/new.path/",
|
||||||
|
"*": ""
|
||||||
|
}
|
||||||
|
```
|
||||||
* **headers**: object with extra headers to be added to target requests.
|
* **headers**: object with extra headers to be added to target requests.
|
||||||
* **proxyTimeout**: timeout (in millis) when proxy receives no response from target
|
* **proxyTimeout**: timeout (in millis) when proxy receives no response from target
|
||||||
|
|
||||||
|
|||||||
@ -289,15 +289,6 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
|
|||||||
expect(this.res.headers['set-cookie']).to.have.length(2);
|
expect(this.res.headers['set-cookie']).to.have.length(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not rewrite domain', function() {
|
|
||||||
var options = {};
|
|
||||||
|
|
||||||
httpProxy.writeHeaders({}, this.res, this.proxyRes, options);
|
|
||||||
|
|
||||||
expect(this.res.headers['set-cookie'])
|
|
||||||
.to.contain('hello; domain=my.domain; path=/');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('rewrites path', function() {
|
it('rewrites path', function() {
|
||||||
var options = {
|
var options = {
|
||||||
cookiePathRewrite: '/dummyPath'
|
cookiePathRewrite: '/dummyPath'
|
||||||
@ -309,6 +300,35 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
|
|||||||
.to.contain('hello; domain=my.domain; path=/dummyPath');
|
.to.contain('hello; domain=my.domain; path=/dummyPath');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not rewrite path', function() {
|
||||||
|
var options = {};
|
||||||
|
|
||||||
|
httpProxy.writeHeaders({}, this.res, this.proxyRes, options);
|
||||||
|
|
||||||
|
expect(this.res.headers['set-cookie'])
|
||||||
|
.to.contain('hello; domain=my.domain; path=/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('removes path', function() {
|
||||||
|
var options = {
|
||||||
|
cookiePathRewrite: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
httpProxy.writeHeaders({}, this.res, this.proxyRes, options);
|
||||||
|
|
||||||
|
expect(this.res.headers['set-cookie'])
|
||||||
|
.to.contain('hello; domain=my.domain');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not rewrite domain', function() {
|
||||||
|
var options = {};
|
||||||
|
|
||||||
|
httpProxy.writeHeaders({}, this.res, this.proxyRes, options);
|
||||||
|
|
||||||
|
expect(this.res.headers['set-cookie'])
|
||||||
|
.to.contain('hello; domain=my.domain; path=/');
|
||||||
|
});
|
||||||
|
|
||||||
it('rewrites domain', function() {
|
it('rewrites domain', function() {
|
||||||
var options = {
|
var options = {
|
||||||
cookieDomainRewrite: 'my.new.domain'
|
cookieDomainRewrite: 'my.new.domain'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user