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

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Feb 28 18:37:16 EST 2008

Norman,

It would be great to add support for other methods. The thing to do is
add another field in the request
structure. I would suggest adding a bytes field to copy the method
from the port, but you could make it a symbol from a particular set of
the valid methods. You are totally correct in that the majority of the
server is completely ignorant of the method, except for GET/POST/HEAD.
(The file dispatcher understands HEAD; it will just need to be
modified to fail on the other methods.)

So a patch is welcome, but if you can wait a little bit, I could put
it on my agenda for next week.

Jay

On Thu, Feb 28, 2008 at 3:09 PM, Norman Gray <norman at astro.gla.ac.uk> wrote:
>
>  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
>
>  _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
Jay McCarthy <jay.mccarthy at gmail.com>
http://jay.teammccarthy.org


Posted on the users mailing list.