Package org.apache.http.entity

Examples of org.apache.http.entity.StringEntity


    {
      HttpPost httppost = new HttpPost(url);
      if (body != null)
      {
        httppost.setHeader("Content-Type", "application/x-www-form-urlencoded");
        httppost.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httppost, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here


    {
      HttpPut httpput = new HttpPut(url);
      if (body != null)
      {
        httpput.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpput.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httpput, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here

    {
      HttpPost httppost = new HttpPost(url);
      if (body != null)
      {
        httppost.setHeader("Content-Type", "application/json;charset=UTF-8");
        httppost.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httppost, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here

    {
      HttpPut httpput = new HttpPut(url);
      if (body != null)
      {
        httpput.setHeader("Content-Type", "application/json;charset=UTF-8");
        httpput.setEntity(new StringEntity(body, "UTF-8"));
      }
      map = executeMethod(httpput, url, body, connectionTimeout, soTimeout);
    }
    catch (UnsupportedEncodingException e)
    {
View Full Code Here

            report.put("metrics", MetricUtils.mapAllFiltered(metricRegistry.getMetrics(), METRICS_BLACKLIST));
            report.put("statistics", buildStatistics());

            String json = objectMapper.writeValueAsString(report);

            postBody = new GzipCompressingEntity(new StringEntity(json, Charsets.UTF_8));
        } catch (JsonProcessingException e) {
            LOG.error("Telemetry is activated but sending failed.", e);
            return;
        }
View Full Code Here

                final String charset = partContentType.getParameters().get(ContentType.PARAMETER_CHARSET);

                final String body = response.getBody();
                content = body != null ? new ByteArrayInputStream(body.getBytes(charset)) : null;

                httpResponse.setEntity(new StringEntity(body, charset));
            }

            AbstractFutureCallback.checkStatus(httpResponse);
        } catch (ODataApplicationException e) {
            return new Olingo2BatchResponse(
View Full Code Here

        URL trustStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
        System.setProperty("javax.net.ssl.trustStore", trustStoreUrl.toURI().getPath());
       
        HttpPost post = new HttpPost("https://localhost:" + portNum + "/users/");
        post.addHeader(Exchange.CONTENT_TYPE, "application/xml");
        post.setEntity(new StringEntity(message));

        HttpResponse response = doExecute(post);
        assertHttpResponse(response, 200, "application/xml");
        String s = context.getTypeConverter().convertTo(String.class, response.getEntity().getContent());
        assertEquals("<status>OK</status>", s);
View Full Code Here

                            Charset cs = contentType.getCharset();
                            if (cs != null) {
                                charset = cs.name();
                            }
                        }
                        StringEntity entity = new StringEntity((String) data, charset);
                        if (contentType != null) {
                            entity.setContentType(contentType.toString());
                        }
                        answer = entity;
                    }

                    // fallback as input stream
                    if (answer == null) {
                        // force the body as an input stream since this is the fallback
                        InputStream is = in.getMandatoryBody(InputStream.class);
                        InputStreamEntity entity = new InputStreamEntity(is, -1);
                        if (contentType != null) {
                            entity.setContentType(contentType.toString());
                        }
                        answer = entity;
                    }
                }
            } catch (UnsupportedEncodingException e) {
View Full Code Here

    }
   
    @Test
    public void testPutConsumer() throws Exception {
        HttpPut put = new HttpPut("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers");
        StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        put.setEntity(entity);
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

        try {
            HttpResponse response = httpclient.execute(put);
View Full Code Here

   
    @Test
    public void testPostConsumer() throws Exception {
        HttpPost post = new HttpPost("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers");
        post.addHeader("Accept" , "text/xml");
        StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
        entity.setContentType("text/xml; charset=ISO-8859-1");
        post.setEntity(entity);
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

        try {
            HttpResponse response = httpclient.execute(post);
View Full Code Here

TOP

Related Classes of org.apache.http.entity.StringEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.