Package org.apache.hc.core5.http.impl
Class DefaultContentLengthStrategy
- java.lang.Object
-
- org.apache.hc.core5.http.impl.DefaultContentLengthStrategy
-
- All Implemented Interfaces:
ContentLengthStrategy
@Contract(threading=IMMUTABLE) public class DefaultContentLengthStrategy extends java.lang.Object implements ContentLengthStrategy
The default implementation of the content length strategy. This class will throwProtocolExceptionif it encounters an unsupported transfer encoding, multipleContent-Lengthheader values or a malformedContent-Lengthheader value.This class recognizes "chunked" transfer-coding only.
- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultContentLengthStrategyINSTANCE-
Fields inherited from interface org.apache.hc.core5.http.ContentLengthStrategy
CHUNKED, UNDEFINED
-
-
Constructor Summary
Constructors Constructor Description DefaultContentLengthStrategy()CreatesDefaultContentLengthStrategyinstance.
-
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 DefaultContentLengthStrategy INSTANCE
-
-
Constructor Detail
-
DefaultContentLengthStrategy
public DefaultContentLengthStrategy()
CreatesDefaultContentLengthStrategyinstance.ContentLengthStrategy.UNDEFINEDis 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.CHUNKEDif the message is chunk coded, orContentLengthStrategy.UNDEFINEDif the message is not explicitly delineated.- Specified by:
determineLengthin interfaceContentLengthStrategy- Parameters:
message- HTTP message- Returns:
- content length,
ContentLengthStrategy.UNDEFINED, orContentLengthStrategy.CHUNKED - Throws:
HttpException- in case of HTTP protocol violation
-
-