Package org.apache.http.impl.entity
Class StrictContentLengthStrategy
- java.lang.Object
-
- org.apache.http.impl.entity.StrictContentLengthStrategy
-
- All Implemented Interfaces:
ContentLengthStrategy
@Contract(threading=IMMUTABLE) public class StrictContentLengthStrategy extends java.lang.Object implements ContentLengthStrategy
The strict implementation of the content length strategy. This class will throwProtocolExceptionif it encounters an unsupported transfer encoding or a malformedContent-Lengthheader value.This class recognizes "chunked" and "identitiy" transfer-coding only.
- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description static StrictContentLengthStrategyINSTANCE-
Fields inherited from interface org.apache.http.entity.ContentLengthStrategy
CHUNKED, IDENTITY
-
-
Constructor Summary
Constructors Constructor Description StrictContentLengthStrategy()CreatesStrictContentLengthStrategyinstance.StrictContentLengthStrategy(int implicitLen)CreatesStrictContentLengthStrategyinstance with the given length used per default when content length is not explicitly specified in the message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longdetermineLength(HttpMessage message)Returns length of the given message in bytes.
-
-
-
Field Detail
-
INSTANCE
public static final StrictContentLengthStrategy INSTANCE
-
-
Constructor Detail
-
StrictContentLengthStrategy
public StrictContentLengthStrategy(int implicitLen)
CreatesStrictContentLengthStrategyinstance with the given length used per default when content length is not explicitly specified in the message.- Parameters:
implicitLen- implicit content length.- Since:
- 4.2
-
StrictContentLengthStrategy
public StrictContentLengthStrategy()
CreatesStrictContentLengthStrategyinstance.ContentLengthStrategy.IDENTITYis used per default when content length is not explicitly specified in the message.
-
-
Method Detail
-
determineLength
public long determineLength(HttpMessage message) throws HttpException
Description copied from interface:ContentLengthStrategyReturns length of the given message in bytes. The returned value must be a non-negative number,ContentLengthStrategy.IDENTITYif the end of the message will be delimited by the end of connection, orContentLengthStrategy.CHUNKEDif the message is chunk coded- Specified by:
determineLengthin interfaceContentLengthStrategy- Parameters:
message- HTTP message- Returns:
- content length,
ContentLengthStrategy.IDENTITY, orContentLengthStrategy.CHUNKED - Throws:
HttpException- in case of HTTP protocol violation
-
-