public final class EntityUtilsHC4
extends java.lang.Object
HttpEntitys.| Modifier and Type | Method and Description |
|---|---|
static void |
consume(org.apache.http.HttpEntity entity)
Ensures that the entity content is fully consumed and the content stream, if exists,
is closed.
|
static void |
consumeQuietly(org.apache.http.HttpEntity entity)
Ensures that the entity content is fully consumed and the content stream, if exists,
is closed.
|
static java.lang.String |
getContentCharSet(org.apache.http.HttpEntity entity)
Deprecated.
(4.1.3) use
ContentType.getOrDefault(HttpEntity) |
static java.lang.String |
getContentMimeType(org.apache.http.HttpEntity entity)
Deprecated.
(4.1.3) use
ContentType.getOrDefault(HttpEntity) |
static byte[] |
toByteArray(org.apache.http.HttpEntity entity)
Read the contents of an entity and return it as a byte array.
|
static java.lang.String |
toString(org.apache.http.HttpEntity entity)
Read the contents of an entity and return it as a String.
|
static java.lang.String |
toString(org.apache.http.HttpEntity entity,
java.nio.charset.Charset defaultCharset)
Get the entity content as a String, using the provided default character set
if none is found in the entity.
|
static java.lang.String |
toString(org.apache.http.HttpEntity entity,
java.lang.String defaultCharset)
Get the entity content as a String, using the provided default character set
if none is found in the entity.
|
static void |
updateEntity(org.apache.http.HttpResponse response,
org.apache.http.HttpEntity entity)
Updates an entity in a response by first consuming an existing entity, then setting the new one.
|
public static void consumeQuietly(org.apache.http.HttpEntity entity)
entity - the entity to consume.public static void consume(org.apache.http.HttpEntity entity)
throws java.io.IOException
entity - the entity to consume.java.io.IOException - if an error occurs reading the input streampublic static void updateEntity(org.apache.http.HttpResponse response,
org.apache.http.HttpEntity entity)
throws java.io.IOException
response - the response with an entity to update; must not be null.entity - the entity to set in the response.java.io.IOException - if an error occurs while reading the input stream on the existing
entity.java.lang.IllegalArgumentException - if response is null.public static byte[] toByteArray(org.apache.http.HttpEntity entity)
throws java.io.IOException
entity - the entity to read from=HttpEntity.getContent() is null.java.io.IOException - if an error occurs reading the input streamjava.lang.IllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUE@Deprecated
public static java.lang.String getContentCharSet(org.apache.http.HttpEntity entity)
throws org.apache.http.ParseException
ContentType.getOrDefault(HttpEntity)entity - must not be nullorg.apache.http.ParseException - if header elements cannot be parsedjava.lang.IllegalArgumentException - if entity is null@Deprecated
public static java.lang.String getContentMimeType(org.apache.http.HttpEntity entity)
throws org.apache.http.ParseException
ContentType.getOrDefault(HttpEntity)entity - must not be nullorg.apache.http.ParseException - if header elements cannot be parsedjava.lang.IllegalArgumentException - if entity is nullpublic static java.lang.String toString(org.apache.http.HttpEntity entity,
java.nio.charset.Charset defaultCharset)
throws java.io.IOException,
org.apache.http.ParseException
entity - must not be nulldefaultCharset - character set to be applied if none found in the entityHttpEntity.getContent() is null.org.apache.http.ParseException - if header elements cannot be parsedjava.lang.IllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUEjava.io.IOException - if an error occurs reading the input streamjava.nio.charset.UnsupportedCharsetException - Thrown when the named charset is not available in
this instance of the Java virtual machinepublic static java.lang.String toString(org.apache.http.HttpEntity entity,
java.lang.String defaultCharset)
throws java.io.IOException,
org.apache.http.ParseException
entity - must not be nulldefaultCharset - character set to be applied if none found in the entityHttpEntity.getContent() is null.org.apache.http.ParseException - if header elements cannot be parsedjava.lang.IllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUEjava.io.IOException - if an error occurs reading the input streamjava.nio.charset.UnsupportedCharsetException - Thrown when the named charset is not available in
this instance of the Java virtual machinepublic static java.lang.String toString(org.apache.http.HttpEntity entity)
throws java.io.IOException,
org.apache.http.ParseException
entity - the entity to convert to a string; must not be nullorg.apache.http.ParseException - if header elements cannot be parsedjava.lang.IllegalArgumentException - if entity is null or if content length > Integer.MAX_VALUEjava.io.IOException - if an error occurs reading the input streamjava.nio.charset.UnsupportedCharsetException - Thrown when the named charset is not available in
this instance of the Java virtual machineCopyright © 1999-2015 The Apache Software Foundation. All rights reserved.