Example usage for org.apache.http.impl.client EntityEnclosingRequestWrapper getEntity

List of usage examples for org.apache.http.impl.client EntityEnclosingRequestWrapper getEntity

Introduction

In this page you can find the example usage for org.apache.http.impl.client EntityEnclosingRequestWrapper getEntity.

Prototype

public HttpEntity getEntity() 

Source Link

Usage

From source file:com.netscape.certsrv.client.PKIConnection.java

public void storeRequest(File file, HttpRequest request) throws IOException {

    try (PrintStream out = new PrintStream(file)) {

        out.println(request.getRequestLine());

        for (Header header : request.getAllHeaders()) {
            out.println(header.getName() + ": " + header.getValue());
        }/*from ww w . j ava  2  s  .co  m*/

        out.println();

        if (request instanceof EntityEnclosingRequestWrapper) {
            EntityEnclosingRequestWrapper wrapper = (EntityEnclosingRequestWrapper) request;

            HttpEntity entity = wrapper.getEntity();
            if (entity == null)
                return;

            if (!entity.isRepeatable()) {
                BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity);
                wrapper.setEntity(bufferedEntity);
                entity = bufferedEntity;
            }

            storeEntity(out, entity);
        }
    }
}