Forum

Please enable PUT and DELETE with url-rewrite

Michael Klein
27 July 2009, 19:59
Hi,

I installed Hiawatha today on a test-server - and everything works perfectly except two little things:

1). I'd like to use your fast server with Symfony and some RESTful Scripts with that, but at this moment URL-rewriting and PUT/DELETE together is not enabled.... server returns a 501...

2). Symfony complains about "Undefined index: QUERY_STRING", but "EnablePathInfo = yes" in config and print_r(
_$_SERVER) returns the correct var. Very strange...

But: all in all a very smart and fast server! Keep up the good work.

Hiawatha version: 6.16
Operating System: Debian Lenny 5.02

Cheers,

Michael
Hugo Leisink
27 July 2009, 20:48
1) Even if Hiawatha would support URL rewriting for PUT and DELETE, I still forsee a problem. Symfony is most likely build on and build for... Apache. And Apache got the PUT request wrongly implemented. If you PUT to a CGI program in Apache, Apache will execute the CGI program. It is up to that CGI script to read the body of the HTTP request. This is wrong. What Hiawatha does is overwrite the CGI program with the body of the HTTP request. According to the official HTTP RFC, that's the correct way of handling a PUT request. And otherwise, there wouldn't be a difference between POST and PUT. Quote from the official HTTP RFC [www.w3.org]:

"The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource."

This also indicates that URL rewriting for PUT requests is not allowed...

2) I guess the problem lies in that Symfony was build on and build for Apache. But that's a guess. I haven't looked at Symfony yet. I will put it on my TODO list.


I think both of your 'problems' come from the fact that many web developers follow Apache's standard instead of the official web standards. Many people like to say how bad Microsoft is for not following standards and they therefor should use open source. Specially Apache instead of MS IIS. Well, if you really take open standards serious... don't go for Apache.
Michael Klein
27 July 2009, 22:10
Thanx for your answer!

You're right, according to the RFC this behaviour is wrong.

But I WANT to use hiawatha because of the speed and simple configuration... and on the other hand I see A**che with multiple server architectures and slow stuff...

What can I do for now?
1.) write a tutorial / howto for setting up symfony & hiawatha

2.) rewrite my RESTful interface...

BTW, it would be very interesting to write a small conversion table for easy rewriting apache mod_write into UrlToolkit...

Thanx again!
Hugo Leisink
28 July 2009, 00:57
1) a tutorial would be great. If it's a good tutorial, I can publish it on this website if that's oke with you.

2) that's an option. Depends on what you want. Follow the Apache standard (which is probably the most user standard for Unix web building) or follow the official standard. You could also make your interface talk both standards...
This topic has been closed.