How can I set Origin and Access-Control-Request-Method when doing a request.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How can I set Origin and Access-Control-Request-Method when doing a request.

Ralph van Etten
Hi,

I am trying to create a test for a server. This test needs to simulate a CORS preflight request but I have trouble setting the correct headers.
In my test I have:

final ClientResource cr = new ClientResource("http://localhost:8000");
cr.getRequest().setAccessControlRequestMethod(Method.GET);
cr.getRequest().getHeaders().set("test", "test");
cr.getRequest().getHeaders().set("origin", "test");
cr.options();

But the request received by the server is lackling the origin and Access-Control-Request-Method headers:

OPTIONS / HTTP/1.1
Date: Tue, 15 Sep 2015 17:01:12 GMT
Accept: */*
User-Agent: Restlet-Framework/2.3.4
test: test
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:8000
Connection: keep-alive

The header named test does show. What is the correct way for setting the Origin and Access-Control-Request-Method header?

Thanks,

Ralph.

To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Loading...