Top Description Fields Constructors Methods
org.apache.http.impl.entity

public Class StrictContentLengthStrategy

extends Object
implements ContentLengthStrategy
Class Inheritance
All Implemented Interfaces
org.apache.http.entity.ContentLengthStrategy
Annotations
@Contract
threading:IMMUTABLE
Imports
org.apache.http.Header, .HttpException, .HttpMessage, .HttpVersion, .ProtocolException, org.apache.http.annotation.ThreadingBehavior, .Contract, org.apache.http.entity.ContentLengthStrategy, org.apache.http.protocol.HTTP, org.apache.http.util.Args

The strict implementation of the content length strategy. This class will throw ProtocolException if it encounters an unsupported transfer encoding or a malformed Content-Length header value.

This class recognizes "chunked" and "identitiy" transfer-coding only.

Since
4.0

Field Summary

Modifier and TypeField and Description
private final int
public static final StrictContentLengthStrategy

Constructor Summary

AccessConstructor and Description
public
StrictContentLengthStrategy(final int
implicit content length.
implicitLen
)

Creates StrictContentLengthStrategy instance with the given length used per default when content length is not explicitly specified in the message.

public
StrictContentLengthStrategy()

Creates StrictContentLengthStrategy instance.

Method Summary

Modifier and TypeMethod and Description
public long
determineLength(final HttpMessage
HTTP message
message
)

Implements org.apache.http.entity.ContentLengthStrategy.determineLength.

Returns length of the given message in bytes.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

implicitLenback to summary
private final int implicitLen
INSTANCEback to summary
public static final StrictContentLengthStrategy INSTANCE

Constructor Detail

StrictContentLengthStrategyback to summary
public StrictContentLengthStrategy(final int implicitLen)

Creates StrictContentLengthStrategy instance with the given length used per default when content length is not explicitly specified in the message.

Parameters
implicitLen:int

implicit content length.

Since
4.2
StrictContentLengthStrategyback to summary
public StrictContentLengthStrategy()

Creates StrictContentLengthStrategy instance. ContentLengthStrategy#IDENTITY is used per default when content length is not explicitly specified in the message.

Method Detail

determineLengthback to summary
public long determineLength(final HttpMessage message) throws HttpException

Implements org.apache.http.entity.ContentLengthStrategy.determineLength.

Doc from org.apache.http.entity.ContentLengthStrategy.determineLength.

Returns length of the given message in bytes. The returned value must be a non-negative number, IDENTITY if the end of the message will be delimited by the end of connection, or CHUNKED if the message is chunk coded

Parameters
message:HttpMessage

HTTP message

Returns:long

content length, IDENTITY, or CHUNKED

Annotations
@Override
Exceptions
HttpException:
in case of HTTP protocol violation