private Uri makeProxiedUri(ProxyUri puc, Integer forcedRefresh, String version) { UriBuilder queryBuilder = puc.makeQueryParams(forcedRefresh, version); String container = puc.getContainer(); UriBuilder uri = new UriBuilder(); uri.setAuthority(getReqConfig(container, PROXY_HOST_PARAM)); // Chained vs. query-style syntax is determined by the presence of CHAINED_PARAMS_TOKEN String path = getReqConfig(container, PROXY_PATH_PARAM); if (path.contains(CHAINED_PARAMS_TOKEN)) { // Chained proxy syntax. Stuff query params into the path and append URI verbatim at the end path = path.replace(CHAINED_PARAMS_TOKEN, queryBuilder.getQuery()); uri.setPath(path); String uriStr = uri.toString(); String curUri = uriStr + (!uriStr.endsWith("/") ? "/" : "") + puc.getResource().toString(); return Uri.parse(curUri); } // Query-style syntax. Use path as normal and append query params at the end. queryBuilder.addQueryParameter(Param.URL.getKey(), puc.getResource().toString()); uri.setQuery(queryBuilder.getQuery()); uri.setPath(path); return uri.toUri(); }
private Uri makeProxiedUri(ProxyUri puc, Integer forcedRefresh, String version) { UriBuilder queryBuilder = puc.makeQueryParams(forcedRefresh, version); String container = puc.getContainer(); UriBuilder uri = new UriBuilder(); uri.setAuthority(getReqConfig(container, PROXY_HOST_PARAM)); // Chained vs. query-style syntax is determined by the presence of CHAINED_PARAMS_TOKEN String path = getReqConfig(container, PROXY_PATH_PARAM); if (path.contains(CHAINED_PARAMS_TOKEN)) { // Chained proxy syntax. Stuff query params into the path and append URI verbatim at the end path = path.replace(CHAINED_PARAMS_TOKEN, queryBuilder.getQuery()); uri.setPath(path); String uriStr = uri.toString(); String curUri = uriStr + (!uriStr.endsWith("/") ? "/" : "") + puc.getResource().toString(); return Uri.parse(curUri); } // Query-style syntax. Use path as normal and append query params at the end. queryBuilder.addQueryParameter(Param.URL.getKey(), puc.getResource().toString()); uri.setQuery(queryBuilder.getQuery()); uri.setPath(path); return uri.toUri(); }
private Uri makeProxiedUri(ProxyUri puc, Integer forcedRefresh, String version) { UriBuilder queryBuilder = puc.makeQueryParams(forcedRefresh, version); String container = puc.getContainer(); UriBuilder uri = new UriBuilder(); uri.setAuthority(getReqConfig(container, PROXY_HOST_PARAM)); // Chained vs. query-style syntax is determined by the presence of CHAINED_PARAMS_TOKEN String path = getReqConfig(container, PROXY_PATH_PARAM); if (path.contains(CHAINED_PARAMS_TOKEN)) { // Chained proxy syntax. Stuff query params into the path and append URI verbatim at the end path = path.replace(CHAINED_PARAMS_TOKEN, queryBuilder.getQuery()); uri.setPath(path); String uriStr = uri.toString(); String curUri = uriStr + (!uriStr.endsWith("/") ? "/" : "") + puc.getResource().toString(); return Uri.parse(curUri); } // Query-style syntax. Use path as normal and append query params at the end. queryBuilder.addQueryParameter(Param.URL.getKey(), puc.getResource().toString()); uri.setQuery(queryBuilder.getQuery()); uri.setPath(path); return uri.toUri(); }
@Test public void testHtmlTagContext() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER) .addQueryParameter(Param.URL.getKey(), "http://www.example.org/") .addQueryParameter(Param.HTML_TAG_CONTEXT.getKey(), "htmlTag") .toUri(); ProxyUri proxyUri = manager.process(testUri); assertEquals("htmlTag", proxyUri.getHtmlTagContext()); Uri targetUri = Uri.parse("http://www.example2.org/"); HttpRequest req = proxyUri.makeHttpRequest(targetUri); assertEquals("htmlTag", req.getParam(Param.HTML_TAG_CONTEXT.getKey())); UriBuilder builder = proxyUri.makeQueryParams(1, "2"); assertEquals("htmlTag", builder.getQueryParameter(Param.HTML_TAG_CONTEXT.getKey())); }
@Test public void testHtmlTagContext() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER) .addQueryParameter(Param.URL.getKey(), "http://www.example.org/") .addQueryParameter(Param.HTML_TAG_CONTEXT.getKey(), "htmlTag") .toUri(); ProxyUri proxyUri = manager.process(testUri); assertEquals("htmlTag", proxyUri.getHtmlTagContext()); Uri targetUri = Uri.parse("http://www.example2.org/"); HttpRequest req = proxyUri.makeHttpRequest(targetUri); assertEquals("htmlTag", req.getParam(Param.HTML_TAG_CONTEXT.getKey())); UriBuilder builder = proxyUri.makeQueryParams(1, "2"); assertEquals("htmlTag", builder.getQueryParameter(Param.HTML_TAG_CONTEXT.getKey())); }
@Test public void testHtmlTagContext() throws Exception { String host = "host.com"; String path = "/proxy/path"; DefaultProxyUriManager manager = makeManager(host, path, null); Uri testUri = new UriBuilder().setAuthority(host).setPath(path) .addQueryParameter(Param.CONTAINER.getKey(), CONTAINER) .addQueryParameter(Param.URL.getKey(), "http://www.example.org/") .addQueryParameter(Param.HTML_TAG_CONTEXT.getKey(), "htmlTag") .toUri(); ProxyUri proxyUri = manager.process(testUri); assertEquals("htmlTag", proxyUri.getHtmlTagContext()); Uri targetUri = Uri.parse("http://www.example2.org/"); HttpRequest req = proxyUri.makeHttpRequest(targetUri); assertEquals("htmlTag", req.getParam(Param.HTML_TAG_CONTEXT.getKey())); UriBuilder builder = proxyUri.makeQueryParams(1, "2"); assertEquals("htmlTag", builder.getQueryParameter(Param.HTML_TAG_CONTEXT.getKey())); }