Hi, If you want to have repeatable streams, enable stream caching (on the route or on the camel context).
Best regards Stephan -----Original Message----- From: Sebastiaan van Erk [mailto:[email protected]] Sent: Donnerstag, 15. März 2018 11:57 To: [email protected] Subject: Repeatable HTTP entity by default? Hi, I am using the HTTP4 component in Camel to send a JSON request to an authenticated REST service (Basic Auth). I don't specify any Content-Encoding. I noticed the following behavior: - If the in exchange body is a byte[], then it turns into an InputStreamEntity which is not repeatable unless the property CamelSkipGzipEncoding is set to true, in which case it becomes a ByteArrayEntity. - If the in exchange body is a String then it ends up becoming a StringRequestEntity which is repeatable. - If the in exchange body is an InputStream, it becomes an InputStreamEntity, which is not repeatable. Since the request is authenticated, the request needs to be repeatable unless you cheat by enabling preemptive auth. My question is: why doesn't Camel aggressively try to return a repeatable HttpEntity unless it cannot reasonably do so. In my opinion the only case that the entity cannot reasonably be made repeatable is in the case of the InputStream body. In all other cases, if the message is already in memory, even the gzip compression can be done to a byte array instead of as a stream, allowing a repeatable ByteArrayEntity as a result. The current behavior is very suprising: a String body IS repeatable by default, a byte[] body is not. Best regards, Sebastiaan
