Java Code Examples for org.apache.http.protocol.HTTP#CHARSET_PARAM
The following examples show how to use
org.apache.http.protocol.HTTP#CHARSET_PARAM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringPart.java From volley with Apache License 2.0 | 6 votes |
/** * @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. * * @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$ } }; }
Example 2
Source File: StringPart.java From barterli_android with Apache License 2.0 | 6 votes |
/** * @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. * * @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$ } }; }