/*
* $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpEntity.java $
* $Revision: 645824 $
* $Date: 2008-04-08 03:12:41 -0700 (Tue, 08 Apr 2008) $
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* In some places, the JavaDoc distinguishes three kinds of entities, * depending on where their {@link #getContent content} originates: *
true
if chunked encoding is preferred for this
* entity, or false
if it is not
*/
boolean isChunked();
/**
* Tells the length of the content, if known.
*
* @return the number of bytes of the content, or
* a negative number if unknown. If the content length is known
* but exceeds {@link java.lang.Long#MAX_VALUE Long.MAX_VALUE},
* a negative number is returned.
*/
long getContentLength();
/**
* Obtains the Content-Type header, if known.
* This is the header that should be used when sending the entity,
* or the one that was received with the entity. It can include a
* charset attribute.
*
* @return the Content-Type header for this entity, or
* null
if the content type is unknown
*/
Header getContentType();
/**
* Obtains the Content-Encoding header, if known.
* This is the header that should be used when sending the entity,
* or the one that was received with the entity.
* Wrapping entities that modify the content encoding should
* adjust this header accordingly.
*
* @return the Content-Encoding header for this entity, or
* null
if the content encoding is unknown
*/
Header getContentEncoding();
/**
* Creates a new InputStream object of the entity.
* It is a programming error
* to return the same InputStream object more than once.
* Entities that are not {@link #isRepeatable repeatable}
* will throw an exception if this method is called multiple times.
*
* @return a new input stream that returns the entity data.
*
* @throws IOException if the stream could not be created
* @throws IllegalStateException
* if this entity is not repeatable and the stream
* has already been obtained previously
*/
InputStream getContent() throws IOException, IllegalStateException;
/**
* Writes the entity content to the output stream.
*
* @param outstream the output stream to write entity content to
*
* @throws IOException if an I/O error occurs
*/
void writeTo(OutputStream outstream) throws IOException;
/**
* Tells whether this entity depends on an underlying stream.
* Streamed entities should return true
until the
* content has been consumed, false
afterwards.
* Self-contained entities should return false
.
* Wrapping entities should delegate this call to the wrapped entity.
* true
until
* {@link #consumeContent consumeContent} is called.
*
* @return true
if the entity content is streamed and
* not yet consumed, false
otherwise
*/
boolean isStreaming(); // don't expect an exception here
/**
* TODO: The name of this method is misnomer. It will be renamed to
* #finish() in the next major release.
*