how to send a header with Direct Web Remoting (DWR) with engine.js?

2k views Asked by At

Ive been trying to use engine.js with DWR to send a header with my request.

For this I am trying to use the preHook (that it is supposed to be triggered before the rest of other things are executed), and I need to send a header metag as parameter (with a value)

Checking the webiste http://directwebremoting.org/dwr/documentation/browser/engine/index.html have a poor information (almost none) about headers, so, I have no idea how to have the correct format for this, any of you have done this before?

I need it to integrate it with my java app. Thanks.

1

There are 1 answers

0
BrianV On BEST ANSWER

According to the DWR documentation, you should be able to set headers as one of the request options. For example:

dwr.engine.setHeaders({
  "Content-Type":"text/plain",
  "My-Special-Header":"some-value"
});

Or it seems you could do it per-request, like so:

Remote.singleMethod(params, {
  headers: {
    "Content-Type":"text/plain",
    "My-Special-Header":"some-value"
  }
});