8

How can I set additional HTTP headers while submitting forms with GWT.
(I am using FormPanel for building the form)


Summary

From accepted answer:

HTTP headers cannot be set using FormPanel - FormPanel wraps the standard HTML <form>, which doesn't allow setting custom headers.

Jason Terk
  • 6,005
  • 1
  • 27
  • 31
Kaan
  • 381
  • 5
  • 13

1 Answers1

5

HTTP headers cannot be set using FormPanel - FormPanel wraps the standard HTML <form>, which doesn't allow setting custom headers.

To set your own headers use a RequestBuilder:

RequestBuilder rb = new RequestBuilder(Method.POST, "http://www.my-server.com");
rb.setHeader("X-My-Header", "VALUE");
Request r = rb.sendRequest(null, new RequestCallback() {...});
Jason Terk
  • 6,005
  • 1
  • 27
  • 31
  • 3
    thanks for the answer, but users are submitting a file. So, unless there is a way of uploading a file other than using a form, I will have to figure another solution for my problem. – Kaan Jun 01 '11 at 20:01
  • @Kaan Did you ever figure out another solution? – mal Mar 13 '18 at 09:57