Package org.apache.http.impl.entity
Class LaxContentLengthStrategy
java.lang.Object
org.apache.http.impl.entity.LaxContentLengthStrategy
- All Implemented Interfaces:
ContentLengthStrategy
@Contract(threading=IMMUTABLE)
public class LaxContentLengthStrategy
extends Object
implements ContentLengthStrategy
The lax implementation of the content length strategy. This class will ignore
unrecognized transfer encodings and malformed
Content-Length
header values.
This class recognizes "chunked" and "identitiy" transfer-coding only.
- Since:
- 4.0
-
Field Summary
FieldsFields inherited from interface org.apache.http.entity.ContentLengthStrategy
CHUNKED, IDENTITY
-
Constructor Summary
ConstructorsConstructorDescriptionCreatesLaxContentLengthStrategy
instance.LaxContentLengthStrategy
(int implicitLen) CreatesLaxContentLengthStrategy
instance with the given length used per default when content length is not explicitly specified in the message. -
Method Summary
Modifier and TypeMethodDescriptionlong
determineLength
(HttpMessage message) Returns length of the given message in bytes.
-
Field Details
-
INSTANCE
-
implicitLen
private final int implicitLen
-
-
Constructor Details
-
LaxContentLengthStrategy
public LaxContentLengthStrategy(int implicitLen) CreatesLaxContentLengthStrategy
instance 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
-
LaxContentLengthStrategy
public LaxContentLengthStrategy()CreatesLaxContentLengthStrategy
instance.ContentLengthStrategy.IDENTITY
is used per default when content length is not explicitly specified in the message.
-
-
Method Details
-
determineLength
Description copied from interface:ContentLengthStrategy
Returns length of the given message in bytes. The returned value must be a non-negative number,ContentLengthStrategy.IDENTITY
if the end of the message will be delimited by the end of connection, orContentLengthStrategy.CHUNKED
if the message is chunk coded- Specified by:
determineLength
in interfaceContentLengthStrategy
- Parameters:
message
- HTTP message- Returns:
- content length,
ContentLengthStrategy.IDENTITY
, orContentLengthStrategy.CHUNKED
- Throws:
HttpException
- in case of HTTP protocol violation
-