Java Code Examples for org.apache.http.protocol.HTTP#CONTENT_TYPE

The following examples show how to use org.apache.http.protocol.HTTP#CONTENT_TYPE . 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: MultipartEntity.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an instance using the specified parameters
 *
 * @param mode     the mode to use, may be {@code null}, in which case {@link HttpMultipartMode#STRICT} is used
 * @param boundary the boundary string, may be {@code null}, in which case {@link #generateBoundary()} is invoked to create the string
 * @param charset  the character set to use, may be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. UTF-8 - is used.
 */
public MultipartEntity(
        HttpMultipartMode mode,
        String boundary,
        Charset charset) {
    super();
    if (boundary == null) {
        boundary = generateBoundary();
    }
    this.boundary = boundary;
    if (mode == null) {
        mode = HttpMultipartMode.STRICT;
    }
    this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET;
    this.multipart = new HttpMultipart(multipartSubtype, this.charset, this.boundary, mode);
    this.contentType = new BasicHeader(
            HTTP.CONTENT_TYPE,
            generateContentType(this.boundary, this.charset));
    this.dirty = true;
}
 
Example 2
Source File: MultipartEntity.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an instance using the specified parameters
 *
 * @param mode     the mode to use, may be {@code null}, in which case {@link HttpMultipartMode#STRICT} is used
 * @param boundary the boundary string, may be {@code null}, in which case {@link #generateBoundary()} is invoked to create the string
 * @param charset  the character set to use, may be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. UTF-8 - is used.
 */
public MultipartEntity(
        HttpMultipartMode mode,
        String boundary,
        Charset charset) {
    super();
    if (boundary == null) {
        boundary = generateBoundary();
    }
    this.boundary = boundary;
    if (mode == null) {
        mode = HttpMultipartMode.STRICT;
    }
    this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET;
    this.multipart = new HttpMultipart(multipartSubtype, this.charset, this.boundary, mode);
    this.contentType = new BasicHeader(
            HTTP.CONTENT_TYPE,
            generateContentType(this.boundary, this.charset));
    this.dirty = true;
}
 
Example 3
Source File: MultipartEntity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * @param multipartSubtype default "form-data"
 */
public void setMultipartSubtype(String multipartSubtype) {
    this.multipartSubtype = multipartSubtype;
    this.multipart.setSubType(multipartSubtype);
    this.contentType = new BasicHeader(
            HTTP.CONTENT_TYPE,
            generateContentType(this.boundary, this.charset));
}
 
Example 4
Source File: MultipartEntity.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/**
 * @param multipartSubtype default "form-data"
 */
public void setMultipartSubtype(String multipartSubtype) {
    this.multipartSubtype = multipartSubtype;
    this.multipart.setSubType(multipartSubtype);
    this.contentType = new BasicHeader(
            HTTP.CONTENT_TYPE,
            generateContentType(this.boundary, this.charset));
}
 
Example 5
Source File: MultipartEntity.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
@Override
public Header getContentType() {
  final StringBuffer buffer = new StringBuffer(MULTIPART_FORM_CONTENT_TYPE);
  buffer.append("; boundary=");
  buffer.append(EncodingUtils.getAsciiString(getMultipartBoundary()));
  return new BasicHeader(HTTP.CONTENT_TYPE, buffer.toString());

}
 
Example 6
Source File: SimpleMultipartEntity.java    From RestVolley with Apache License 2.0 4 votes vote down vote up
private byte[] createContentType(String type) {
    String result = HTTP.CONTENT_TYPE + ": " + normalizeContentType(type) + STR_CR_LF;
    return result.getBytes();
}
 
Example 7
Source File: MultipartEntity.java    From iaf with Apache License 2.0 4 votes vote down vote up
MultipartEntity(MultipartForm multipart, final ContentType contentType,final long contentLength) {
	super();
	this.multipart = multipart;
	this.contentType = new BasicHeader(HTTP.CONTENT_TYPE, contentType.toString());
	this.contentLength = contentLength;
}
 
Example 8
Source File: AbstractHttpEntity.java    From android-lite-http with Apache License 2.0 3 votes vote down vote up
/**
 * Specifies the Content-Type header, as a string.
 * The default implementation calls
 * {@link #setContentType(Header) setContentType(Header)}.
 *
 * @param ctString the new Content-Type header, or
 *                 <code>null</code> to unset
 */
public void setContentType(final String ctString) {
    Header h = null;
    if (ctString != null) {
        h = new BasicHeader(HTTP.CONTENT_TYPE, ctString);
    }
    setContentType(h);
}