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

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

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

origin: org.apache.shindig/shindig-gadgets

private static byte[] getBody(final HttpRequest request) throws UnsupportedEncodingException {
 return request.getPostBodyAsString().getBytes("UTF-8");
}
origin: org.gatein.shindig/shindig-gadgets

@Override
public String toString() {
 StringBuilder buf = new StringBuilder(method);
 buf.append(' ').append(uri.getPath())
   .append(uri.getQuery() == null ? "" : '?' + uri.getQuery()).append("\n\n");
 buf.append("Host: ").append(uri.getAuthority()).append('\n');
 buf.append("X-Shindig-AuthType: ").append(authType).append('\n');
 for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
  String name = entry.getKey();
  for (String value : entry.getValue()) {
   buf.append(name).append(": ").append(value).append('\n');
  }
 }
 buf.append('\n');
 buf.append(getPostBodyAsString());
 return buf.toString();
}
origin: com.lmco.shindig/shindig-gadgets

@Override
public String toString() {
 StringBuilder buf = new StringBuilder(method);
 buf.append(' ').append(uri.getPath())
   .append(uri.getQuery() == null ? "" : '?' + uri.getQuery()).append("\n\n");
 buf.append("Host: ").append(uri.getAuthority()).append('\n');
 buf.append("X-Shindig-AuthType: ").append(authType).append('\n');
 for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
  String name = entry.getKey();
  for (String value : entry.getValue()) {
   buf.append(name).append(": ").append(value).append('\n');
  }
 }
 buf.append('\n');
 buf.append(getPostBodyAsString());
 return buf.toString();
}
origin: org.apache.shindig/shindig-gadgets

@Override
public String toString() {
 StringBuilder buf = new StringBuilder(method);
 buf.append(' ').append(uri.getPath())
   .append(uri.getQuery() == null ? "" : '?' + uri.getQuery()).append("\n\n");
 buf.append("Host: ").append(uri.getAuthority()).append('\n');
 buf.append("X-Shindig-AuthType: ").append(authType).append('\n');
 for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
  String name = entry.getKey();
  for (String value : entry.getValue()) {
   buf.append(name).append(": ").append(value).append('\n');
  }
 }
 buf.append('\n');
 buf.append(getPostBodyAsString());
 return buf.toString();
}
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: com.lmco.shindig/shindig-gadgets

@Test
public void postBodyCopied() throws Exception {
 HttpRequest request  = new HttpRequest(DEFAULT_URI).setPostBody(POST_BODY.getBytes());
 assertEquals(POST_BODY.length(), request.getPostBodyLength());
 assertEquals(POST_BODY, IOUtils.toString(request.getPostBody(), "UTF-8"));
 assertEquals(POST_BODY, request.getPostBodyAsString());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void postBodyCopied() throws Exception {
 HttpRequest request  = new HttpRequest(DEFAULT_URI).setPostBody(POST_BODY.getBytes());
 assertEquals(POST_BODY.length(), request.getPostBodyLength());
 assertEquals(POST_BODY, IOUtils.toString(request.getPostBody(), "UTF-8"));
 assertEquals(POST_BODY, request.getPostBodyAsString());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void postBodyCopied() throws Exception {
 HttpRequest request  = new HttpRequest(DEFAULT_URI).setPostBody(POST_BODY.getBytes());
 assertEquals(POST_BODY.length(), request.getPostBodyLength());
 assertEquals(POST_BODY, IOUtils.toString(request.getPostBody(), "UTF-8"));
 assertEquals(POST_BODY, request.getPostBodyAsString());
}
origin: org.apache.shindig/shindig-gadgets

@Test
public void testCopyRequestData() throws Exception {
 HttpRequest origRequest = new HttpRequest(Uri.parse("http://www.example.com"));
 origRequest.setMethod("Post");
 String data = "hello world";
 origRequest.setPostBody(data.getBytes());
 HttpRequest req = new HttpRequest(Uri.parse(
   "http://www.example.org/data.html"));
 UriUtils.copyRequestData(origRequest, req);
 assertEquals(data, req.getPostBodyAsString());
}
origin: org.wso2.org.apache.shindig/shindig-gadgets

@Test
public void testCopyRequestData() throws Exception {
 HttpRequest origRequest = new HttpRequest(Uri.parse("http://www.example.com"));
 origRequest.setMethod("Post");
 String data = "hello world";
 origRequest.setPostBody(data.getBytes());
 HttpRequest req = new HttpRequest(Uri.parse(
   "http://www.example.org/data.html"));
 UriUtils.copyRequestData(origRequest, req);
 assertEquals(data, req.getPostBodyAsString());
}
origin: com.lmco.shindig/shindig-gadgets

@Test
public void testCopyRequestData() throws Exception {
 HttpRequest origRequest = new HttpRequest(Uri.parse("http://www.example.com"));
 origRequest.setMethod("Post");
 
 String data = "hello world";
 origRequest.setPostBody(data.getBytes());
 
 HttpRequest req = new HttpRequest(Uri.parse(
   "http://www.example.org/data.html"));
 UriUtils.copyRequestData(origRequest, req);
 assertEquals(data, req.getPostBodyAsString());
}
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 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 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.httpHttpRequestgetPostBodyAsString

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
  • getMethod
  • getOAuthArguments
  • getMethod,
  • getOAuthArguments,
  • getParam,
  • getParamAsInteger,
  • getPostBody,
  • getPostBodyLength,
  • getRewriteMimeType,
  • getSecurityToken,
  • getUri

Popular in Java

  • Reactive rest calls using spring rest template
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Table (org.hibernate.mapping)
    A relational table
  • Top 12 Jupyter Notebook extensions
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