This project is read-only.

no response on OPTIONS header

Topics: blog, faq
Dec 27, 2010 at 6:59 AM
Hi,

I have a server very much like the example in http://webserver.codeplex.com/Thread/View.aspx?ThreadId=78947

Server server = new Server();

// Load file resources from c:\\temp
server.Add(new FileResources("/files/", "C:\\temp\\"));

// Only decode forms of type application/multi-part
server.Add(new MultipartDecoder());

// Serve files from the built in resource provider
server.Add(new FileModule(server.ResourceProvider, false));

// Only using one listener (could use many different ones)
HttpListener listener = HttpListener.Create(IPAddress.Any, 8085);
server.Add(listener);

// start server (can have 5 pending accepts)
server.Start(5);

I nocticed that it does not respond on a OPTIONS header.

OPTIONS /getconfiguration?_=1293186249649 HTTP/1.1
Host: 10.100.1.100:8888
Access-Control-Request-Method: GET
Origin: http://10.100.1.100:8081
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7E18
Accept: */*
Referer: http://10.100.1.100:8081/
Access-Control-Request-Headers: X-Requested-With, Accept
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Length: 0
Connection: keep-alive

On this I don't get any reply (using wireshark).
Anyone who know why I will not get a reply on this header ?

I would expect some reply like this:
HTTP/1.1 200 OK
Date: Mon, 01 Dec 2008 01:15:39 GMT
Server: Apache/2.0.61 (Unix)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: X-Requested-With
Access-Control-Max-Age: 86400
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 0
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: text/plain
Please note that I am working on implementing CORS to overcome the same origin policy.

I have two webservers (say A and B) when I browse to A and make ajax calls to B,
it works using CORS headers. But when I browse to B and make ajax calls to A,
it does not work because A (the server above) does not respond on the OPTIONS header.

Dec 29, 2010 at 3:14 PM

A should respond with a Bad Request message. I had not added OPTIONS to the enum that I use to validate requests. I've fixed that now (version 2.0).