Code example for HttpMessage

Methods: addHeadergetParams

0
    public void testChunkedTransferEncodingMustBeLast() 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", "chunked, identity");
        message.addHeader("Content-Length", "plain wrong");
        assertEquals(ContentLengthStrategy.IDENTITY, lenStrategy.determineLength(message));
 
        // strict mode 
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
        try { 
            lenStrategy.determineLength(message);
            fail("ProtocolException should have been thrown");
        } catch (ProtocolException ex) {
            // expected 
        } 
    } 
Stop searching for code, let great code find you!  Add Codota to your java IDE