Code example for HttpMessage

Methods: addHeader, getParams

0
    public void testEntityWithIdentityTransferEncoding() throws Exception { 
        ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();
 
        // lenient mode 
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Transfer-Encoding", "identity");
        message.addHeader("Content-Length", "plain wrong");
        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
    } 
 
    public void testEntityWithUnsupportedTransferEncoding() throws Exception { 
        ContentLengthStrategy lenStrategy = new LaxContentLengthStrategy();
        HttpMessage message = new HttpMessageMockup();
 
        // lenient mode 
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Transfer-Encoding", "whatever; param=value, chunked");
        message.addHeader("Content-Length", "plain wrong");