/// <exception cref="Org.Apache.Http.HttpException"></exception>
        public override long DetermineLength(HttpMessage message)
        {
            Args.NotNull(message, "HTTP message");
            // Although Transfer-Encoding is specified as a list, in practice
            // it is either missing or has the single value "chunked". So we
            // treat it as a single-valued header here.
            Header transferEncodingHeader = message.GetFirstHeader(HTTP.TransferEncoding);

            if (transferEncodingHeader != null)
            {
                string s = transferEncodingHeader.GetValue();
                if (Sharpen.Runtime.EqualsIgnoreCase(HTTP.ChunkCoding, s))
                {
                    if (message.GetProtocolVersion().LessEquals(HttpVersion.Http10))
                    {
                        throw new ProtocolException("Chunked transfer encoding not allowed for " + message
                                                    .GetProtocolVersion());
                    }
                    return(Chunked);
                }
                else
                {
                    if (Sharpen.Runtime.EqualsIgnoreCase(HTTP.IdentityCoding, s))
                    {
                        return(Identity);
                    }
                    else
                    {
                        throw new ProtocolException("Unsupported transfer encoding: " + s);
                    }
                }
            }
            Header contentLengthHeader = message.GetFirstHeader(HTTP.ContentLen);

            if (contentLengthHeader != null)
            {
                string s = contentLengthHeader.GetValue();
                try
                {
                    long len = long.Parse(s);
                    if (len < 0)
                    {
                        throw new ProtocolException("Negative content length: " + s);
                    }
                    return(len);
                }
                catch (FormatException)
                {
                    throw new ProtocolException("Invalid content length: " + s);
                }
            }
            return(this.implicitLen);
        }