## org.apache.http.impl.entity
Class LaxContentLengthStrategy

    java.lang.Object
      org.apache.http.impl.entity.LaxContentLengthStrategy

All Implemented Interfaces:
  ContentLengthStrategy

    @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 if the `CoreProtocolPNames.STRICT_TRANSFER_ENCODING` parameter of the given message is not set or set to `false`.

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

The following parameters can be used to customize the behavior of this class:

- `CoreProtocolPNames.STRICT_TRANSFER_ENCODING`

Since:
  4.0

Field Summary

Fields inherited from interface org.apache.http.entity.ContentLengthStrategy
`CHUNKED, IDENTITY`

Constructor Summary
`LaxContentLengthStrategy()` Creates `LaxContentLengthStrategy` instance.
`LaxContentLengthStrategy(int implicitLen)` Creates `LaxContentLengthStrategy` instance with the given length used per default when content length is not explicitly specified in the message.

Method Summary
`long` `determineLength(HttpMessage message)` Returns length of the given message in bytes.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LaxContentLengthStrategy

    public LaxContentLengthStrategy(int implicitLen)

  Creates `LaxContentLengthStrategy` 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()

  Creates `LaxContentLengthStrategy` instance. `ContentLengthStrategy.IDENTITY` is 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: `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, or `ContentLengthStrategy.CHUNKED` if the message is chunk coded

  Specified by:
    `determineLength` in interface `ContentLengthStrategy`
  Returns:
    content length, `ContentLengthStrategy.IDENTITY`, or `ContentLengthStrategy.CHUNKED`
  Throws:
    `HttpException` - in case of HTTP protocol violation

Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.