Code example for HttpMessage

Methods: addHeader

0
        byte[] content = new byte[] {1, 2, 3, 4, 5}; 
        ByteArrayEntity entity = new ByteArrayEntity(content); 
 
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup(); 
        HttpMessage message = new HttpMessageMockup(); 
        message.addHeader("Content-Length", Integer.toString(content.length)); 
 
        EntitySerializer entitywriter = new EntitySerializer( 
                new StrictContentLengthStrategy()); 
        entitywriter.serialize(datatransmitter, message, entity); 
 
        byte[] data = datatransmitter.getData(); 
        assertNotNull(data); 
        assertEquals(content.length, data.length); 
    } 
} 
 
Experience pair programming with AI  Get Codota for Java