Updating docs and adding more tests.

This commit is contained in:
Sean Willis 2018-02-20 20:53:39 -08:00 committed by Charlie Robbins
parent 50f58b4cd9
commit f5c2381395
2 changed files with 41 additions and 9 deletions

View File

@ -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.
* **proxyTimeout**: timeout (in millis) when proxy receives no response from target

View File

@ -289,15 +289,6 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
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() {
var options = {
cookiePathRewrite: '/dummyPath'
@ -309,6 +300,35 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
.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() {
var options = {
cookieDomainRewrite: 'my.new.domain'