List of usage examples for org.apache.http.entity ContentType TEXT_PLAIN
ContentType TEXT_PLAIN
To view the source code for org.apache.http.entity ContentType TEXT_PLAIN.
Click Source Link
From source file:org.camunda.bpm.RestDeployment.java
public static void main(String[] args) throws IOException { if (args.length == 0) { System.err.println("No process files specified"); System.exit(1);/*from w w w . ja v a2 s . co m*/ } CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost("http://localhost:8080/engine-rest/deployment/create"); StringBody deploymentName = new StringBody("myDeployment", ContentType.TEXT_PLAIN); StringBody enableDuplicateFiltering = new StringBody("true", ContentType.TEXT_PLAIN); StringBody deployChangedOnly = new StringBody("true", ContentType.TEXT_PLAIN); MultipartEntityBuilder builder = MultipartEntityBuilder.create().addPart("deployment-name", deploymentName) .addPart("enable-duplicate-filtering", enableDuplicateFiltering) .addPart("deploy-changed-only", deployChangedOnly); for (String resource : args) { File resourceFile = new File(resource); FileBody fileBody = new FileBody(resourceFile); builder.addPart(resourceFile.getName(), fileBody); } HttpEntity httpEntity = builder.build(); httpPost.setEntity(httpEntity); HttpResponse response = httpClient.execute(httpPost); logResponse(response); }
From source file:demo.example.ClientMultipartFormPost.java
public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("File path not given"); System.exit(1);/*ww w. ja v a 2s. c o m*/ } CloseableHttpClient httpclient = HttpClients.createDefault(); try { HttpPost httppost = new HttpPost( "http://localhost:8080" + "/servlets-examples/servlet/RequestInfoExample"); FileBody bin = new FileBody(new File(args[0])); StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN); HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("bin", bin).addPart("comment", comment) .build(); httppost.setEntity(reqEntity); System.out.println("executing request " + httppost.getRequestLine()); CloseableHttpResponse response = httpclient.execute(httppost); try { System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { System.out.println("Response content length: " + resEntity.getContentLength()); } EntityUtils.consume(resEntity); } finally { response.close(); } } finally { httpclient.close(); } }
From source file:uk.ac.aber.dcs.cs22120.group16.utilities.ClientMultipartFormPost.java
public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("File path not given"); System.exit(1);/* w w w. ja v a 2 s . com*/ } CloseableHttpClient httpclient = HttpClients.createDefault(); try { HttpPost httppost = new HttpPost( "http://localhost:8080" + "/servlets-examples/servlet/RequestInfoExample"); FileBody bin = new FileBody(new File(args[0])); StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN); HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("bin", bin).addPart("comment", comment) .build(); httppost.setEntity(reqEntity); System.out.println("executing request " + httppost.getRequestLine()); CloseableHttpResponse response = httpclient.execute(httppost); try { System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { System.out.println("Response content length: " + resEntity.getContentLength()); } consume(resEntity); } finally { response.close(); } } finally { httpclient.close(); } }
From source file:com.lexmark.saperion.util.ClientMultipartFormPost.java
public static void main(String[] args) throws Exception { String userName = "amolugu"; String password = "ecm"; String authString = userName + ":" + password; byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); String authStringEnc = new String(authEncBytes); CloseableHttpClient httpclient = HttpClients.createDefault(); try {/*from w w w . j a v a 2 s .c o m*/ HttpPost httpPost = new HttpPost("https://ecm-service.psft.co/ecms/documents"); //http httpPost.addHeader("Authorization", "Basic " + authStringEnc); httpPost.addHeader("Accept", "application/json"); httpPost.addHeader("saTenant", "india"); httpPost.addHeader("saLicense", "1"); httpPost.addHeader("Content-Type", "application/octet-stream"); FileBody bin = new FileBody(new File("C:\\Users\\Aditya.Molugu\\workspace\\RestClient\\Binaries.txt")); StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN); HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("bin", bin).addPart("comment", comment) .build(); //HttpBo httpPost.setEntity(reqEntity); System.out.println("executing request " + httpPost.getRequestLine()); CloseableHttpResponse response = httpclient.execute(httpPost); try { System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { System.out.println("Response content length: " + resEntity.getContentLength()); } EntityUtils.consume(resEntity); } finally { response.close(); } } finally { httpclient.close(); } }
From source file:org.adridadou.ethereum.swarm.SwarmService.java
public SwarmHash publish(final String content) { try {//from w w w. j a va 2 s . c om Response response = Request.Post(host + "/bzzr:/").bodyString(content, ContentType.TEXT_PLAIN) .execute(); return SwarmHash.of(response.returnContent().asString()); } catch (IOException e) { throw new EthereumApiException("error while publishing the smart contract metadata to Swarm", e); } }
From source file:app.controllers.MultipartControllerTest.java
@Test public void testUpload0() { THttpMultipart form = client().request("/multipart/upload0").multipart(); form.addBytes("bin", new byte[] { 1 }).addText("comment", "A binary file of some kind", ContentType.TEXT_PLAIN.getMimeType()); THttpResponse response = form.send(); response.assertContentEquals("bin,comment"); }
From source file:leap.webunit.FormTest.java
@Test public void testMultipartForm() throws IOException { THttpMultipart multipart = client().request("/upload").multipart(); multipart.addBytes("bin", new byte[] { 1 }).addText("comment", "A binary file of some kind", ContentType.TEXT_PLAIN.getMimeType()); THttpResponse response = multipart.send(); response.assertContentEquals("bin,comment"); }
From source file:org.camunda.connect.httpclient.TestResponse.java
public TestResponse payload(String payload) { return payload(payload, ContentType.TEXT_PLAIN); }
From source file:gobblin.writer.http.RestWriter.java
@Override public Optional<HttpUriRequest> onNewRecord(RestEntry<String> record) { HttpUriRequest uriRequest = RequestBuilder.post() .addHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_PLAIN.getMimeType()) .setUri(combineUrl(getCurServerHost(), record.getResourcePath())) .setEntity(new StringEntity(record.getRestEntryVal(), ContentType.TEXT_PLAIN)).build(); return Optional.of(uriRequest); }
From source file:org.openehealth.ipf.tutorials.ref.Client.java
public Client() { mgr = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(mgr).build(); contentType = ContentType.TEXT_PLAIN; }