Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Http4 Set Header Content-Type not passing through to the HTTP Request

$
0
0
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痩=0ꗪ=10000")
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.setHeader(Exchange.HTTP_CHARACTER_ENCODING, constant("UTF-8"))

.to("log:httpbefore.SYSTEM.COM?level=DEBUG䨚〝窻=true䨚〆蝲=true")
.to("http4://SERVER-remote.com/services/status/54024")

.to("log:httpafter.SYSTEM.COM?level=DEBUG䨚〝窻=true䨚〆蝲=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䨚〝窻=true闫=DEBUG])],

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

Channel[sendTo(Endpoint[log://httpafter.SYSTEM.COM?ShowBody=true䨚〝窻=true闫=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

Viewing all articles
Browse latest Browse all 5648

Trending Articles