-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from mbarto/http_proxy
Fixes #106: integrated http-proxy as a submodule;
- Loading branch information
Showing
18 changed files
with
155 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "geostore"] | ||
path = geostore | ||
url = https://github.com/geosolutions-it/geostore | ||
[submodule "http-proxy"] | ||
path = http-proxy | ||
url = https://github.com/geosolutions-it/http-proxy.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
mvn clean install -Pgeostore,extjs,postgres,h2_disk | ||
mvn clean install -Pgeostore,proxy,extjs,postgres,h2_disk |
Submodule http-proxy
added at
24c396
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
var axios = require('../ajax'); | ||
|
||
describe('Tests ajax library', () => { | ||
it('uses proxy for requests not on the same origin', (done) => { | ||
axios.get('http://fakeexternaldomain.mapstore2').then(() => { | ||
done(); | ||
}).catch(ex => { | ||
expect(ex.config).toExist(); | ||
expect(ex.config.url).toExist(); | ||
expect(ex.config.url).toContain('proxy/?url='); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('does not use proxy for requests on the same origin', (done) => { | ||
axios.get('base/web/client/test-resources/testConfig.json').then((response) => { | ||
expect(response.config).toExist(); | ||
expect(response.config.url).toExist(); | ||
expect(response.config.url).toBe('base/web/client/test-resources/testConfig.json'); | ||
done(); | ||
}).catch(ex => { | ||
done(ex); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var axios = require('axios'); | ||
|
||
var proxy = '/mapstore/proxy/?url='; | ||
|
||
axios.interceptors.request.use(config => { | ||
var uri = config.url || ''; | ||
var sameOrigin = !(uri.indexOf("http") === 0); | ||
var urlParts = !sameOrigin && uri.match(/([^:]*:)\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/); | ||
if (urlParts) { | ||
let location = window.location; | ||
sameOrigin = | ||
urlParts[1] === location.protocol && | ||
urlParts[3] === location.hostname; | ||
let uPort = urlParts[4]; | ||
let lPort = location.port; | ||
if (uPort !== 80 && uPort !== "" || lPort !== "80" && lPort !== "") { | ||
sameOrigin = sameOrigin && uPort === lPort; | ||
} | ||
} | ||
if (!sameOrigin) { | ||
let proxyUrl = config ? config.proxyUrl || proxy : proxy; | ||
if (proxyUrl) { | ||
|
||
if (proxyUrl.match(/^http:\/\//i) === null) { | ||
proxyUrl = 'http://' + window.location.host + proxyUrl; | ||
} | ||
config.url = proxyUrl + encodeURIComponent(uri); | ||
} | ||
} | ||
return config; | ||
}); | ||
|
||
module.exports = axios; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
module.exports = window.L; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
module.exports = window.ol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
module.exports = window.proj4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters