6 Replies Latest reply on Apr 10, 2012 7:08 AM by jamie3_james.archibald

    Can't convert HTTP Response with no Content-Type to String

    jamie3_james.archibald

      I have a case where I am doing an HTTP POST to a web server and the response is text but camel cannot convert the body to a string. Instead the conversion results in an empty string.

       

      from("timer://foo")

      .to("http://somehost/bar")

      .convertBodyTo(String.class)

      // this results in an empty string

      .log("$");

       

      I examined the response body and it is a CachedOutputStream$WrappedInputStream. If I introspect through the body I can see the actual text that the server is responding with.

       

      I turned on debugging for the camel http component and it is saying that the Content-Type isn't found in the http response. Would this contribute to the problem?

       

      My only work around is to write my own type converter, however I was hoping camel's built in type converters could handle this.

       

      Or I was hoping to somehow force the http endpoint to read the response as text.