Package org.apache.camel.component.http

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


                from("jetty:http://localhost:" + port1 + "/test").to("mock:a");

                Processor proc = new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        try {
                            HttpMessage message = (HttpMessage)exchange.getIn();
                            HttpSession session = message.getRequest().getSession();
                            assertNotNull("we should get session here", session);
                        } catch (Exception e) {
                            exchange.getOut().setFault(true);
                            exchange.getOut().setBody(e);
                        }
View Full Code Here


        };
    }

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

            exchange.getOut().setBody("Bye World");
            exchange.getOut().setHeader("one", "eins");
            exchange.getOut().setHeader("two", "zwei");
        }
View Full Code Here

            if (consumer.getEndpoint().isDisableStreamCache()) {
                exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
            }
           
            HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
            exchange.setIn(new HttpMessage(exchange, request, response));

            log.trace("Suspending continuation of exchangeId: {}", exchange.getExchangeId());
            continuation.setAttribute(EXCHANGE_ATTRIBUTE_ID, exchange.getExchangeId());
            // must suspend before we process the exchange
            continuation.suspend();
View Full Code Here

            if (consumer.getEndpoint().isDisableStreamCache()) {
                exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
            }
           
            HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
            exchange.setIn(new HttpMessage(exchange, request, response));

            log.trace("Suspending continuation of exchangeId: {}", exchange.getExchangeId());
            continuation.setAttribute(EXCHANGE_ATTRIBUTE_ID, exchange.getExchangeId());
            // must suspend before we process the exchange
            continuation.suspend();
View Full Code Here

                exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
            }
           
            HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
           
            exchange.setIn(new HttpMessage(exchange, request, response));
            // set context path as header
            String contextPath = consumer.getEndpoint().getPath();
            exchange.getIn().setHeader("CamelServletContextPath", contextPath);
           
            String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH);
View Full Code Here

        };
    }

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

            exchange.getOut().setBody("Bye World");
            exchange.getOut().setHeader("one", "eins");
            exchange.getOut().setHeader("two", "zwei");
        }
View Full Code Here

            String newUrl;
            if (endpoint.getUrlRewrite() instanceof HttpServletUrlRewrite) {
                // its servlet based, so we need the servlet request
                HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
                if (request == null) {
                    HttpMessage msg = exchange.getIn(HttpMessage.class);
                    if (msg != null) {
                        request = msg.getRequest();
                    }
                }
                if (request == null) {
                    throw new IllegalArgumentException("UrlRewrite " + endpoint.getUrlRewrite() + " requires the message body to be a"
                            + "HttpServletRequest instance, but was: " + ObjectHelper.className(exchange.getIn().getBody()));
View Full Code Here

               
                from("jetty:http://localhost:" + port1 + "/test").process(new Processor() {

                    @Override
                    public void process(Exchange exchange) throws Exception {
                        HttpMessage message = (HttpMessage)exchange.getIn();
                        assertNotNull(message.getRequest());
                        assertEquals("GET", message.getRequest().getMethod());
                        exchange.getOut().setBody(message.getRequest().getQueryString());
                       
                    }
                   
                });
               
                from("jetty:http://localhost:" + port2 + "/test").process(new Processor() {

                    @Override
                    public void process(Exchange exchange) throws Exception {
                        HttpMessage message = (HttpMessage)exchange.getIn();
                        assertNotNull(message.getRequest());
                        assertEquals("GET", message.getRequest().getMethod());
                        exchange.getOut().setBody(message.getRequest().getQueryString() + "&2");
                    }
                   
                });
               
                from("direct:start1").to("http4://localhost:" + port1 + "/test");
View Full Code Here

            @Override
            public void configure() throws Exception {
                from("jetty://http://localhost:{{port}}/test").
                        process(new Processor() {
                            public void process(Exchange exchange) throws Exception {
                                HttpMessage msg = exchange.getIn(HttpMessage.class);

                                ServletInputStream sis = HttpConverter.toServletInputStream(msg);
                                assertNotNull(sis);
                                // The ServletInputStream should be cached and you can't read message here
                                assertTrue(sis.available() == 0);                               
                                String s = msg.getBody(String.class);

                                assertEquals("Hello World", s);
                            }
                        }).transform(constant("Bye World"));
            }
View Full Code Here

            @Override
            public void configure() throws Exception {
                from("jetty://http://localhost:{{port}}/test").
                        process(new Processor() {
                            public void process(Exchange exchange) throws Exception {
                                HttpMessage msg = exchange.getIn(HttpMessage.class);

                                InputStream sis = msg.getBody(InputStream.class);
                                assertNotNull(sis);
                                String s = exchange.getContext().getTypeConverter().convertTo(String.class, sis);

                                assertEquals("Hello World", s);
                            }
View Full Code Here

TOP

Related Classes of org.apache.camel.component.http.HttpMessage

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.