Examples of HttpExchange


Examples of com.facebook.presto.jdbc.internal.jetty.client.HttpExchange

    }

    @Override
    public void send()
    {
        HttpExchange exchange = getHttpExchange();
        if (exchange != null)
            sender.send(exchange);
    }
View Full Code Here

Examples of com.sun.net.httpserver.HttpExchange

        handler = new JolokiaHttpHandler(getConfig());
    }

    @Test
    public void testCallbackGet() throws IOException, URISyntaxException {
        HttpExchange exchange = prepareExchange("http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage?callback=data");

        // Simple GET method
        expect(exchange.getRequestMethod()).andReturn("GET");


        Headers header = new Headers();
        ByteArrayOutputStream out = prepareResponse(handler, exchange, header);
View Full Code Here

Examples of javax.xml.ws.spi.http.HttpExchange

    }
   
    @Test
    public void testMessage() throws Exception {
        expect(bus.getExtension(QueryHandlerRegistry.class)).andReturn(null);
        HttpExchange exchange = setUpExchange();
        control.replay();

        JAXWSHttpSpiDestination destination =
            new JAXWSHttpSpiDestination(bus, endpoint);
        destination.setMessageObserver(observer);
View Full Code Here

Examples of org.apache.camel.component.http.HttpExchange

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.

                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

Examples of org.apache.camel.component.http.HttpExchange

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
               
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.
               
                // set the header value from endpoint
                if (exchange.getOut().getHeader(Exchange.HTTP_CHUNKED) == null) {
                    exchange.getOut().setHeader(Exchange.HTTP_CHUNKED, consumer.getEndpoint().isChunked());
                }
               
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

Examples of org.apache.camel.component.http.HttpExchange

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.

                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

Examples of org.apache.camel.component.http.HttpExchange

        };
    }

    private class MyParamsProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            HttpExchange http = (HttpExchange) exchange;
            Assert.assertNotNull(http.getRequest());
            Assert.assertEquals("uno", http.getRequest().getParameter("one"));
            Assert.assertEquals("dos", http.getRequest().getParameter("two"));

            exchange.getOut(true).setBody("Bye World");
            exchange.getOut(true).setHeader("one", "einz");
            exchange.getOut(true).setHeader("two", "twei");
        }
View Full Code Here

Examples of org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler.HttpExchange

    }

    @Test
    public void testRequestContentIOException() throws Exception {
        IOException ioex = new IOException();
        HttpExchange httpExchange = this.protocolHandler.new HttpExchange();
        httpExchange.setHandler(this.exchangeHandler);
        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE, httpExchange);
        Mockito.doThrow(ioex).when(this.exchangeHandler).produceContent(this.encoder, this.conn);

        this.protocolHandler.outputReady(this.conn, this.encoder);
View Full Code Here

Examples of org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler.HttpExchange

        Mockito.verify(this.exchangeHandler).failed(ioex);
    }

    @Test
    public void testBasicResponse() throws Exception {
        HttpExchange httpExchange = this.protocolHandler.new HttpExchange();
        HttpRequest request = new BasicHttpRequest("GET", "/");
        httpExchange.setRequest(request);
        httpExchange.setHandler(this.exchangeHandler);
        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE, httpExchange);
        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);

        this.protocolHandler.responseReceived(this.conn);

        Assert.assertSame(response, httpExchange.getResponse());
        Assert.assertEquals(MessageState.BODY_STREAM, httpExchange.getResponseState());
    }
View Full Code Here

Examples of org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler.HttpExchange

        Assert.assertEquals(MessageState.BODY_STREAM, httpExchange.getResponseState());
    }

    @Test
    public void testResponseContinue() throws Exception {
        HttpExchange httpExchange = this.protocolHandler.new HttpExchange();
        httpExchange.setRequestState(MessageState.ACK_EXPECTED);
        httpExchange.setTimeout(1000);
        BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
        request.setEntity(NStringEntity.create("stuff"));
        httpExchange.setRequest(request);
        httpExchange.setHandler(this.exchangeHandler);
        this.connContext.setAttribute(HttpAsyncClientProtocolHandler.HTTP_EXCHANGE, httpExchange);
        BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 100, "Continue");
        Mockito.when(this.conn.getHttpResponse()).thenReturn(response);

        this.protocolHandler.responseReceived(this.conn);

        Assert.assertNull(httpExchange.getResponse());
        Assert.assertEquals(MessageState.ACK, httpExchange.getRequestState());
        Assert.assertEquals(MessageState.READY, httpExchange.getResponseState());
        Mockito.verify(this.conn).setSocketTimeout(1000);
        Mockito.verify(this.conn).requestOutput();
    }
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.