Example usage for org.apache.http.entity BasicHttpEntity setContentType

List of usage examples for org.apache.http.entity BasicHttpEntity setContentType

Introduction

In this page you can find the example usage for org.apache.http.entity BasicHttpEntity setContentType.

Prototype

public void setContentType(Header header) 

Source Link

Usage

From source file:com.yangcong345.android.phone.manager.OkHttpStack.java

/**
 * Initializes an {@link HttpEntity} from the given {@link HttpURLConnection}.
 *
 * @return an HttpEntity populated with data from <code>connection</code>.
 *///w ww.j  a  v a  2  s.com
private static HttpEntity entityFromOkHttp(Response okResponse) {
    ResponseBody rb = okResponse.body();

    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream = rb.byteStream();
    entity.setContent(inputStream);
    entity.setContentLength(rb.contentLength());
    entity.setContentType(rb.contentType().type());
    return entity;
}

From source file:com.orange.retrytest.OkHttpStack.java

private static HttpEntity getEntity(Response response) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = response.body();
    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(response.header("Content-Encoding"));
    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }/*from ww w .j av a 2  s  . c o m*/
    return entity;
}

From source file:com.aix.city.comm.OkHttpStack.java

private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = r.body();/*from   w w w  . j a v  a 2 s  .  co  m*/

    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(r.header("Content-Encoding"));

    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }
    return entity;
}

From source file:com.objectivetruth.uoitlibrarybooking.app.networking.OkHttp3Stack.java

private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = r.body();/*  ww  w .  j  av a2s .  co m*/
    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(r.header("Content-Encoding"));

    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }
    return entity;
}

From source file:com.phattn.vnexpressnews.io.OkHttpStack.java

private static HttpEntity entityFromOkHttpResponse(Response response) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = response.body();

    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(response.header("Content-Encoding"));

    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }/*from ww w  .  j  ava  2s. co  m*/
    return entity;
}

From source file:com.eTilbudsavis.etasdk.network.impl.HttpURLNetwork.java

private static HttpEntity getEntity(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;/*from   w w  w .j a  v a  2 s. c  o  m*/
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}

From source file:com.androidso.lib.net.http.OkHttpStack.java

private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity() {
        @Override/* ww  w . ja  v a2  s  .  co  m*/
        public void consumeContent() {
            //                getContent().close();

        }
    };
    ResponseBody body = r.body();

    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(r.header("Content-Encoding"));

    if (body.contentType() != null) {
        entity.setContentType(body.contentType().type());
    }
    return entity;
}

From source file:cn.garymb.wechatmoments.common.OkHttpStack.java

@SuppressWarnings("deprecation")
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;//  w w  w . ja  va 2s. co  m
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}

From source file:ai.eve.volley.stack.HurlStack.java

/**
 * Initializes an {@link HttpEntity} from the given {@link HttpURLConnection}.
 * @return an HttpEntity populated with data from <code>connection</code>.
 *//* w ww.jav a2s  .  c  om*/
private static HttpEntity entityFromConnection(HttpURLConnection connection) {
    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}

From source file:com.kubeiwu.commontool.khttp.toolbox.HurlStack.java

/**
 * Initializes an {@link HttpEntity} from the given {@link HttpURLConnection}.
 * //w  w  w . jav a  2s  .  co  m
 * @param connection
 * @return an HttpEntity populated with data from <code>connection</code>.
 */
private static HttpEntity entityFromConnection(HttpURLConnection connection) {

    BasicHttpEntity entity = new BasicHttpEntity();
    InputStream inputStream;
    try {
        inputStream = connection.getInputStream();
    } catch (IOException ioe) {
        inputStream = connection.getErrorStream();
    }
    entity.setContent(inputStream);
    entity.setContentLength(connection.getContentLength());
    entity.setContentEncoding(connection.getContentEncoding());
    entity.setContentType(connection.getContentType());
    return entity;
}