Package org.eclipse.jetty.http2.parser

Examples of org.eclipse.jetty.http2.parser.Parser$Listener


    public void testGenerateParse() throws Exception
    {
        PushPromiseGenerator generator = new PushPromiseGenerator(new HeaderGenerator(), new HpackEncoder());

        final List<PushPromiseFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onPushPromise(PushPromiseFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        int streamId = 13;
        int promisedStreamId = 17;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        // Iterate a few times to be sure generator and parser are properly reset.
        for (int i = 0; i < 2; ++i)
        {
            ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
            generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);

            frames.clear();
            for (ByteBuffer buffer : lease.getByteBuffers())
            {
                while (buffer.hasRemaining())
                {
                    parser.parse(buffer);
                }
            }

            Assert.assertEquals(1, frames.size());
            PushPromiseFrame frame = frames.get(0);
View Full Code Here


    public void testGenerateParseOneByteAtATime() throws Exception
    {
        PushPromiseGenerator generator = new PushPromiseGenerator(new HeaderGenerator(), new HpackEncoder());

        final List<PushPromiseFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onPushPromise(PushPromiseFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        int streamId = 13;
        int promisedStreamId = 17;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
        generator.generatePushPromise(lease, streamId, promisedStreamId, metaData);

        for (ByteBuffer buffer : lease.getByteBuffers())
        {
            while (buffer.hasRemaining())
            {
                parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
            }
        }

        Assert.assertEquals(1, frames.size());
        PushPromiseFrame frame = frames.get(0);
View Full Code Here

        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        final List<HeadersFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onHeaders(HeadersFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        // Iterate a few times to be sure generator and parser are properly reset.
        for (int i = 0; i < 2; ++i)
        {
            ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
            generator.generateHeaders(lease, streamId, metaData, false);

            frames.clear();
            for (ByteBuffer buffer : lease.getByteBuffers())
            {
                while (buffer.hasRemaining())
                {
                    parser.parse(buffer);
                }
            }

            Assert.assertEquals(1, frames.size());
            HeadersFrame frame = frames.get(0);
View Full Code Here

    public void testGenerateParseOneByteAtATime() throws Exception
    {
        HeadersGenerator generator = new HeadersGenerator(new HeaderGenerator(), new HpackEncoder());

        final List<HeadersFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onHeaders(HeadersFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        int streamId = 13;
        HttpFields fields = new HttpFields();
        fields.put("Accept", "text/html");
        fields.put("User-Agent", "Jetty");
        MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields);

        ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
        generator.generateHeaders(lease, streamId, metaData, false);

        for (ByteBuffer buffer : lease.getByteBuffers())
        {
            while (buffer.hasRemaining())
            {
                parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
            }
        }

        Assert.assertEquals(1, frames.size());
        HeadersFrame frame = frames.get(0);
View Full Code Here

        @SuppressWarnings("unchecked")
        Promise<Session> promise = (Promise<Session>)context.get(SESSION_PROMISE_CONTEXT_KEY);

        Generator generator = new Generator(byteBufferPool, 4096);
        HTTP2ClientSession session = new HTTP2ClientSession(scheduler, endPoint, generator, listener, new HTTP2FlowControl(FlowControl.DEFAULT_WINDOW_SIZE));
        Parser parser = new Parser(byteBufferPool, session, 4096, 8192);
        return new HTTP2ClientConnection(client, byteBufferPool, executor, endPoint, parser, session, 8192, false, promise, listener);
    }
View Full Code Here

    public void testGenerateParse() throws Exception
    {
        GoAwayGenerator generator = new GoAwayGenerator(new HeaderGenerator());

        final List<GoAwayFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onGoAway(GoAwayFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        int lastStreamId = 13;
        int error = 17;

        // Iterate a few times to be sure generator and parser are properly reset.
        for (int i = 0; i < 2; ++i)
        {
            ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
            generator.generateGoAway(lease, lastStreamId, error, null);

            frames.clear();
            for (ByteBuffer buffer : lease.getByteBuffers())
            {
                while (buffer.hasRemaining())
                {
                    parser.parse(buffer);
                }
            }
        }

        Assert.assertEquals(1, frames.size());
View Full Code Here

    public void testGenerateParseOneByteAtATime() throws Exception
    {
        GoAwayGenerator generator = new GoAwayGenerator(new HeaderGenerator());

        final List<GoAwayFrame> frames = new ArrayList<>();
        Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter()
        {
            @Override
            public boolean onGoAway(GoAwayFrame frame)
            {
                frames.add(frame);
                return false;
            }
        }, 4096, 8192);

        int lastStreamId = 13;
        int error = 17;
        byte[] payload = new byte[16];
        new Random().nextBytes(payload);

        ByteBufferPool.Lease lease = new ByteBufferPool.Lease(byteBufferPool);
        generator.generateGoAway(lease, lastStreamId, error, payload);

        for (ByteBuffer buffer : lease.getByteBuffers())
        {
            while (buffer.hasRemaining())
            {
                parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
            }
        }

        Assert.assertEquals(1, frames.size());
        GoAwayFrame frame = frames.get(0);
View Full Code Here

        long idleTimeout = endPoint.getIdleTimeout();
        if (idleTimeout > 0)
            idleTimeout /= 2;
        session.setStreamIdleTimeout(idleTimeout);

        Parser parser = newServerParser(connector.getByteBufferPool(), session);
        HTTP2Connection connection = new HTTP2ServerConnection(connector.getByteBufferPool(), connector.getExecutor(),
                        endPoint, parser, session, getInputBufferSize(), isDispatchIO(), listener);

        return configure(connection, connector, endPoint);
    }
View Full Code Here

        final XMLBeansModel model = new XMLBeansModel(Factory.parse(is).getJbossesb());
       
        final List<Listener> awareListeners = model.getESBAwareListeners() ;
        assertEquals("Listener count", 1, awareListeners.size()) ;
       
        final Listener listener = awareListeners.get(0) ;
        assertTrue("JmsListener", listener instanceof JmsListener) ;
       
        final Document doc = YADOMUtil.createDocument() ;
        final Element root = doc.createElement("root") ;
        final Element listenerElement = JmsListenerMapper.map(root, (JmsListener)listener, model) ;
View Full Code Here

    JmsMessageFilter listenerDestination = awareListener.getJmsMessageFilter();
    assertEquals("queue/B", listenerDestination.getDestName());
    assertEquals(JmsMessageFilter.DestType.TOPIC, listenerDestination.getDestType());
    assertEquals("service='Reconciliation'", listenerDestination.getSelector());

    Listener untypedAwareListener = awareListeners.get(1);
    assertEquals("Bank-Listener-Generic", untypedAwareListener.getName());
    assertEquals("my-generic-bus", untypedAwareListener.getBusidref());
    assertTrue(!untypedAwareListener.getIsGateway());

    Service gatewayService = model.getService(gatewayListener);
    Service awareService = model.getService(awareListener);
    assertSame(gatewayService, awareService);
    assertEquals("Bank", awareService.getCategory());
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.http2.parser.Parser$Listener

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.