use of com.tremolosecurity.proxy.http.UriMethod in project OpenUnison by TremoloSecurity.
the class UriRequestProcess method postProcess.
@Override
public void postProcess(HttpFilterRequest req, HttpFilterResponse resp, UrlHolder holder, HttpFilterChain chain) throws Exception {
String proxyTo = holder.getUrl().getProxyTo();
HashMap<String, String> uriParams = (HashMap<String, String>) req.getAttribute("TREMOLO_URI_PARAMS");
Iterator<String> names;
StringBuffer proxyToURL = ProxyTools.getInstance().getGETUrl(req, holder, uriParams);
boolean first = true;
for (NVP p : req.getQueryStringParams()) {
if (first) {
proxyToURL.append('?');
first = false;
} else {
proxyToURL.append('&');
}
proxyToURL.append(p.getName()).append('=').append(URLEncoder.encode(p.getValue(), "UTF-8"));
}
com.tremolosecurity.proxy.HttpUpgradeRequestManager upgradeRequestManager = GlobalEntries.getGlobalEntries().getConfigManager().getUpgradeManager();
if (req.getHeader("Connection") != null && req.getHeader("Connection").getValues().get(0).equalsIgnoreCase("Upgrade")) {
ProxyResponse pr = (ProxyResponse) resp.getServletResponse();
upgradeRequestManager.proxyWebSocket(req, (HttpServletResponse) pr.getResponse(), proxyToURL.toString());
} else {
CloseableHttpClient httpclient = this.getHttp(proxyTo, req.getServletRequest(), holder);
// HttpGet httpget = new HttpGet(proxyToURL.toString());
// this.getHttpMethod(proxyToURL.toString());
HttpRequestBase httpMethod = new UriMethod(req.getMethod(), proxyToURL.toString());
req.setAttribute("TREMOLO_FINAL_URL", proxyToURL.toString());
setHeadersCookies(req, holder, httpMethod, proxyToURL.toString());
HttpContext ctx = (HttpContext) req.getSession().getAttribute(ProxySys.HTTP_CTX);
HttpResponse response = httpclient.execute(httpMethod, ctx);
postProcess(req, resp, holder, response, proxyToURL.toString(), chain, httpMethod);
}
}
Aggregations