Code example for HttpMessage

Methods: getFirstHeader, getProtocolVersion

0
            throw new IllegalArgumentException("HTTP message may not be null");
        } 
        // 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.TRANSFER_ENCODING);
        Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
        if (transferEncodingHeader != null) {
            String s = transferEncodingHeader.getValue();
            if (HTTP.CHUNK_CODING.equalsIgnoreCase(s)) {
                if (message.getProtocolVersion().lessEquals(HttpVersion.HTTP_1_0)) {
                    throw new ProtocolException(
                            "Chunked transfer encoding not allowed for " + 
                            message.getProtocolVersion());
                } 
                return CHUNKED;
            } else if (HTTP.IDENTITY_CODING.equalsIgnoreCase(s)) {
                return IDENTITY;
            } else { 
                throw new ProtocolException(
                        "Unsupported transfer encoding: " + s);