Example usage for org.apache.http.entity ByteArrayEntityHC4 ByteArrayEntityHC4

List of usage examples for org.apache.http.entity ByteArrayEntityHC4 ByteArrayEntityHC4

Introduction

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

Prototype

public ByteArrayEntityHC4(final byte[] b) 

Source Link

Usage

From source file:org.thoughtcrime.securesms.mms.OutgoingMmsConnection.java

@Override
protected HttpUriRequest constructRequest(boolean useProxy) throws IOException {
    HttpPostHC4 request = new HttpPostHC4(apn.getMmsc());
    request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
    request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
    request.addHeader("Content-Type", "application/vnd.wap.mms-message");
    request.setEntity(new ByteArrayEntityHC4(mms));
    if (useProxy) {
        HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
        request.setConfig(RequestConfig.custom().setProxy(proxy).build());
    }//from  w  w  w . j a va2 s . com
    return request;
}

From source file:com.tingtingapps.securesms.mms.OutgoingLegacyMmsConnection.java

private HttpUriRequest constructRequest(byte[] pduBytes, boolean useProxy) throws IOException {
    try {//from  w  w w .  j  a  v a  2 s .  c o m
        HttpPostHC4 request = new HttpPostHC4(apn.getMmsc());
        for (Header header : getBaseHeaders()) {
            request.addHeader(header);
        }

        request.setEntity(new ByteArrayEntityHC4(pduBytes));
        if (useProxy) {
            HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
            request.setConfig(RequestConfig.custom().setProxy(proxy).build());
        }
        return request;
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae);
    }
}

From source file:at.bitfire.davdroid.webdav.WebDavResource.java

public String put(byte[] data, PutMode mode) throws URISyntaxException, IOException, HttpException {
    HttpPutHC4 put = new HttpPutHC4(location);
    put.setEntity(new ByteArrayEntityHC4(data));

    switch (mode) {
    case ADD_DONT_OVERWRITE:
        put.addHeader("If-None-Match", "*");
        break;/*from w w w  .  j a  va2 s. c o  m*/
    case UPDATE_DONT_OVERWRITE:
        put.addHeader("If-Match", (properties.eTag != null) ? properties.eTag : "*");
        break;
    }

    if (properties.contentType != null)
        put.addHeader("Content-Type", properties.contentType.toString());

    @Cleanup
    CloseableHttpResponse response = httpClient.execute(put, context);
    checkResponse(response);

    Header eTag = response.getLastHeader("ETag");
    if (eTag != null)
        return eTag.getValue();

    return null;
}

From source file:com.granita.icloudcalsync.webdav.WebDavResource.java

public String put(byte[] data, PutMode mode) throws URISyntaxException, IOException, HttpException {
    HttpPutHC4 put = new HttpPutHC4(location);
    put.setEntity(new ByteArrayEntityHC4(data));

    switch (mode) {
    case ADD_DONT_OVERWRITE:
        put.addHeader("If-None-Match", "*");
        break;//from  w w w  . ja v a 2s  .c om
    case UPDATE_DONT_OVERWRITE:
        put.addHeader("If-Match", (getETag() != null) ? getETag() : "*");
        break;
    }

    if (getContentType() != null)
        put.addHeader("Content-Type", getContentType());

    @Cleanup
    CloseableHttpResponse response = httpClient.execute(put, context);
    checkResponse(response);

    Header eTag = response.getLastHeader("ETag");
    if (eTag != null)
        return eTag.getValue();

    return null;
}