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:ai.serotonin.haystack.validator.Source.java
/** * Read a remote database via the Project-Haystack protocol. * //from w w w. j ava 2 s .c o m * This method currently does not support authentication. * * @param endpoint * @return the list of rows returned * @throws Exception */ public static List<HMap> remote(String endpoint) throws Exception { String filter = "id"; //int limit = 10000; HMap map = new HMap().put("filter", filter); //.put("limit", limit); String entityStr = ZincWriter.gridToString(new HGrid(map)); HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost(endpoint + "read"); // Set the auth as required. StringEntity entity = new StringEntity(entityStr, ContentType.TEXT_PLAIN); post.setEntity(entity); String responseStr = HttpUtils4.getTextContent(client, post, 1); HGrid response = new ZincReader(responseStr).readGrid(); return response.getRows(); }
From source file:org.ow2.proactive.addons.webhook.service.JsonRestApacheRequestService.java
public RestResponse doRequest(String restMethod, String jsonHeader, String url, String content) throws IOException { Request request = apacheHttpClientRequestGetter.getHttpRequestByString(restMethod, url); for (Map.Entry<String, String> entry : jsonStringToHeaderMap.convert(jsonHeader).entrySet()) { request.addHeader(entry.getKey(), entry.getValue()); }//from w ww. j a v a2s.c o m if (content != null && !content.isEmpty()) { request.bodyString(content, ContentType.TEXT_PLAIN); } return executeRequest(request); }
From source file:io.gravitee.gateway.standalone.TransformRequestContentGatewayTest.java
@Test public void call_override_request_content() throws Exception { org.apache.http.client.fluent.Request request = org.apache.http.client.fluent.Request .Post("http://localhost:8082/echo/helloworld"); request.bodyString(BODY_CONTENT + " {#request.id}", ContentType.TEXT_PLAIN); org.apache.http.client.fluent.Response response = request.execute(); HttpResponse returnResponse = response.returnResponse(); assertEquals(HttpStatus.SC_OK, returnResponse.getStatusLine().getStatusCode()); String responseContent = StringUtils.copy(returnResponse.getEntity().getContent()); String[] parts = responseContent.split(":"); assertTrue(responseContent.startsWith(BODY_CONTENT)); assertTrue(UUID.fromString(parts[1].substring(1)) != null); }
From source file:com.github.tomakehurst.wiremock.GzipAcceptanceTest.java
@Test public void acceptsGzippedRequest() { wireMockServer.stubFor(any(urlEqualTo("/gzip-request")).withRequestBody(equalTo("request body")) .willReturn(aResponse().withBody("response body"))); HttpEntity compressedBody = new GzipCompressingEntity( new StringEntity("request body", ContentType.TEXT_PLAIN)); WireMockResponse response = testClient.post("/gzip-request", compressedBody); assertThat(response.content(), is("response body")); }
From source file:rxweb.RxJavaServerTests.java
public void echo() throws IOException { server.post("/test", (request, response) -> response.content(request.getContent())); String content = Request.Post("http://localhost:8080/test") .bodyString("This is a test!", ContentType.TEXT_PLAIN).execute().returnContent().asString(); Assert.assertEquals("This is a test!", content); }
From source file:com.github.yongchristophertang.engine.web.http.MultipartBodyFormBuilder.java
public MultipartBodyFormBuilder param(String name, Collection<String> values) { AssertUtils.notNull(name, "Parameter name must not be null."); values.stream().forEach(v -> builder.addTextBody(name, v, ContentType.TEXT_PLAIN)); return this; }
From source file:securitytools.veracode.http.request.UploadFileRequest.java
public UploadFileRequest(String applicationId, File file, String sandboxId) { super("/api/4.0/uploadfile.do"); if (applicationId == null) { throw new IllegalArgumentException("Application id cannot be null."); }// www .j a v a 2s .c om if (!file.canRead()) { throw new IllegalArgumentException("Cannot read file."); } MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); entityBuilder.addPart("app_id", new StringBody(applicationId, ContentType.TEXT_PLAIN)); if (sandboxId != null) { entityBuilder.addPart("sandbox_id", new StringBody(sandboxId, ContentType.TEXT_PLAIN)); } entityBuilder.addPart("file", new FileBody(file)); setEntity(entityBuilder.build()); }
From source file:org.wso2.carbon.appmanager.integration.ui.Util.Bean.DocumentRequest.java
@Override public void init() { addParameter("mode", new StringBody(mode, ContentType.TEXT_PLAIN)); addParameter("docUrl", new StringBody(docUrl, ContentType.TEXT_PLAIN)); addParameter("sourceType", new StringBody(sourceType, ContentType.TEXT_PLAIN)); addParameter("summary", new StringBody(summary, ContentType.TEXT_PLAIN)); addParameter("docType", new StringBody(docType, ContentType.TEXT_PLAIN)); addParameter("docName", new StringBody(docName, ContentType.TEXT_PLAIN)); addParameter("version", new StringBody(version, ContentType.TEXT_PLAIN)); addParameter("apiName", new StringBody(apiName, ContentType.TEXT_PLAIN)); addParameter("action", new StringBody(action, ContentType.TEXT_PLAIN)); addParameter("provider", new StringBody(provider, ContentType.TEXT_PLAIN)); addParameter("optionsRadios", new StringBody(optionsRadios, ContentType.TEXT_PLAIN)); addParameter("optionsRadios1", new StringBody(optionsRadios1, ContentType.TEXT_PLAIN)); if ("other".equalsIgnoreCase(docType)) { addParameter("newType", new StringBody(newType, ContentType.TEXT_PLAIN)); }/*from w w w .j a va 2 s .com*/ if ("file".equalsIgnoreCase(sourceType)) { FileBody bin = new FileBody(new File(docLocation)); addParameter("docLocation", bin); } }
From source file:com.braffdev.server.core.http.method.handler.TraceHttpMethodHandler.java
@Override public HttpResponse handle(PlainRequestEnvironment env, HttpServletRequest request) { HttpResponse response = env.getHttpResponse(); String requestContent = request.toString(); response.setEntity(new StringEntity(requestContent, ContentType.TEXT_PLAIN)); return response; }