|We don't bite newbies here... much|
Are all .cgi helper modules unfit for http methods common in REST?by isync (Hermit)
|on Aug 12, 2010 at 19:29 UTC||Need Help??|
isync has asked for the wisdom of the Perl Monks concerning the following question:
So far I had a look at CGI.pm and CGI::Simple.
The trouble starts when you are handling non-mainstream requests that contain payload, like the PUT method. That means, the HTTP message has a body or content attached, which is not the result of a POST action or is not labeled as being 'application/x-www-form-urlencoded'.
My experience is that CGI.pm 3.49 does not read in the put data correctly, although it should do so and store it in param('PUTDATA') (after a lot of effort).
Other non-standard methods do send content as well, for example the PROPFIND method common in WebDAV. CGI.pm simply ignores it. CGI::Simple at least tells me it skipped it by raising the '.cgi_error' => '400 Unknown method PROPFIND' error flag.
In both cases I can resort to reading in STDIN. But things with STDIN get messy when your helper module *thinks* it did the right thing, garbled everything into key/value param nonsense or similar. And then, STDIN is cleared.
Building on the best there is, you decide to use CGI::Simple, but what about large payloads, gigabytes? Reading all this into memory is a bad idea. CGI.pm has hooks to process chunk by chunk or send everything to a file - CGI::Simple doesn't (right?).
Or have you every tried to output all capitalized/partly capitalized headers like "ABC-Value: test"? The header(-abc_alue => 'test') interface is your only chance and it only ever capitalizes the first letter!
So, is there a .cgi helper module which I can use as a replacement for CGI.pm which doesn't try to marshall which method is okay or not and lets me handle method evaluation. Is there a helper which reads in whole HTTP requests while providing hooks to do it in slurps, or in chunks, to a file, etc.
In one sentence: is there a .cgi helper module which is fit for REST?