Your second logging will log headers from the response sent by the http4 
invocation. I am able to see the values and these are not blanked out.

Tried out with following path.

                                
from("timer://foo?fixedRate=true&delay=0&period=1000")
                                                
.setHeader(Exchange.CONTENT_TYPE,
                                                                
constant("application/json"))
                                                
.setHeader(Exchange.HTTP_CHARACTER_ENCODING,
                                                                
constant("UTF-8"))
                                                .to(
                                                                
"log:httpbefore.SYSTEM.COMBEFORE?level=DEBUG&ShowHeaders=true&ShowBody=true")
                                                
.to("http4://api.flickr.com/services/rest/?method=flickr.test.echo&name=value")
                                                .to(
                                                                
"log:httpafter.SYSTEM.COMAFTER?level=DEBUG&ShowHeaders=true&ShowBody=true");


[mel-1) thread #0 - timer://foo] COMBEFORE                      DEBUG 
Exchange[ExchangePattern: InOnly, Headers: 
{breadcrumbId=ID-LT005383-64443-1390555622180-0-1, 
CamelHttpCharacterEncoding=UTF-8, Content-Type=application/json, firedTime=Fri 
Jan 24 14:57:04 IST 2014}, BodyType: null, Body: [Body is null]]

[mel-1) thread #0 - timer://foo] COMAFTER                       DEBUG 
Exchange[ExchangePattern: InOnly, Headers: {Age=0, 
breadcrumbId=ID-LT005383-64443-1390555622180-0-1, Cache-Control=private, 
CamelHttpCharacterEncoding=UTF-8, CamelHttpResponseCode=200, 
Connection=keep-alive, Content-Length=132, Content-Type=text/xml; 
charset=utf-8, Date=Fri, 24 Jan 2014 09:27:05 GMT, firedTime=Fri Jan 24 
14:57:04 IST 2014, P3P=policyref="http://info.yahoo.com/w3c/p3p.xml";, CP="CAO 
DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi 
UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV", 
Server=ATS, Vary=Accept-Encoding, Via=http/1.1 fts115.flickr.bf1.yahoo.com 
(ApacheTrafficServer/4.0.1 [cMsSf ]), http/1.1 r02.ycpi.inc.yahoo.net 
(ApacheTrafficServer/4.0.2 [cMsSf ]), X-Served-By=www222.flickr.bf1.yahoo.com}, 
BodyType: 
org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream, Body: 
[Body is instance of java.io.InputStream]]


- Ravi

-----Original Message-----
From: E. A. English [mailto:[email protected]]
Sent: Friday, January 24, 2014 12:59 AM
To: [email protected]
Subject: Http4 Set Header Content-Type not passing through to the HTTP Request

Hi,

setting the Content-type header for Http4 Camel Route - Message headers from
the IN message are not being copied to the OUT message

Using Camel Version 2.12.2

example  http4 route code:

    from("timer://foo?fixedRate=true&delay=0&period=10000")
    .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    .setHeader(Exchange.HTTP_CHARACTER_ENCODING, constant("UTF-8"))

.to("log:httpbefore.SYSTEM.COM?level=DEBUG&ShowHeaders=true&ShowBody=true")
    .to("http4://SERVER-remote.com/services/status/54024")

.to("log:httpafter.SYSTEM.COM?level=DEBUG&ShowHeaders=true&ShowBody=true");

The Content Type and Character Encoding message headers are apparently being
filtered out.

Excerpt from Log with JSON Content Type IN message:

[                          main] RouteService                   DEBUG
Starting child service on route: route1 ->

Pipeline[[Channel[setHeader(Content-Type, application/json)],

Channel[setHeader(CamelHttpCharacterEncoding, UTF-8)],

Channel[sendTo(Endpoint[log://httpbefore.SYSTEM.COM?ShowBody=true&ShowHeaders=true&level=DEBUG])],

Channel[sendTo(Endpoint[http4://server.remote.com/services/status/54024])],

Channel[sendTo(Endpoint[log://httpafter.SYSTEM.COM?ShowBody=true&ShowHeaders=true&level=DEBUG])]]]


if you look at the outgoing >>  wire and headers lines you could see the
Content-Type is missing:

[mel-1) thread #0 - timer://foo] DefaultClientConnection        DEBUG
Sending request: GET /services/status/54024 HTTP/1.1
[mel-1) thread #0 - timer://foo] wire                           DEBUG >>
"GET /services/status/54024 HTTP/1.1[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG >>
"firedTime: Thu Jan 23 14:05:49 EST             2014[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG >>
"breadcrumbId: ID-com-43559-     1390503945739-0-1[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG >>
"Host: SERVER-remote.com:443[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG >>
"Connection: Keep-Alive[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG >>
"[\r][\n]"
[mel-1) thread #0 - timer://foo] headers                        DEBUG >> GET
/services/status/54024 HTTP/1.1
[mel-1) thread #0 - timer://foo] headers                        DEBUG >>
firedTime: Thu Jan 23 14:05:49 EST 2014
[mel-1) thread #0 - timer://foo] headers                        DEBUG >>
breadcrumbId: ID-com-43559-      1390503945739-0-1
[mel-1) thread #0 - timer://foo] headers                        DEBUG >>
Host: SERVER-remote.com:443
[mel-1) thread #0 - timer://foo] headers                        DEBUG >>
Connection: Keep-Alive
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"HTTP/1.1 200 OK[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Cache-Control: private[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Content-Type: text/html[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Server: Microsoft-IIS/8.0[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"X-Powered-By: ServiceStack/3.962 Win32NT/.     NET[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Access-Control-Allow-Origin: *[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Access-Control-Allow-Methods: GET, POST, PUT,  DELETE, OPTIONS[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"X-AspNet-Version: 4.0.30319[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"X-Powered-By: ASP.NET[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Access-Control-Allow-Origin: *[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Access-Control-Allow-Headers: Content-         Type[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Access-Control-Allow-Methods: GET, POST, PUT,  DELETE, OPTIONS[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Date: Thu, 23 Jan 2014 19:05:51 GMT[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"Content-Length: 9750[\r][\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"[\r][\n]"
[mel-1) thread #0 - timer://foo] DefaultClientConnection        DEBUG
Receiving response: HTTP/1.1 200 OK
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
HTTP/1.1 200 OK
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Cache-Control: private
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Content-Type: text/html
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Server: Microsoft-IIS/8.0
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
X-Powered-By: ServiceStack/3.962 Win32NT/.NET
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Access-Control-Allow-Origin: *
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Access-Control-Allow-Methods: GET, POST, PUT,   DELETE, OPTIONS
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
X-AspNet-Version: 4.0.30319
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
X-Powered-By: ASP.NET
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Access-Control-Allow-Origin: *
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Access-Control-Allow-Headers: Content-Type
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Access-Control-Allow-Methods: GET, POST, PUT,   DELETE, OPTIONS
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Date: Thu, 23 Jan 2014 19:05:51 GMT
[mel-1) thread #0 - timer://foo] headers                        DEBUG <<
Content-Length: 9750
[mel-1) thread #0 - timer://foo] DefaultHttpClient              DEBUG
Connection can be kept alive indefinitely
[mel-1) thread #0 - timer://foo] HttpProducer                   DEBUG Http
responseCode: 200
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"<!doctype html>[\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"<html lang="en-us">[\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"<head>[\n]"
[mel-1) thread #0 - timer://foo] wire                           DEBUG <<
"<title>RequestStatus Snapshot of 1/23/2014 7:  05:51 PM</title>[\n]"

is this expected behaviour? why Content-Type and Character-Encoding headers
being dropped.

do we need are they being filtered because of headerFilterStrategy option is
set to null.

does headerFilterStrategy when set to null filter out all setHeader?

if the issue is headerFilterStrategy, is there example code somewhere that
shows how not to filter out Content-Type.

thanks,

chasse



--
View this message in context: 
http://camel.465427.n5.nabble.com/Http4-Set-Header-Content-Type-not-passing-through-to-the-HTTP-Request-tp5746414.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful.

Reply via email to