Examples of SessionOutputBuffer


Examples of org.apache.http.nio.reactor.SessionOutputBuffer

   
    public void testChunkNoExceed() throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        WritableByteChannel channel = newChannel(baos);
        HttpParams params = new BasicHttpParams();
        SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
        encoder.write(wrap("1234"));
        encoder.complete();
       
        outbuf.flush(channel);
       
        String s = baos.toString("US-ASCII");
       
        assertTrue(encoder.isCompleted());
        assertEquals("4\r\n1234\r\n0\r\n\r\n", s);   
View Full Code Here

Examples of org.apache.http.nio.reactor.SessionOutputBuffer

   
    public void testChunkExceed() throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        WritableByteChannel channel = newChannel(baos);
        HttpParams params = new BasicHttpParams();
        SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
       
        ByteBuffer src = wrap("0123456789ABCDEF");
       
        assertEquals(6, encoder.write(src));
        assertTrue(src.hasRemaining());
        assertEquals(10, src.remaining());

        assertEquals(6, encoder.write(src));
        assertTrue(src.hasRemaining());
        assertEquals(4, src.remaining());

        assertEquals(4, encoder.write(src));
        assertFalse(src.hasRemaining());
       
        outbuf.flush(channel);
        String s = baos.toString("US-ASCII");
        assertEquals("6\r\n012345\r\n6\r\n6789AB\r\n4\r\nCDEF\r\n", s);   
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.