History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XFIRE-884
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Tomasz Sztelak
Reporter: Tomasz Sztelak
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XFire

Add support for custom HTTP headers

Created: 23/Feb/07 03:31 AM   Updated: 27/Feb/07 02:27 AM
Component/s: Core
Affects Version/s: None
Fix Version/s: 1.2.5

Time Tracking:
Not Specified

File Attachments: 1. Text File http-header.patch (2 kb)



 Description  « Hide
It would be good to have a way to specify custom http headers

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Scott MacKenzie - 23/Feb/07 02:07 PM
This change is important for the project I am currently working on so I took a stab at a patch for it.

This patch will allow custom HTTP headers to be added as contextual properties. For example, the developer could set the header(s) like this:

Client client = Client.getInstance(soap)
Map m = new HashMap();
m.put("routing.key", "target");
m.put("test-header", new String[]{"test1", "test2"} );
client.setProperty(CommonsHttpMessageSender.HTTP_HEADERS, m );

this would produce the following headers:

routing.key: target
test-header: test1
test-header: test2

The map can have either (String, String) or (String, String[]) since we are allowed to have headers with the same name.


Tomasz Sztelak - 26/Feb/07 08:09 AM
Fixed in svn

Julius Davies - 26/Feb/07 08:54 PM
I see this committed to SVN:

Map headersMap = (Map) context.getContextualProperty(HTTP_HEADERS);
if (headersMap != null) {
for (Iterator iter = headersMap.entrySet().iterator(); iter.hasNext() { Map.Entry entry = (Entry) iter.next(); postMethod.addRequestHeader(entry.getKey().toString(), entry.getValue().toString()); }
}

I like the Object.toString()! That could come in handy.

Is the support for several headers (so checking for instanceof Object[]) with the same name not desirable?

Just curious if the String[] idea was a bad one.


Tomasz Sztelak - 27/Feb/07 02:27 AM
I fixed this before you attached your patch, so i couldn't see the idea with multiple values for one header. But still i don't see any potential situation when you must send many headers with the same name. If you show me any requirement of that kind i'll add such functionality.