Package org.mortbay.jetty.client.HttpExchange

Examples of org.mortbay.jetty.client.HttpExchange.ContentExchange


        latch.await();
    }

    public boolean process(final Exchange exchange, final AsyncCallback callback) {

        ContentExchange jettyExchange = new CamelContentExchange(exchange, callback);

        jettyExchange.setURL(address);

        // If a in body can be converted to an InputStream or a Buffer
        // then do a POST otherwise, do a GET
        Message in = exchange.getIn();
        InputStream is = in.getBody(InputStream.class);
        if (is != null) {
            jettyExchange.setMethod(HttpMethods.POST);
            jettyExchange.setRequestContentSource(is);
        } else {
            Buffer buffer = in.getBody(Buffer.class);
            if (buffer != null) {
                jettyExchange.setMethod(HttpMethods.POST);
                jettyExchange.setRequestContent(buffer);
            } else {
                jettyExchange.setMethod(HttpMethods.GET);
            }
        }

        // propagate headers to http request
        HeaderFilterStrategy strategy = ((HttpEndpoint)getEndpoint()).getHeaderFilterStrategy();
        for (String name : in.getHeaders().keySet()) {
            String value = in.getHeader(name, String.class);
            if ("Content-Type".equals(name)) {
                jettyExchange.setRequestContentType(value);
            } else if (strategy != null && !strategy.applyFilterToCamelHeaders(name, value)) {
                jettyExchange.addRequestHeader(name, value);
            }
        }
       
        try {
            httpClient.send(jettyExchange);
View Full Code Here


        latch.await();
    }

    public boolean process(final Exchange exchange, final AsyncCallback callback) {

        ContentExchange jettyExchange = new CamelContentExchange(exchange, callback);

        jettyExchange.setURL(address);

        // If a in body can be converted to an InputStream or a Buffer
        // then do a POST otherwise, do a GET
        Message in = exchange.getIn();
        InputStream is = in.getBody(InputStream.class);
        if (is != null) {
            jettyExchange.setMethod(HttpMethods.POST);
            jettyExchange.setRequestContentSource(is);
        } else {
            Buffer buffer = in.getBody(Buffer.class);
            if (buffer != null) {
                jettyExchange.setMethod(HttpMethods.POST);
                jettyExchange.setRequestContent(buffer);
            } else {
                jettyExchange.setMethod(HttpMethods.GET);
            }
        }

        HttpBinding binding = ((HttpEndpoint)getEndpoint()).getBinding();
        for (String name : in.getHeaders().keySet()) {
            String value = in.getHeader(name, String.class);
            if ("Content-Type".equals(name)) {
                jettyExchange.setRequestContentType(value);
            } else if (binding.shouldHeaderBePropagated(name, value)) {
                jettyExchange.addRequestHeader(name, value);
            }
        }
        try {
            httpClient.send(jettyExchange);
        } catch (IOException e) {
View Full Code Here

        latch.await();
    }

    public boolean process(final Exchange exchange, final AsyncCallback callback) {

        ContentExchange jettyExchange = new CamelContentExchange(exchange, callback);

        jettyExchange.setURL(address);

        // If a in body can be converted to an InputStream or a Buffer
        // then do a POST otherwise, do a GET
        Message in = exchange.getIn();
        InputStream is = in.getBody(InputStream.class);
        if (is != null) {
            jettyExchange.setMethod(HttpMethods.POST);
            jettyExchange.setRequestContentSource(is);
        } else {
            Buffer buffer = in.getBody(Buffer.class);
            if (buffer != null) {
                jettyExchange.setMethod(HttpMethods.POST);
                jettyExchange.setRequestContent(buffer);
            } else {
                jettyExchange.setMethod(HttpMethods.GET);
            }
        }

        for (String name : in.getHeaders().keySet()) {           
            String value = in.getHeader(name, String.class);
            if( "Content-Type".equals(name) ) {
                jettyExchange.setRequestContentType(value);
            } else {
                jettyExchange.addRequestHeader(name, value);
            }
        }
        try {
            httpClient.send(jettyExchange);
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.client.HttpExchange.ContentExchange

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.