Top Description Fields Constructors Methods
org.apache.hc.core5.http.impl

public Class DefaultContentLengthStrategy

extends Object
implements ContentLengthStrategy
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.ContentLengthStrategy
Annotations
@Contract
threading:IMMUTABLE
Imports
org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.ContentLengthStrategy, .Header, .HeaderElements, .HttpException, .HttpHeaders, .HttpMessage, .NotImplementedException, .ProtocolException, org.apache.hc.core5.util.Args

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

This class recognizes "chunked" transfer-coding only.

Since
5.0

Field Summary

Modifier and TypeField and Description
public static final DefaultContentLengthStrategy

Constructor Summary

AccessConstructor and Description
public
DefaultContentLengthStrategy()

Creates DefaultContentLengthStrategy instance.

Method Summary

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

Implements org.apache.hc.core5.http.ContentLengthStrategy.determineLength.

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

Field Detail

INSTANCEback to summary
public static final DefaultContentLengthStrategy INSTANCE

Constructor Detail

DefaultContentLengthStrategyback to summary
public DefaultContentLengthStrategy()

Creates DefaultContentLengthStrategy instance. ContentLengthStrategy#UNDEFINED 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.hc.core5.http.ContentLengthStrategy.determineLength.

Doc from org.apache.hc.core5.http.ContentLengthStrategy.determineLength.

Returns length of the given message in bytes. The returned value must be a non-negative number, CHUNKED if the message is chunk coded, or UNDEFINED if the message is not explicitly delineated.

Parameters
message:HttpMessage

HTTP message

Returns:long

content length, UNDEFINED, or CHUNKED

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