Michael
Michael

Reputation: 35351

Mule 3: How to get the HTTP headers from a MuleMessage

Given a MuleMessage object that was created from an HTTP request, how do you get the HTTP headers of the request? I'm using Mule 3.2.1. Thanks.

Upvotes: 2

Views: 11275

Answers (3)

Sunshine C
Sunshine C

Reputation: 175

You can also check by putting log message

<logger message="=============test= #[message.inboundProperties]" level="INFO" doc:name="Logger"/>

Let me know if that works for you.

Thanks

Upvotes: 0

Michael
Michael

Reputation: 35351

HTTP headers are stored as inbound-scoped properties. Their property names are prefixed with http.. For example:

MuleMessage message = ...
String contentType = (String)message.getInboundProperty("http.Content-Type");

But there are other HTTP-related properties inside of the "http." property namespace as well, such as "http.status" for the status code and "http.request" for the request URL. So, while it's possible to retrieve individual headers, there's no reliable, automated way of getting a list of all HTTP headers.

This issue is slated to be fixed in Mule 3.3. Mule 3.3 will organize HTTP-related properties better. For example, all headers will be stored in a property named "http.headers", and all query string parameters will be parsed and stored in "http.query.params".

Upvotes: 6

David Dossot
David Dossot

Reputation: 33413

All the HTTP headers are in the inbound-scoped properties of the MuleMessage.

Upvotes: 5

Related Questions