Example usage for org.apache.http.entity.mime MultipartEntityBuilder addTextBody

List of usage examples for org.apache.http.entity.mime MultipartEntityBuilder addTextBody

Introduction

In this page you can find the example usage for org.apache.http.entity.mime MultipartEntityBuilder addTextBody.

Prototype

public MultipartEntityBuilder addTextBody(final String name, final String text) 

Source Link

Usage

From source file:org.roda.core.common.SeleniumUtils.java

private static void sendPostRequest(String source) {
    CloseableHttpClient httpClient = HttpClientBuilder.create().build();

    MultipartEntityBuilder builder = MultipartEntityBuilder.create();
    builder.addTextBody("input", source);

    HttpPost httpPost = new HttpPost("http://www.acessibilidade.gov.pt/accessmonitor/");
    httpPost.setEntity(builder.build());

    try {//from w  w w.j av a 2s .co m
        CloseableHttpResponse response = httpClient.execute(httpPost);
        System.err.println(response);

        for (Header h : response.getAllHeaders()) {
            if ("location".equalsIgnoreCase(h.getName())) {
                locations.put(h.getValue(), driver.getCurrentUrl());
            }
        }
    } catch (IOException e) {
        System.err.println("Error sending POST request!");
    }
}