Package org.eclipse.jetty.spdy.generator

Examples of org.eclipse.jetty.spdy.generator.Generator


    public void testInvalidHeaderNameLength() throws Exception
    {
        Fields headers = new Fields();
        headers.add("broken", "header");
        SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new NoCompressionCompressionFactory.NoCompressionCompressor());

        ByteBuffer bufferWithBrokenHeaderNameLength = generator.control(frame);
        // Break the header name length to provoke the Parser to throw a StreamException
        bufferWithBrokenHeaderNameLength.put(21, (byte)0);

        ByteBuffer bufferWithValidSynStreamFrame = generator.control(frame);

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(BufferUtil.toArray(bufferWithBrokenHeaderNameLength));
        outputStream.write(BufferUtil.toArray(bufferWithValidSynStreamFrame));
View Full Code Here


        ByteBuffer readBuffer = ByteBuffer.allocate(1024);
        channel.read(readBuffer);
        readBuffer.flip();
        int streamId = readBuffer.getInt(8);

        Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor());
        byte[] bytes = new byte[1];
        ByteBuffer writeBuffer = generator.data(streamId, bytes.length, new BytesDataInfo(bytes, true));
        channel.write(writeBuffer);
        assertThat("data is fully written", writeBuffer.hasRemaining(),is(false));

        readBuffer.clear();
        channel.read(readBuffer);
View Full Code Here

    {
        Fields headers = new Fields();
        headers.add("good", "header");
        headers.add("another","header");
        SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new NoCompressionCompressionFactory.NoCompressionCompressor());

        ByteBuffer bufferWithBrokenVersion = generator.control(frame);
        // Break the header name length to provoke the Parser to throw a StreamException
        bufferWithBrokenVersion.put(1, (byte)4);

        ByteBuffer bufferWithValidSynStreamFrame = generator.control(frame);

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(BufferUtil.toArray(bufferWithBrokenVersion));
        outputStream.write(BufferUtil.toArray(bufferWithValidSynStreamFrame));
View Full Code Here

        ByteBuffer readBuffer = ByteBuffer.allocate(1024);
        channel.read(readBuffer);
        readBuffer.flip();
        int streamId = readBuffer.getInt(8);

        Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor());

        ByteBuffer writeBuffer = generator.control(new SynReplyFrame(SPDY.V2, (byte)0, streamId, new Fields()));
        channel.write(writeBuffer);
        assertThat("SynReply is fully written", writeBuffer.hasRemaining(), is(false));

        byte[] bytes = new byte[1];
        writeBuffer = generator.data(streamId, bytes.length, new BytesDataInfo(bytes, true));
        channel.write(writeBuffer);
        assertThat("data is fully written", writeBuffer.hasRemaining(), is(false));

        // Write again to simulate the faulty condition
        writeBuffer.flip();
View Full Code Here

    {
        Fields headers = new Fields();
        headers.add("good", "header");
        headers.add("another","header");
        SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new NoCompressionCompressionFactory.NoCompressionCompressor());

        ByteBuffer bufferWithBrokenVersion = generator.control(frame);
        // Break the header name length to provoke the Parser to throw a StreamException
        bufferWithBrokenVersion.put(1, (byte)4);

        ByteBuffer bufferWithValidSynStreamFrame = generator.control(frame);

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(BufferUtil.toArray(bufferWithBrokenVersion));
        outputStream.write(BufferUtil.toArray(bufferWithValidSynStreamFrame));
View Full Code Here

    {
        Fields headers = new Fields();
        headers.add("good", "header");
        headers.add("another","header");
        SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new NoCompressionCompressionFactory.NoCompressionCompressor());

        ByteBuffer bufferWithBrokenVersion = generator.control(frame);
        // Break the header name length to provoke the Parser to throw a StreamException
        bufferWithBrokenVersion.put(1, (byte)4);

        ByteBuffer bufferWithValidSynStreamFrame = generator.control(frame);

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        outputStream.write(BufferUtil.toArray(bufferWithBrokenVersion));
        outputStream.write(BufferUtil.toArray(bufferWithValidSynStreamFrame));
View Full Code Here

                // Suppress exception logging for this test
            }
        });

        SynStreamFrame frame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, new Fields());
        Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory.StandardCompressor());
        ByteBuffer buffer = generator.control(frame);
        // Replace the version byte with an unsupported version
        buffer.putShort(0, (short)0x8001);

        SocketChannel channel = SocketChannel.open(address);
        channel.write(buffer);
View Full Code Here

    }

    private ByteBuffer createHeadersFrameBuffer(Fields headers)
    {
        HeadersFrame frame1 = new HeadersFrame(SPDY.V2, flags, streamId, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor());
        ByteBuffer buffer = generator.control(frame1);
        assertThat("Buffer is not null", buffer, notNullValue());
        return buffer;
    }
View Full Code Here

        short slot = 5;
        Fields headers = new Fields();
        headers.put("a", "b");
        headers.put("c", "d");
        SynStreamFrame frame1 = new SynStreamFrame(SPDY.V2, flags, streamId, associatedStreamId, priority, slot, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor());
        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
View Full Code Here

        short slot = 5;
        Fields headers = new Fields();
        headers.put("a", "b");
        headers.put("c", "d");
        SynStreamFrame frame1 = new SynStreamFrame(SPDY.V2, flags, streamId, associatedStreamId, priority, slot, headers);
        Generator generator = new Generator(new MappedByteBufferPool(), new StandardCompressionFactory().newCompressor());
        ByteBuffer buffer = generator.control(frame1);

        Assert.assertNotNull(buffer);

        TestSPDYParserListener listener = new TestSPDYParserListener();
        Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.spdy.generator.Generator

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.