Tabnine Logo
HttpRequest.getMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
getMethod
method
in
org.apache.shindig.gadgets.http.HttpRequest

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

origin: com.lmco.shindig/shindig-gadgets

protected boolean isCacheable(HttpRequest request) {
 if (request.getIgnoreCache()) {
  return false;
 }
 return ("GET".equals(request.getMethod()) ||
     "GET".equals(request.getHeader("X-Method-Override")));
}
origin: org.apache.shindig/shindig-gadgets

protected boolean isCacheable(HttpRequest request) {
 if (request.getIgnoreCache()) {
  return false;
 }
 return ("GET".equals(request.getMethod()) ||
     "GET".equals(request.getHeader("X-Method-Override")));
}
origin: org.gatein.shindig/shindig-gadgets

protected boolean isCacheable(HttpRequest request) {
 if (request.getIgnoreCache()) {
  return false;
 }
 return ("GET".equals(request.getMethod()) ||
     "GET".equals(request.getHeader("X-Method-Override")));
}
origin: org.gatein.shindig/shindig-gadgets

/**
 * Copies the post data from HttpServletRequest object to HttpRequest object.
 * @param origRequest Request to copy post data from.
 * @param req The HttpRequest object to copy post data to.
 * @throws GadgetException In case of errors.
 */
public static void copyRequestData(HttpRequest origRequest,
                  HttpRequest req) throws GadgetException {
 req.setMethod(origRequest.getMethod());
 try {
  if (origRequest.getMethod().equalsIgnoreCase("post")) {
   req.setPostBody(origRequest.getPostBody());
  }
 } catch (IOException e) {
  throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
 }
}
origin: org.apache.shindig/shindig-gadgets

/**
 * Copies the post data from HttpServletRequest object to HttpRequest object.
 * @param origRequest Request to copy post data from.
 * @param req The HttpRequest object to copy post data to.
 * @throws GadgetException In case of errors.
 */
public static void copyRequestData(HttpRequest origRequest,
                  HttpRequest req) throws GadgetException {
 req.setMethod(origRequest.getMethod());
 try {
  if (origRequest.getMethod().equalsIgnoreCase("post")) {
   req.setPostBody(origRequest.getPostBody());
  }
 } catch (IOException e) {
  throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
 }
}
origin: com.lmco.shindig/shindig-gadgets

/**
 * Copies the post data from HttpServletRequest object to HttpRequest object.
 * @param origRequest Request to copy post data from.
 * @param req The HttpRequest object to copy post data to.
 * @throws GadgetException In case of errors.
 */
public static void copyRequestData(HttpRequest origRequest,
                  HttpRequest req) throws GadgetException {
 req.setMethod(origRequest.getMethod());
 try {
  if (origRequest.getMethod().equalsIgnoreCase("post")) {
   req.setPostBody(origRequest.getPostBody());
  }
 } catch (IOException e) {
  throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
 }
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

 public boolean matches(Object obj) {
  HttpRequest match = (HttpRequest)obj;
  return (match.getMethod().equals(req.getMethod()) &&
    match.getUri().equals(req.getUri()) &&
    match.getAuthType().equals(req.getAuthType()) &&
    match.getPostBodyAsString().equals(req.getPostBodyAsString()) &&
    Objects.equal(match.getOAuthArguments(), req.getOAuthArguments()) &&
    match.getHeaders().equals(req.getHeaders()));
 }
}
origin: org.apache.shindig/shindig-gadgets

 public boolean matches(Object obj) {
  HttpRequest match = (HttpRequest)obj;
  return (match.getMethod().equals(req.getMethod()) &&
    match.getUri().equals(req.getUri()) &&
    match.getAuthType().equals(req.getAuthType()) &&
    match.getPostBodyAsString().equals(req.getPostBodyAsString()) &&
    Objects.equal(match.getOAuthArguments(), req.getOAuthArguments()) &&
    match.getHeaders().equals(req.getHeaders()));
 }
}
origin: com.lmco.shindig/shindig-gadgets

 public boolean matches(Object obj) {
  HttpRequest match = (HttpRequest)obj;
  return (match.getMethod().equals(req.getMethod()) &&
    match.getUri().equals(req.getUri()) &&
    match.getAuthType().equals(req.getAuthType()) &&
    match.getPostBodyAsString().equals(req.getPostBodyAsString()) &&
    Objects.equal(match.getOAuthArguments(), req.getOAuthArguments()) &&
    match.getHeaders().equals(req.getHeaders()));
 }
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void renderProxiedWithPreload() throws Exception {
 List<JSONObject> prefetchedJson = ImmutableList.of(new JSONObject("{id: 'foo', data: 'bar'}"));
 pipelineExecutor.results = new PipelineExecutor.Results(null, prefetchedJson, null);
 pipeline.plainResponses.put(EXPECTED_PROXIED_HTML_HREF, new HttpResponse(PROXIED_HTML_CONTENT));
 String content = proxyRenderer.render(makeHrefGadget("none"));
 assertEquals(PROXIED_HTML_CONTENT, content);
 HttpRequest lastHttpRequest = pipeline.getLastHttpRequest();
 assertEquals("POST", lastHttpRequest.getMethod());
 assertEquals("application/json;charset=utf-8", lastHttpRequest.getHeader("Content-Type"));
 String postBody = lastHttpRequest.getPostBodyAsString();
 JsonAssert.assertJsonEquals(JsonSerializer.serialize(prefetchedJson), postBody);
 assertTrue(pipelineExecutor.wasPreloaded);
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void renderProxiedWithPreload() throws Exception {
 List<JSONObject> prefetchedJson = ImmutableList.of(new JSONObject("{id: 'foo', data: 'bar'}"));
 pipelineExecutor.results = new PipelineExecutor.Results(null, prefetchedJson, null);
 pipeline.plainResponses.put(EXPECTED_PROXIED_HTML_HREF, new HttpResponse(PROXIED_HTML_CONTENT));
 String content = proxyRenderer.render(makeHrefGadget("none"));
 assertEquals(PROXIED_HTML_CONTENT, content);
 HttpRequest lastHttpRequest = pipeline.getLastHttpRequest();
 assertEquals("POST", lastHttpRequest.getMethod());
 assertEquals("application/json;charset=utf-8", lastHttpRequest.getHeader("Content-Type"));
 String postBody = lastHttpRequest.getPostBodyAsString();
 JsonAssert.assertJsonEquals(JsonSerializer.serialize(prefetchedJson), postBody);
 assertTrue(pipelineExecutor.wasPreloaded);
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void renderProxiedWithPreload() throws Exception {
 List<JSONObject> prefetchedJson = ImmutableList.of(new JSONObject("{id: 'foo', data: 'bar'}"));
 
 pipelineExecutor.results = new PipelineExecutor.Results(null, prefetchedJson, null);
 pipeline.plainResponses.put(EXPECTED_PROXIED_HTML_HREF, new HttpResponse(PROXIED_HTML_CONTENT));
 String content = proxyRenderer.render(makeHrefGadget("none"));
 assertEquals(PROXIED_HTML_CONTENT, content);
 HttpRequest lastHttpRequest = pipeline.getLastHttpRequest();
 assertEquals("POST", lastHttpRequest.getMethod());
 assertEquals("application/json;charset=utf-8", lastHttpRequest.getHeader("Content-Type"));
 String postBody = lastHttpRequest.getPostBodyAsString();
 JsonAssert.assertJsonEquals(JsonSerializer.serialize(prefetchedJson), postBody);
 assertTrue(pipelineExecutor.wasPreloaded);
}

origin: org.apache.shindig/shindig-gadgets

@Test
public void testHttpPreloadWithGetParams() throws Exception {
 GadgetSpec spec = new GadgetSpec(GADGET_URL, XML_WITH_HTTP_REQUEST_AND_GET_PARAMS);
 String httpResult = "{foo: 'bar'}";
 RecordingRequestPipeline pipeline = new RecordingRequestPipeline(httpResult);
 PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
 view = "profile";
 Gadget gadget = new Gadget()
   .setContext(context)
   .setSpec(spec)
   .setCurrentView(spec.getView("profile"));
 PipelinedData.Batch batch = getBatch(gadget);
 Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
   context, batch);
 tasks.iterator().next().call();
 // Should have only fetched one request
 assertEquals(1, pipeline.requests.size());
 HttpRequest request = pipeline.requests.get(0);
 assertEquals(HTTP_REQUEST_URL + '?' + PARAMS, request.getUri().toString());
 assertEquals("GET", request.getMethod());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testHttpPreloadWithGetParams() throws Exception {
 GadgetSpec spec = new GadgetSpec(GADGET_URL, XML_WITH_HTTP_REQUEST_AND_GET_PARAMS);
 String httpResult = "{foo: 'bar'}";
 RecordingRequestPipeline pipeline = new RecordingRequestPipeline(httpResult);
 PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
 view = "profile";
 Gadget gadget = new Gadget()
   .setContext(context)
   .setSpec(spec)
   .setCurrentView(spec.getView("profile"));
 PipelinedData.Batch batch = getBatch(gadget);
 Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
   context, batch);
 tasks.iterator().next().call();
 // Should have only fetched one request
 assertEquals(1, pipeline.requests.size());
 HttpRequest request = pipeline.requests.get(0);
 assertEquals(HTTP_REQUEST_URL + '?' + PARAMS, request.getUri().toString());
 assertEquals("GET", request.getMethod());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testHttpPreloadWithPostParams() throws Exception {
 GadgetSpec spec = new GadgetSpec(GADGET_URL, XML_WITH_HTTP_REQUEST_AND_PARAMS);
 String httpResult = "{foo: 'bar'}";
 RecordingRequestPipeline pipeline = new RecordingRequestPipeline(httpResult);
 PipelinedDataPreloader preloader = new PipelinedDataPreloader(pipeline, containerConfig);
 view = "profile";
 Gadget gadget = new Gadget()
   .setContext(context)
   .setSpec(spec)
   .setCurrentView(spec.getView("profile"));
 PipelinedData.Batch batch = getBatch(gadget);
 Collection<Callable<PreloadedData>> tasks = preloader.createPreloadTasks(
   context, batch);
 tasks.iterator().next().call();
 // Should have only fetched one request
 assertEquals(1, pipeline.requests.size());
 HttpRequest request = pipeline.requests.get(0);
 assertEquals(HTTP_REQUEST_URL, request.getUri().toString());
 assertEquals("POST", request.getMethod());
 assertEquals(PARAMS, request.getPostBodyAsString());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testHtmlAccelHandlesPost() throws Exception {
 String url = "http://example.org/data.html";
 String data = "<html><body>This is error page</body></html>";
 ((FakeCaptureRewriter) rewriter).setContentToRewrite(data);
 Capture<HttpRequest> req = new Capture<HttpRequest>();
 HttpResponse resp = new HttpResponseBuilder()
   .setResponse(data.getBytes())
   .setHeader("Content-Type", "text/html")
   .create();
 expect(pipeline.execute(capture(req))).andReturn(resp).once();
 expectPostRequest("", url, "hello=world");
 replay();
 servlet.doPost(request, recorder);
 verify();
 assertEquals(data, recorder.getResponseAsString());
 assertEquals(200, recorder.getHttpStatusCode());
 assertTrue(rewriter.responseWasRewritten());
 assertEquals("POST", req.getValue().getMethod());
 assertEquals("hello=world", req.getValue().getPostBodyAsString());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testHtmlAccelHandlesPost() throws Exception {
 String url = "http://example.org/data.html";
 String data = "<html><body>This is error page</body></html>";
 ((FakeCaptureRewriter) rewriter).setContentToRewrite(data);
 Capture<HttpRequest> req = new Capture<HttpRequest>();
 HttpResponse resp = new HttpResponseBuilder()
   .setResponse(data.getBytes())
   .setHeader("Content-Type", "text/html")
   .create();
 expect(pipeline.execute(capture(req))).andReturn(resp).once();
 expectPostRequest("", url, "hello=world");
 replay();
 servlet.doPost(request, recorder);
 verify();
 assertEquals(data, recorder.getResponseAsString());
 assertEquals(200, recorder.getHttpStatusCode());
 assertTrue(rewriter.responseWasRewritten());
 assertEquals("POST", req.getValue().getMethod());
 assertEquals("hello=world", req.getValue().getPostBodyAsString());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testHtmlAccelHandlesPost() throws Exception {
 String url = "http://example.org/data.html";
 String data = "<html><body>This is error page</body></html>";
 ((FakeCaptureRewriter) rewriter).setContentToRewrite(data);
 Capture<HttpRequest> req = new Capture<HttpRequest>();
 HttpResponse resp = new HttpResponseBuilder()
   .setResponse(data.getBytes())
   .setHeader("Content-Type", "text/html")
   .create();
 expect(pipeline.execute(capture(req))).andReturn(resp).once();
 expectPostRequest("", url, "hello=world");
 replay();
 servlet.doPost(request, recorder);
 verify();
 assertEquals(data, recorder.getResponseAsString());
 assertEquals(200, recorder.getHttpStatusCode());
 assertTrue(rewriter.responseWasRewritten());
 assertEquals("POST", req.getValue().getMethod());
 assertEquals("hello=world", req.getValue().getPostBodyAsString());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testGetAuthorizationRequest_5() throws Exception {
 final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
 final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
 final String completeAuthorizationUrl = "xxx";
 final HttpRequest result = fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
 Assert.assertNotNull(result);
 final String postBody = result.getPostBodyAsString();
 Assert.assertNotNull(postBody);
 Assert.assertEquals(
   "client_id=clientId1&client_secret=clientSecret1&grant_type=client_credentials", postBody);
 Assert.assertNotNull( result.getSecurityToken() );
 Assert.assertTrue( result.getSecurityToken().isAnonymous() );
 Assert.assertEquals( accessor.getGadgetUri(), result.getSecurityToken().getAppUrl() );
 Assert.assertEquals("POST", result.getMethod());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testGetAuthorizationRequest_5() throws Exception {
 final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
 final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
 final String completeAuthorizationUrl = "xxx";
 final HttpRequest result = fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
 Assert.assertNotNull(result);
 final String postBody = result.getPostBodyAsString();
 Assert.assertNotNull(postBody);
 Assert.assertEquals(
   "client_id=clientId1&client_secret=clientSecret1&grant_type=client_credentials", postBody);
 Assert.assertNotNull( result.getSecurityToken() );
 Assert.assertTrue( result.getSecurityToken().isAnonymous() );
 Assert.assertEquals( accessor.getGadgetUri(), result.getSecurityToken().getAppUrl() );
 Assert.assertEquals("POST", result.getMethod());
}
org.apache.shindig.gadgets.httpHttpRequestgetMethod

Popular methods of HttpRequest

  • <init>
    Clone an existing 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
  • getOAuthArguments
  • getParam
  • getOAuthArguments,
  • getParam,
  • getParamAsInteger,
  • getPostBody,
  • getPostBodyAsString,
  • getPostBodyLength,
  • getRewriteMimeType,
  • getSecurityToken,
  • getUri

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Reference (javax.naming)
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JLabel (javax.swing)
  • From CI to AI: The AI layer in your organization
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