public List<Uri> make(List<ProxyUri> resource, Integer forcedRefresh) { List<Uri> ctx = Lists.newArrayListWithCapacity(resource.size()); for (ProxyUri res : resource) { ctx.add(getUri(res.getResource())); } return ImmutableList.copyOf(ctx); }
public Uri make(ProxyUriManager.ProxyUri uri, Uri context) { if (config.shouldRewriteURL(uri.getResource().toString())) { List<ProxyUriManager.ProxyUri> puris = Lists.newArrayList(uri); List<Uri> returned = wrapped.make(puris, null); return returned.get(0); } return context.resolve(uri.getResource()); } }
public Uri make(ProxyUriManager.ProxyUri uri, Uri context) { if (config.shouldRewriteURL(uri.getResource().toString())) { List<ProxyUriManager.ProxyUri> puris = Lists.newArrayList(uri); List<Uri> returned = wrapped.make(puris, null); return returned.get(0); } return context.resolve(uri.getResource()); } }
@Test public void containerFallsBackToSynd() throws Exception { String host = "host.com"; String path = "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); UriBuilder uriBuilder = new UriBuilder(); uriBuilder.setScheme("http").setAuthority(host).setPath(path); uriBuilder.addQueryParameter(Param.URL.getKey(), RESOURCE_1.toString()); uriBuilder.addQueryParameter("synd", CONTAINER); uriBuilder.addQueryParameter(Param.GADGET.getKey(), SPEC_URI.toString()); uriBuilder.addQueryParameter(Param.REFRESH.getKey(), "321"); ProxyUriManager.ProxyUri proxyUri = manager.process(uriBuilder.toUri()); assertEquals(RESOURCE_1, proxyUri.getResource()); assertEquals(CONTAINER, proxyUri.getContainer()); assertEquals(SPEC_URI.toString(), proxyUri.getGadget()); assertEquals(321, (int)proxyUri.getRefresh()); assertEquals(false, proxyUri.isDebug()); assertEquals(false, proxyUri.isNoCache()); }
@Test public void containerFallsBackToSynd() throws Exception { String host = "host.com"; String path = "/path"; DefaultProxyUriManager manager = makeManager(host, path, null); UriBuilder uriBuilder = new UriBuilder(); uriBuilder.setScheme("http").setAuthority(host).setPath(path); uriBuilder.addQueryParameter(Param.URL.getKey(), RESOURCE_1.toString()); uriBuilder.addQueryParameter("synd", CONTAINER); uriBuilder.addQueryParameter(Param.GADGET.getKey(), SPEC_URI.toString()); uriBuilder.addQueryParameter(Param.REFRESH.getKey(), "321"); ProxyUriManager.ProxyUri proxyUri = manager.process(uriBuilder.toUri()); assertEquals(RESOURCE_1, proxyUri.getResource()); assertEquals(CONTAINER, proxyUri.getContainer()); assertEquals(SPEC_URI.toString(), proxyUri.getGadget()); assertEquals(321, (int)proxyUri.getRefresh()); assertEquals(false, proxyUri.isDebug()); assertEquals(false, proxyUri.isNoCache()); }
@Test public void testProxyGadgetsChainGif() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/container=container&" + "gadget=http%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int&" + "debug=0&nocache=0/http://www.orkut.com/img/castro/i_reply.gif"); ProxyUri pUri = uriManager.process(uri); assertEquals(false, pUri.isDebug()); assertEquals("http://www.orkut.com/img/castro/i_reply.gif", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget()); }
@Test public void testProxyGadgetsChainDecodeGif() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/container%3dcontainer%26" + "gadget%3dhttp%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int%26" + "debug%3d0%26nocache%3d0/http://www.orkut.com/img/castro/i%5freply.gif"); ProxyUri pUri = uriManager.process(uri); assertEquals(false, pUri.isDebug()); assertEquals("http://www.orkut.com/img/castro/i%5freply.gif", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget()); }
private Uri getUri(ProxyUri src) { if (!doProxy) { return src.getResource(); } UriBuilder builder = new UriBuilder().setScheme("http").setAuthority(proxyHost).setPath(proxyPath) .addQueryParameter(Param.URL.getKey(), src.getResource().toString()); if (src.sanitizeContent()) { builder.addQueryParameter(Param.SANITIZE.getKey(), "1"); } if (src.getRewriteMimeType() != null) { builder.addQueryParameter(Param.REWRITE_MIME_TYPE.getKey(), src.getRewriteMimeType()); } return builder.toUri(); }
private Uri getUri(ProxyUri src) { if (!doProxy) { return src.getResource(); } UriBuilder builder = new UriBuilder().setScheme("http").setAuthority(proxyHost).setPath(proxyPath) .addQueryParameter(Param.URL.getKey(), src.getResource().toString()); if (src.sanitizeContent()) { builder.addQueryParameter(Param.SANITIZE.getKey(), "1"); } if (src.getRewriteMimeType() != null) { builder.addQueryParameter(Param.REWRITE_MIME_TYPE.getKey(), src.getRewriteMimeType()); } return builder.toUri(); }
@Test public void testProxyGadgetsChainDecodeGif() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/container%3dcontainer%26" + "gadget%3dhttp%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int%26" + "debug%3d0%26nocache%3d0/http://www.orkut.com/img/castro/i%5freply.gif"); ProxyUri pUri = uriManager.process(uri); assertEquals(false, pUri.isDebug()); assertEquals("http://www.orkut.com/img/castro/i%5freply.gif", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget()); }
@Test public void testProxyGadgetsChainGif() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/container=container&" + "gadget=http%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int&" + "debug=0&nocache=0/http://www.orkut.com/img/castro/i_reply.gif"); ProxyUri pUri = uriManager.process(uri); assertEquals(false, pUri.isDebug()); assertEquals("http://www.orkut.com/img/castro/i_reply.gif", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget()); }
@Test public void testProxyGadgetsChainGif() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/container=container&" + "gadget=http%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int&" + "debug=0&nocache=0/http://www.orkut.com/img/castro/i_reply.gif"); ProxyUri pUri = uriManager.process(uri); assertEquals(false, pUri.isDebug()); assertEquals("http://www.orkut.com/img/castro/i_reply.gif", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget()); }
@Test public void testProxyGadgetsChainDecodeGif() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/container%3dcontainer%26" + "gadget%3dhttp%3A%2F%2Fwww.orkut.com%2Fcss%2Fgen%2Fbase054.css.int%26" + "debug%3d0%26nocache%3d0/http://www.orkut.com/img/castro/i%5freply.gif"); ProxyUri pUri = uriManager.process(uri); assertEquals(false, pUri.isDebug()); assertEquals("http://www.orkut.com/img/castro/i%5freply.gif", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); assertEquals("http://www.orkut.com/css/gen/base054.css.int", pUri.getGadget()); }
public String rewriteUri(ExternalReference ref, UriEffect effect, LoaderType loader, Map<String, ?> hints) { Uri resourceUri = Uri.fromJavaUri(ref.getUri()); if (contextUri != null) { resourceUri = contextUri.resolve(resourceUri); } ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( stubGadget, resourceUri); return proxyUri.getResource().toString(); } };
public Uri make(ProxyUriManager.ProxyUri uri, Uri context) { if (config.shouldRewriteURL(uri.getResource().toString())) { List<ProxyUriManager.ProxyUri> puris = Lists.newArrayList(uri); List<Uri> returned = wrapped.make(puris, null); return returned.get(0); } return context.resolve(uri.getResource()); } }
@Test public void testProxyGadgetsChainDecode() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/" + "http://www.cnn.com/news?refresh=45"); ProxyUri pUri = uriManager.process(uri); assertEquals(new Integer(55), pUri.getRefresh()); assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); }
public String rewriteUri(ExternalReference ref, UriEffect effect, LoaderType loader, Map<String, ?> hints) { Uri resourceUri = Uri.fromJavaUri(ref.getUri()); if (contextUri != null) { resourceUri = contextUri.resolve(resourceUri); } ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( stubGadget, resourceUri); return proxyUri.getResource().toString(); } };
@Test public void testProxyGadgetsChainDecode() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/" + "http://www.cnn.com/news?refresh=45"); ProxyUri pUri = uriManager.process(uri); assertEquals(new Integer(55), pUri.getRefresh()); assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); }
public String rewriteUri(ExternalReference ref, UriEffect effect, LoaderType loader, Map<String, ?> hints) { Uri resourceUri = Uri.fromJavaUri(ref.getUri()); if (contextUri != null) { resourceUri = contextUri.resolve(resourceUri); } ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri( stubGadget, resourceUri); return proxyUri.getResource().toString(); } };
@Test public void testProxyGadgetsChainDecode() throws Exception { String host = "host.com"; String path = "/proxy/" + DefaultProxyUriManager.CHAINED_PARAMS_TOKEN; DefaultProxyUriManager uriManager = makeManager(host, path, null); Uri uri = Uri.parse("http://host.com/gadgets/proxy/refresh%3d55%26container%3dcontainer/" + "http://www.cnn.com/news?refresh=45"); ProxyUri pUri = uriManager.process(uri); assertEquals(new Integer(55), pUri.getRefresh()); assertEquals("http://www.cnn.com/news?refresh=45", pUri.getResource().toString()); assertEquals(CONTAINER, pUri.getContainer()); }