Package org.apache.http.impl.nio.reactor

Examples of org.apache.http.impl.nio.reactor.SessionInputBuffer


    public void testBasicDecodingSmallBuffer() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16);
       
        ByteBuffer dst = ByteBuffer.allocate(4);
       
        int bytesRead = decoder.read(dst);
View Full Code Here


   
    public void testDecodingFromSessionBuffer1() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        inbuf.fill(channel);
       
        assertEquals(6, inbuf.length());
       
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16);
       
        ByteBuffer dst = ByteBuffer.allocate(1024);
       
View Full Code Here

        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {
                        "stuff;",
                        "more stuff; and a lot more stuff"}, "US-ASCII");
       
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        inbuf.fill(channel);
        inbuf.fill(channel);
       
        assertEquals(38, inbuf.length());
       
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16);
       
        ByteBuffer dst = ByteBuffer.allocate(1024);
       
View Full Code Here

    public void testInvalidConstructor() {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        try {
            new LengthDelimitedDecoder(null, null, 10);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // ignore
View Full Code Here

    public void testInvalidInput() throws Exception {
        String s = "stuff";
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {s}, "US-ASCII");
   
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 3);
       
        try {
            decoder.read(null);
            fail("IllegalArgumentException should have been thrown");
View Full Code Here

    // ----------------------------------------------------- Test read
    public void testBasicDecodingFile() throws Exception {
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"stuff;", "more stuff"}, "US-ASCII");
       
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16);
       
        File tmpFile = File.createTempFile("testFile", ".txt");
        FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
       
View Full Code Here

        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {
                        "stuff;",
                        "more stuff; and a lot more stuff"}, "US-ASCII");
       
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 256);
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(channel, inbuf, 16);
       
        File tmpFile = File.createTempFile("testFile", ".txt");
        FileChannel fchannel = new FileOutputStream(tmpFile).getChannel();
       
View Full Code Here

        return newChannel(s, "US-ASCII");
    }

    public void testSimpleParsing() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory, params);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.1\r\nSome header: stuff\r\n\r\n"));
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNotNull(request);
View Full Code Here

        assertEquals(1, request.getAllHeaders().length);
    }

    public void testParsingChunkedMessages() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory, params);

        requestParser.fillBuffer(newChannel("GET /whatev"));
        HttpRequest request = (HttpRequest) requestParser.parse();
View Full Code Here

       
    }

    public void testParsingFoldedHeaders() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory, params);

        requestParser.fillBuffer(newChannel("GET /whatev"));
        HttpRequest request = (HttpRequest) requestParser.parse();
View Full Code Here

TOP

Related Classes of org.apache.http.impl.nio.reactor.SessionInputBuffer

Copyright © 2018 www.massapicom. 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.