Example usage for org.apache.http.protocol HTTP DEFAULT_CONTENT_CHARSET

List of usage examples for org.apache.http.protocol HTTP DEFAULT_CONTENT_CHARSET

Introduction

In this page you can find the example usage for org.apache.http.protocol HTTP DEFAULT_CONTENT_CHARSET.

Prototype

String DEFAULT_CONTENT_CHARSET

To view the source code for org.apache.http.protocol HTTP DEFAULT_CONTENT_CHARSET.

Click Source Link

Usage

From source file:com.inferiorhumanorgans.WayToGo.Agency.BART.BaseXMLTask.java

@Override
protected Void doInBackground(final BARTAgency... someAgencies) {
    Assert.assertEquals(1, someAgencies.length);
    theAgency = someAgencies[0];//from  ww w  .j av  a2  s  .  com

    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);
    /*HttpConnectionParams.setConnectionTimeout(params, 1000);
    HttpConnectionParams.setSoTimeout(params, 1000);
    ConnManagerParams.setTimeout(params, 1000);*/

    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

    return null;
}

From source file:org.apache.sling.distribution.it.DistributionPackageExporterImporterTest.java

@Test
public void testAddExportImport() throws Exception {
    String nodePath = createRandomNode(publishClient, "/content/export_" + System.nanoTime());
    assertExists(publishClient, nodePath);

    String content = doExport(publish, "default", DistributionRequestType.ADD, nodePath);

    publishClient.delete(nodePath);//from  w  w  w.j  av  a 2  s .  co  m
    assertNotExists(publishClient, nodePath);

    doImport(publish, "default", content.getBytes(HTTP.DEFAULT_CONTENT_CHARSET));
    assertExists(publishClient, nodePath);

}

From source file:com.cloudbase.CBStringPart.java

/**
 * @param name String - name of parameter (may not be <code>null</code>).
 * @param value String - value of parameter (may not be <code>null</code>).
 * @param charset String, if null is passed then default "ISO-8859-1" charset is used.
 * /*w  w w . j a v  a2  s.c o m*/
 * @throws IllegalArgumentException if either <code>value</code> 
 *         or <code>name</code> is <code>null</code>.
 * @throws RuntimeException if <code>charset</code> is unsupported by OS.
 */
public CBStringPart(String name, String value, String charset) {
    if (name == null) {
        throw new IllegalArgumentException("Name may not be null"); //$NON-NLS-1$
    }
    if (value == null) {
        throw new IllegalArgumentException("Value may not be null"); //$NON-NLS-1$
    }

    final String partName = CBUrlEncodingHelper.encode(name, HTTP.DEFAULT_PROTOCOL_CHARSET);

    if (charset == null) {
        charset = HTTP.DEFAULT_CONTENT_CHARSET;
    }
    final String partCharset = charset;

    try {
        this.valueBytes = value.getBytes(partCharset);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    headersProvider = new IHeadersProvider() {
        public String getContentDisposition() {
            return "Content-Disposition: form-data; name=\"" + partName + '"'; //$NON-NLS-1$
        }

        public String getContentType() {
            return "Content-Type: " + HTTP.PLAIN_TEXT_TYPE + HTTP.CHARSET_PARAM + partCharset; //$NON-NLS-1$
        }

        public String getContentTransferEncoding() {
            return "Content-Transfer-Encoding: 8bit"; //$NON-NLS-1$
        }
    };
}

From source file:nl.igorski.lib.utils.network.ResponseParser.java

private static String _getResponseBody(final HttpEntity entity) throws IOException, ParseException {
    if (entity == null)
        throw new IllegalArgumentException("HTTP entity may not be null");

    InputStream instream = entity.getContent();

    if (instream == null)
        return "";

    if (entity.getContentLength() > Integer.MAX_VALUE)
        throw new IllegalArgumentException("HTTP entity too large to be buffered in memory");

    String charset = getContentCharSet(entity);

    if (charset == null)
        charset = HTTP.DEFAULT_CONTENT_CHARSET;

    Reader reader = new InputStreamReader(instream, charset);
    StringBuilder buffer = new StringBuilder();

    try {// w  w w  . ja  va 2s .co m
        char[] tmp = new char[1024];
        int l;
        while ((l = reader.read(tmp)) != -1) {
            buffer.append(tmp, 0, l);
        }
    } finally {
        reader.close();
    }
    return buffer.toString();
}

From source file:net.bitquill.ocr.weocr.WeOCRClient.java

public WeOCRClient(String endpoint) {
    mEndpoint = endpoint;//from w  ww. ja  v a2s .  c  o m
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);
    HttpProtocolParams.setUserAgent(params, USER_AGENT_STRING);
    HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
    mHttpClient = new DefaultHttpClient(params);
}

From source file:com.strato.hidrive.api.utils.multipart.StringPart.java

/**
 * @param name//from   w w w. ja v a  2 s  . c  o m
 *            String - name of parameter (may not be <code>null</code>).
 * @param value
 *            String - value of parameter (may not be <code>null</code>).
 * @param charset
 *            String, if null is passed then default "ISO-8859-1" charset is
 *            used.
 * 
 * @throws IllegalArgumentException
 *             if either <code>value</code> or <code>name</code> is
 *             <code>null</code>.
 * @throws RuntimeException
 *             if <code>charset</code> is unsupported by OS.
 */
public StringPart(String name, String value, String charset) {
    if (name == null) {
        throw new IllegalArgumentException("Name may not be null"); //$NON-NLS-1$
    }
    if (value == null) {
        throw new IllegalArgumentException("Value may not be null"); //$NON-NLS-1$
    }

    final String partName = UrlEncodingHelper.encode(name, HTTP.DEFAULT_PROTOCOL_CHARSET);

    if (charset == null) {
        charset = HTTP.DEFAULT_CONTENT_CHARSET;
    }
    final String partCharset = charset;

    try {
        this.valueBytes = value.getBytes(partCharset);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    headersProvider = new IHeadersProvider() {
        public String getContentDisposition() {
            return "Content-Disposition: form-data; name=\"" + partName + '"'; //$NON-NLS-1$
        }

        public String getContentType() {
            return "Content-Type: " + HTTP.PLAIN_TEXT_TYPE + HTTP.CHARSET_PARAM + partCharset; //$NON-NLS-1$
        }

        public String getContentTransferEncoding() {
            return "Content-Transfer-Encoding: 8bit"; //$NON-NLS-1$
        }
    };
}

From source file:org.bfr.querytools.spectrumbridge.SpectrumBridgeQuery.java

private static HttpClient createClient() {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);

    HttpClient client = new DefaultHttpClient(params);

    HttpConnectionParams.setConnectionTimeout(client.getParams(), 10 * 1000);
    HttpConnectionParams.setSoTimeout(client.getParams(), 10 * 1000);

    return client;
}

From source file:com.entertailion.android.launcher.utils.HttpRequestHelper.java

public static DefaultHttpClient createHttpClient() {
    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, 60000);
    HttpConnectionParams.setSoTimeout(params, 60000);
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUserAgent(params,
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.5 Safari/537.22");

    SchemeRegistry schReg = new SchemeRegistry();
    schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg);

    return new DefaultHttpClient(conMgr, params);
}

From source file:org.mariotaku.twidere.util.httpclient.UrlEncodedFormEntity.java

/**
 * Constructs a new {@link UrlEncodedFormEntity} with the list of parameters
 * in the specified encoding./*from   www . ja  v a  2s.co m*/
 * 
 * @param parameters list of name/value pairs
 * @param encoding encoding the name/value pairs be encoded with
 * @throws UnsupportedEncodingException if the encoding isn't supported
 */
public UrlEncodedFormEntity(final HttpParameter[] params) throws UnsupportedEncodingException {
    super(HttpParameter.encodeParameters(params), HTTP.DEFAULT_CONTENT_CHARSET);
    setContentType(URLEncodedUtils.CONTENT_TYPE + HTTP.CHARSET_PARAM + HTTP.DEFAULT_CONTENT_CHARSET);
}