Tabnine Logo
HttpRequest.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.shindig.gadgets.http.HttpRequest
constructor

Best Java code snippets using org.apache.shindig.gadgets.http.HttpRequest.<init> (Showing top 20 results out of 315)

origin: org.apache.shindig/shindig-gadgets

private void expectGetAndReturnData(String url, byte[] data) throws Exception {
 HttpRequest req = new HttpRequest(Uri.parse(url));
 HttpResponse resp = new HttpResponseBuilder().setResponse(data).create();
 expect(pipeline.execute(req)).andReturn(resp);
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void removeResponse() {
 HttpRequest request = new HttpRequest(DEFAULT_URI);
 String key = cache.createKey(request);
 HttpResponse response = new HttpResponse("result");
 cache.map.put(key, response);
 assertEquals(response, cache.removeResponse(request));
 assertEquals(0, cache.map.size());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void contentTypeExtraction() throws Exception {
 HttpRequest request = new HttpRequest(DEFAULT_URI)
   .addHeader("Content-Type", CONTENT_TYPE);
 assertEquals(CONTENT_TYPE, request.getContentType());
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testHttpUnderscore() throws Exception {
 Uri uri = Uri.parse("http://0.test_host.com/data");
 HttpRequest request = new HttpRequest(uri);
 HttpResponse response = fetcher.fetch(request);
 assertEquals(504, response.getHttpStatusCode()); //timeout
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void getResponseNotCacheable() {
 HttpRequest request = new HttpRequest(DEFAULT_URI);
 String key = cache.createKey(request);
 HttpResponse response = new HttpResponseBuilder().setStrictNoCache().create();
 cache.map.put(key, response);
 assertNull("Did not return null when response was uncacheable", cache.getResponse(request));
 extendedStrictNoCacheTtlCache.map.put(key, response);
 assertEquals(response, extendedStrictNoCacheTtlCache.getResponse(request));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testImgWithCacheControlPrivateReservedAndFetchNotTriggered() throws Exception {
 cache.addResponse(new HttpRequest(Uri.parse(IMG_URL)),
          new HttpResponseBuilder().setResponseString("test")
            .addHeader("Cache-Control", "private").create());
 // Ensure that the strict no-cache resource is cached.
 assertTrue(cache.getResponse(new HttpRequest(Uri.parse(IMG_URL))) != null);
 checkVisitBypassedAndFetchTriggered("img", IMG_URL, false, false);
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testHttpBadPort() throws Exception {
 Uri uri = Uri.parse("http://a:b/");
 HttpRequest request = new HttpRequest(uri);
 try {
  fetcher.fetch(request);
  fail("Expected GadgetException");
 } catch (GadgetException e) {
  assertEquals(400, e.getHttpStatusCode());
  assertTrue(e.getMessage().contains("Bad port number in request"));
 }
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testHttpBadUrl() throws Exception {
 Uri uri = Uri.parse("host/data");
 HttpRequest request = new HttpRequest(uri);
 try {
  fetcher.fetch(request);
  fail("Expected GadgetException");
 } catch (GadgetException e) {
  assertEquals(400, e.getHttpStatusCode());
  assertTrue(e.getMessage().contains("Missing domain name for request"));
 }
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void authTypeNoneWasCached() throws Exception {
 HttpRequest request = new HttpRequest(DEFAULT_URI).setAuthType(AuthType.NONE);
 HttpResponse cached = new HttpResponse("cached");
 cache.data.put(DEFAULT_URI, cached);
 HttpResponse response = pipeline.execute(request);
 assertEquals(cached, response);
 assertEquals(1, cache.readCount);
 assertEquals(0, cache.writeCount);
 assertEquals(0, fetcher.fetchCount);
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testStripSecretsFromRequestHeader() {
 HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/foo"));
 req.setHeader("Authorization", "OAuth opensocial_owner_id=\"owner\", opensocial_viewer_id=" +
   "\"owner\", opensocial_app_id=\"app\", opensocial_app_url=\"http%3A%2F%2Fwww.examp" +
   "le.com%2Fheader.xml\", oauth_version=\"1.0\", oauth_timestamp=\"1231461306\", oau" +
   "th_consumer_key=\"consumer\", oauth_signature_method=\"HMAC-SHA1\", oauth_nonce" +
   "=\"1231461308333563000\", oauth_session_handle=\"w0zAI1yN5ZRvmBX5kcVdra5%2BbZE%" +
   "3D\"");
 String filtered = OAuthResponseParams.filterSecrets(req.toString());
 checkStringContains(filtered, "oauth_session_handle=REMOVED");
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testIsHtmlWithoutHtmlTagContext() throws Exception {
 HttpRequest req = new HttpRequest(Uri.parse("http://www.example.org/"));
 HttpResponseBuilder builder = new HttpResponseBuilder()
   .addHeader("Content-Type", "text/html");
 assertTrue(RewriterUtils.isHtml(req, builder));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testJs() throws Exception {
 Gadget gadget = mockGadget();
 control.replay();
 HttpRequest req = new HttpRequest(CONTENT_URI);
 req.setRewriteMimeType("text/javascript");
 req.setCajaRequested(true);
 HttpResponse response = new HttpResponseBuilder().setResponseString("var a;").create();
 String sanitized = "___.di(IMPORTS___,'a');";
 assertTrue(rewrite(req, response).contains(sanitized));
 assertTrue(rewrite(req, response, gadget).contains(sanitized));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testJsWithoutCaja() throws Exception {
 Gadget gadget = mockGadget();
 control.replay();
 HttpRequest req = new HttpRequest(CONTENT_URI);
 req.setRewriteMimeType("text/javascript");
 req.setCajaRequested(false);
 HttpResponse response = new HttpResponseBuilder().setResponseString("var a;").create();
 String sanitized = "var a;";
 assertTrue(rewrite(req, response).contains(sanitized));
 assertTrue(rewrite(req, response, gadget).contains(sanitized));
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void renderProxiedFromCache() throws Exception {
 HttpRequest request = new HttpRequest(EXPECTED_PROXIED_HTML_HREF);
 request.setHeader("User-Agent", USER_AGENT_SET);
 HttpResponse response = new HttpResponse(PROXIED_HTML_CONTENT);
 cache.addResponse(request, response);
 String content = proxyRenderer.render(makeHrefGadget("none"));
 assertEquals(PROXIED_HTML_CONTENT, content);
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testImgWithPragmaNoCacheReservedAndFetchNotTriggered() throws Exception {
 cache.addResponse(new HttpRequest(Uri.parse(IMG_URL)),
          new HttpResponseBuilder().setResponseString("test")
            .addHeader("Pragma", "no-cache").create());
 checkVisitBypassedAndFetchTriggered("img", IMG_URL, false, false);
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void createKeySimple() {
 HttpRequest request = new HttpRequest(DEFAULT_URI).setAuthType(AuthType.NONE);
 CacheKeyBuilder key = new CacheKeyBuilder()
   .setLegacyParam(0, DEFAULT_URI).setLegacyParam(1, AuthType.NONE);
 assertEquals(key.build(), cache.createKey(request));
}
origin: org.apache.shindig/shindig-gadgets

 @Test
 public void removeResponse() {
  HttpRequest request = new HttpRequest(DEFAULT_URI);
  HttpResponse response = new HttpResponse("response");

  String key = httpCache.createKey(request);

  cache.addElement(key, response);

  assertEquals(response, httpCache.removeResponse(request));

  assertEquals(0, cache.getSize());
 }
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testHttp404() throws Exception {
 String content = "Hello, world!";
 Uri uri = new UriBuilder(BASE_URL)
   .addQueryParameter("body", content)
   .addQueryParameter("status", "404")
   .toUri();
 HttpRequest request = new HttpRequest(uri);
 HttpResponse response = fetcher.fetch(request);
 assertEquals(404, response.getHttpStatusCode());
 assertEquals(content, response.getResponseAsString());
}
origin: org.apache.shindig/shindig-gadgets

@Test public void testFollowRelativeRedirects() throws Exception {
 String content = "";
 Uri uri = new UriBuilder(BASE_URL)
   .addQueryParameter("body", content)
   .addQueryParameter("status", "302")
   .addQueryParameter("header", "Location=/?body=redirected")
   .toUri();
 HttpRequest request = new HttpRequest(uri);
 HttpResponse response = fetcher.fetch(request);
 assertEquals(200, response.getHttpStatusCode());
 assertEquals("redirected", response.getResponseAsString());
}
origin: org.apache.shindig/shindig-gadgets

 @Test
 public void testIsHtmlReturnsTrueIfHtmlAcceptingTagContext() throws Exception {
  HttpRequest req = new HttpRequest(Uri.parse("http://www.example.org/"));
  req.setParam(UriCommon.Param.HTML_TAG_CONTEXT.getKey(), "link");
  HttpResponseBuilder builder = new HttpResponseBuilder()
    .addHeader("Content-Type", "text/html");
  assertTrue(RewriterUtils.isHtml(req, builder));

  req.setParam(UriCommon.Param.HTML_TAG_CONTEXT.getKey(), "iframe");
  assertTrue(RewriterUtils.isHtml(req, builder));
 }
}
org.apache.shindig.gadgets.httpHttpRequest<init>

Javadoc

Construct a new request for the given uri.

Popular methods of HttpRequest

  • addHeader
    Add a single header to the request. If a value for the given name is already set, a second value is
  • getAuthType
  • getCacheTtl
  • getContainer
  • getFollowRedirects
  • getGadget
  • getHeader
  • getHeaders
  • getIgnoreCache
  • getMethod
  • getOAuthArguments
  • getParam
  • getOAuthArguments,
  • getParam,
  • getParamAsInteger,
  • getPostBody,
  • getPostBodyAsString,
  • getPostBodyLength,
  • getRewriteMimeType,
  • getSecurityToken,
  • getUri

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now