camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg.Kasian" <o-kas...@yandex.ru>
Subject Problems when forwarding large post with jetty
Date Fri, 19 Oct 2012 07:24:53 GMT
I am facing the problem when forwarding post requests with large data using
camel-jetty component. I am not sure what is the reason, stack trace is:

2012-10-19 10:04:30.991:WARN:oejs.HttpConnection:header full:
java.lang.RuntimeException: Header>6144
2012-10-19 10:04:30.992:WARN:oejs.Response:Committed before 500 null
2012-10-19 10:04:30.992:WARN:oejs.HttpConnection:/forward
java.lang.IllegalStateException: Committed
	at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1059)
        ...

camel version 2.10.0
jetty version 7.5.4.v20111024
The problem first occured when running camel based app on karaf 2.2.9,
however I can reproduce it with this unit test:

import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Random;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.http.HttpStatus;
import org.junit.Test;


public class JettyPostBigDataTest extends CamelTestSupport {

    private static final int LENGTH = 5 * 1024;

    @Test
    public void testPostParameter() throws Exception {
        final String body = generateBody(LENGTH);
        final NameValuePair[] data = {
            new NameValuePair("param", body)
        };
        final HttpClient client = new HttpClient();
        final PostMethod post = new
PostMethod("http://localhost:5757/test");
        post.setRequestBody(data);
        client.executeMethod(post);
        final InputStream response = post.getResponseBodyAsStream();
        final String out =
context.getTypeConverter().convertTo(String.class, response);
        assertEquals("ERROR OCCURED: \n" + out, HttpStatus.SC_OK,
post.getStatusCode());
    }

    private String generateBody(final int length) throws
UnsupportedEncodingException {
        final Random rnd = new Random();
        byte[] bytes = new byte[length];
        rnd.nextBytes(bytes);
        return new String(bytes);
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() {

               
from("jetty:http://localhost:5757/test").to("http://localhost:5757/forward?bridgeEndpoint=true");

                from("jetty:http://localhost:5757/forward")
                        .setBody(simple("${in.header.param[0]}"))
                        .convertBodyTo(String.class)
                        .to("mock:result");

            }
        };
    }
}



--
View this message in context: http://camel.465427.n5.nabble.com/Problems-when-forwarding-large-post-with-jetty-tp5721278.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message