Custom Header Problem

629 views
Skip to first unread message

Zahir Hamroune

unread,
Nov 3, 2011, 9:40:50 AM11/3/11
to restygwt
Hello every one,
j have a problem with custom header, my code bellow

//Client with RestyGWT
Map<String, String> headersMap = new HashMap<String, String>();
headersMap.put("X-CustomHeader", "123456789...");
Resource resource = new Resource(url, headersMap);

//Server
in my filter, when inspecting the request

String customHeader = request.getHeader("X-CustomHeader");

customHeader still null;

how can i send a custom header?





Maximiliano Carrizo

unread,
Nov 3, 2011, 9:56:42 AM11/3/11
to rest...@googlegroups.com
Install firebug and check if parameter X-CustomHeader is present in outcoming header. It will help you detecting where is the problem, in browser or servlet.

   Regards !

2011/11/3 Zahir Hamroune <hamro...@sfeir.com>

Zahir Hamroune

unread,
Nov 3, 2011, 10:13:55 AM11/3/11
to rest...@googlegroups.com
I found @HeaderParam, adding it to signature method, it works perfect like
@GET void someMethod(@HeaderParam("X-CustomHeader") String customHeader, MethodCallback....);
thanks for reply, but i will try with firebug/Chrome inspection.

2011/11/3 Maximiliano Carrizo <mcar...@gmail.com>



--
Mr. Zahir Hamroune
Ingénieur Etude & Développement Web RIA
GWT - Java/J2ee - Méthode Scrum

Maximiliano Carrizo

unread,
Nov 3, 2011, 10:17:30 AM11/3/11
to rest...@googlegroups.com
Personally, I add header parameters with Resty-GWT in this way:


resource.get().header(Constants.CITI_TOKEN, sessionToken).timeout(TIMEOUT);


And always works !

Zahir Hamroune

unread,
Nov 3, 2011, 10:39:05 AM11/3/11
to rest...@googlegroups.com
I can confirm that using your method there is no param headres displayed in Firebug, but when using @HeaderParam, it appears, so??
i'm using RestyGWT 1.2

2011/11/3 Maximiliano Carrizo <mcar...@gmail.com>

Maximiliano Carrizo

unread,
Nov 3, 2011, 10:42:15 AM11/3/11
to rest...@googlegroups.com
Trick is to do this:

Method method = resource.get().header("param1", "value1");
method.send( .... );

If you don't do this, doesn't work. I don't use resty-gwt with annotations, I had a lot of problems....

kristian

unread,
Nov 3, 2011, 10:53:50 AM11/3/11
to rest...@googlegroups.com
if I look at the code then

Map<String,String> headers = new HashMap<>();
headers.put("param1", "value1");
Method method = new Resource(url, headers).get();
method.send(...);

should do the same as in your examples. if only your TRICK works
please file a bug sowe can track it down.

regards, Kristian

Zahir Hamroune

unread,
Nov 3, 2011, 11:08:11 AM11/3/11
to rest...@googlegroups.com
Yep it works with method.send();
how can i create a bug?
thanks

2011/11/3 kristian <m.kri...@web.de>

Maximiliano Carrizo

unread,
Nov 3, 2011, 11:14:28 AM11/3/11
to rest...@googlegroups.com
You're welcome. I'm very happy you could make it work !

         Bye !

kristian

unread,
Nov 3, 2011, 11:25:47 AM11/3/11
to rest...@googlegroups.com
On Thu, Nov 3, 2011 at 8:38 PM, Zahir Hamroune <hamro...@sfeir.com> wrote:
> how can i create a bug?

https://github.com/chirino/resty-gwt/issues

thanx, Kristian

Reply all
Reply to author
Forward
0 new messages