[plt-scheme] Supporting PUT (etc) in the web-server

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Thu Feb 28 18:09:23 EST 2008

Greetings.

The PLT web-server has good support for HTTP GET and POST, but none of  
the other methods.  It supports DELETE by default, but not HEAD or  
PUT.  HEAD one can live without, but not PUT.  What's the best way for  
me to add support for these in an application?  I'm looking at version  
370, but the online documentation for request-structs in 3.99[1] shows  
the same struct for REQUEST, suggesting that this problem isn't about  
to evaporate in the next release.

The restriction comes about, as far as I can see, because it's only  
'get and 'post which are explicitly supported in the function READ- 
BINDINGS&POST-DATA/RAW in web-server/private/request.ss.  Other  
methods don't cause an error, but result in the content of the  
connection apparently being ignored, and specifically being  
unavailable in the REQUEST structure.

As far as I can see, the neatest way of getting round this in the case  
of PUT is to add another field to the REQUEST structure, containing  
the connection-i-port corresponding to the input stream, then adjust  
the content and interface of READ-BINDINGS&POST-DATA/RAW and the call  
to it in READ-REQUEST.  An alternative would be to overload either the  
post-data/raw field or construct a pseudo-binding with the stream as  
value, which would mean at least that the REQUEST structure wouldn't  
have to change.

The question is, should I even attempt this, and if so, what's the  
most robust way to do so?  Providing an alternative application-local  
version of READ-REQUEST seems fragile even if it's feasible.

Thanks for any advice.

Best wishes,

Norman


[1] http://docs.plt-scheme.org/web-server/request-structs_ss.html


-- 
Norman Gray  :  http://nxg.me.uk
eurovotech.org  :  University of Leicester



Posted on the users mailing list.