| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.net.HttpCookie; |
| | | import java.net.URI; |
| | | import java.net.URISyntaxException; |
| | |
| | | } |
| | | |
| | | private String filterStr(HttpServletRequest request, HttpServletResponse response, ResEntity res, String str) { |
| | | String url = res.getUrl(); |
| | | if (url.contains(StaticData.AK)) { |
| | | String[] strs = url.split("\\?"); |
| | | url = strs[0]; |
| | | |
| | | if (!StringHelper.isEmpty(strs[1])) { |
| | | str = str.replace("?" + strs[1], "").replace("&" + strs[1], "").replace("&" + strs[1], ""); |
| | | } |
| | | } |
| | | if (str.contains(url)) { |
| | | if (str.contains(res.getUrl())) { |
| | | String proxyUrl = res.getProxy().replace("{token}", response.getHeader("token")); |
| | | proxyUrl = request.getRequestURL().substring(0, request.getRequestURL().indexOf(proxyUrl) + proxyUrl.length()); |
| | | str = str.replace(url, proxyUrl); |
| | | str = str.replace(res.getUrl(), proxyUrl); |
| | | |
| | | if (str.contains(StaticData.REST_LAYER)) { |
| | | str = str.replace(url.replace("/wmts/layer/", StaticData.REST_LAYER), proxyUrl); |
| | | if (!StringHelper.isEmpty(res.getArgs())) { |
| | | // str = str.replace("?" + res.getArgs(), "").replace("&" + res.getArgs(), "") |
| | | str = str.replace("?" + res.getArgs() + "\"", "\"").replace("&" + res.getArgs() + "\"", "\"") |
| | | .replace("?" + res.getArgs() + "&", "?").replace("&" + res.getArgs() + "&", "&"); |
| | | } |
| | | |
| | | if (StaticData.THREE == res.getCategory() && str.contains(StaticData.REST_LAYER)) { |
| | | str = str.replace(res.getUrl().replace("/v6/wmts/", StaticData.REST_LAYER), proxyUrl.replace("/proxy/", "/proxy/rest/")); |
| | | } |
| | | } |
| | | |