How to access body of PUT or POST request?

Started by tardigrade, February 10, 2011, 05:03:35 PM

Previous topic - Next topic

tardigrade

I'd like to implement a REST server by running newlisp in http-only mode, and intercepting requests with "command-event".   However, the argument to command-event only contains the method, header and http version.  Is there a way to access the "raw" request body, and thereby gain access to the content of a PUT or POST request?



Thanks in advance,

Jeff

Lutz

#1
'commend-event' is not the right way to do this, I wouldn't even mess with it until your server scripts run. 'command-event' together with newLISP server is mainly used to rewrite URLs.



newLISP HTTP server handles GET, PUT and DELETE requests automatically, without any programming. PUT requests also allow "pragma: append" in the client header for appending to files.



On a newLISP client side: 'read-file', 'write-file', 'append-file', 'delete-file' , 'load' and 'save' can all be used with URLs for the filename. They will all be translated in GET, PUT, DELETE requests and are served automaticall by newLISP server. PUT requests don't need any special server side configuration, as Apache server does. Of course file permissions must be correct.



POST requests must be handled with a CGI script. See the Web section on this page http://www.newlisp.org/index.cgi?Tips_and_Tricks">http://www.newlisp.org/index.cgi?Tips_and_Tricks for examples, i.e. "read form data".



For a more complicated POST handler of multipart encoded forms, see the the link "File Upload Script" it requires the newLISP 10.3 or Apache on the server side.