Package org.apache.camel.component.http

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


        };
    }

    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


                from("jetty:http://localhost:9080/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

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

                                ServletInputStream sis = HttpConverter.toServletInputStream(msg);
                                assertNotNull(sis);
                                String s = exchange.getContext().getTypeConverter().convertTo(String.class, sis);
View Full Code Here

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

                                InputStream sis = HttpConverter.toInputStream(msg);
                                assertNotNull(sis);
                                String s = exchange.getContext().getTypeConverter().convertTo(String.class, sis);
View Full Code Here

        assertEquals("Bye World", out);
    }

    @Test
    public void testNulls() throws Exception {
        HttpMessage msg = null;
        assertNull(HttpConverter.toInputStream(msg));
        assertNull(HttpConverter.toServletInputStream(msg));
        assertNull(HttpConverter.toServletRequest(msg));
        assertNull(HttpConverter.toServletResponse(msg));
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

   
    @SuppressWarnings("unchecked")
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object result = method.invoke(httpBinding, args); // updates args
        if (method.getName().equals("readRequest") && (args.length == 2)) {
            HttpMessage message = (HttpMessage)args[1];
            // prepare exchange for further inbound binding operations
            message.getExchange().setIn(message);
            // delegate further request binding operations to inbound binding
            inboundBinding.readRequest(endpoint, message.getExchange(), (S)args[0]);
        } else if (method.getName().equals("writeResponse") && (args.length == 2)) {
            // delegate further response binding operations to inbound binding
            inboundBinding.writeResponse(endpoint, (Exchange)args[0], (T)args[1]);
        }
        return result;
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

                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 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

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.