Code example for HttpMessage

Methods: getFirstHeadergetProtocolVersion

            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 " + 
                return CHUNKED;
            } else if (HTTP.IDENTITY_CODING.equalsIgnoreCase(s)) {
                return IDENTITY;
            } else { 
                throw new ProtocolException(
Experience pair programming with AI  Get Codota for Java