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

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

Introduction

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

Prototype

String CHARSET_PARAM

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

Click Source Link

Usage

From source file:com.googlecode.sardine.impl.methods.HttpLock.java

public HttpLock(URI url) {
    this.setURI(url);
    this.setHeader("Content-Type", "text/xml" + HTTP.CHARSET_PARAM + HTTP.UTF_8.toLowerCase());
}

From source file:com.googlecode.sardine.impl.methods.HttpMkCol.java

public HttpMkCol(URI url) {
    this.setURI(url);
    this.setHeader("Content-Type", "text/xml" + HTTP.CHARSET_PARAM + HTTP.UTF_8.toLowerCase());
}

From source file:com.googlecode.sardine.impl.methods.HttpPropPatch.java

public HttpPropPatch(URI url) {
    this.setURI(url);
    this.setHeader("Content-Type", "text/xml" + HTTP.CHARSET_PARAM + HTTP.UTF_8.toLowerCase());
}

From source file:com.googlecode.sardine.impl.methods.HttpPropFind.java

/**
 * Sets the <code>Depth</code> request header to <code>1</code>, meaning the
 * request applies to the resource and its children.
 *
 * @param uri The resource//w ww . ja  v  a 2s. c o m
 */
public HttpPropFind(final URI uri) {
    this.setDepth(String.valueOf("1"));
    this.setURI(uri);
    this.setHeader("Content-Type", "text/xml" + HTTP.CHARSET_PARAM + HTTP.UTF_8.toLowerCase());
}

From source file:com.googlecode.sardine.impl.methods.HttpUnlock.java

/**
 * @param url   The resource/*from   w w  w . jav  a  2s. co  m*/
 * @param token The Lock-Token request header is used with the UNLOCK method to identify the lock to be removed.
 *              The lock token in the Lock-Token request header must identify a lock that contains the resource
 *              identified by Request-URI as a member.
 */
public HttpUnlock(URI url, String token) {
    this.setURI(url);
    this.setHeader("Content-Type", "text/xml" + HTTP.CHARSET_PARAM + HTTP.UTF_8.toLowerCase());
    this.setHeader("Lock-Token", "<" + token + ">");
}

From source file:com.nesscomputing.httpclient.factory.httpclient4.BetterStringEntity.java

/**
 * Creates a StringEntity with the specified content and charset
 *
 * @param string content to be used. Not {@code null}.
 * @param charset character set to be used. May be {@code null}, in which case the default is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
 *
 * @throws IllegalArgumentException if the string parameter is null
 *///ww  w  .j av  a  2  s . co  m
BetterStringEntity(final String string, Charset charset) {
    super();
    Preconditions.checkArgument(string != null, "Source string may not be null");

    final Charset charsetObj = ObjectUtils.firstNonNull(charset, Charsets.ISO_8859_1);
    this.content = string.getBytes(charsetObj);
    setContentType(HTTP.PLAIN_TEXT_TYPE + HTTP.CHARSET_PARAM + charsetObj.name());
}

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 w w  w  .j  a  va  2  s. c o 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);
}

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.
 * //  ww w . j a va  2s . 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:com.strato.hidrive.api.utils.multipart.StringPart.java

/**
 * @param name/*ww w .  jav a2 s . com*/
 *            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:cn.hi321.browser.weave.client.WeaveUtil.java

@SuppressWarnings("unused")
private static HttpEntity toHttpEntity(JSONArray jsonArray) throws JSONException {
    try {// w w w  . j  a  v a 2 s.c  o m
        StringEntity entity = new StringEntity(jsonArray.toString(0), ENTITY_CHARSET_NAME);
        entity.setContentType(JSON_STREAM_TYPE + HTTP.CHARSET_PARAM + ENTITY_CHARSET_NAME);
        return entity;
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException(e);
    }
}