Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Can't access {POST|PUT}DATA from CGI script

by derby (Abbot)
on Aug 16, 2011 at 11:40 UTC ( #920464=note: print w/ replies, xml ) Need Help??


in reply to Can't access {POST|PUT}DATA from CGI script

chromatic is correct. From the docs:

If POSTed data is not of type application/x-www-form-urlencoded or multipart/form-data, then the POSTed data will not be processed, but instead be returned as-is in a parameter named POSTDATA.

I'm not sure of all the curl command lines, but here's how I would test using LWP's lwp-request:

lwp-request -m PUT -c 'text/xml' -se 'http://localhost/cgi-bin/api.pl +' < test.xml
One caveat though, it cannot be 'application/xml' either. For some reasons XForms overreached and managed to grab that generic content-type and CGI does some special processing for it.

-derby

update: And to properly handle PUTDATA, you need your CGI version to be greater that 3.30. That support was actually hacked our here in the monastery: REST Webservices and CGI.pm.


Comment on Re: Can't access {POST|PUT}DATA from CGI script
Download Code
Re^2: Can't access {POST|PUT}DATA from CGI script
by vendion (Scribe) on Aug 16, 2011 at 12:56 UTC

    My CGI module 3.52, and the version on my production server is newer, I would say 3.55 because it was installed via CPAN last week. As for how curl works when given the -T flag it does a PUT and looks like this

    PUT /cgi-bin/api.pl?mode=MultiSpeak3 HTTP/1.1 User-Agent: curl/7.21.7 (x86_64-unknown-linux-gnu) libcurl/7.21.7 Open +SSL/1.0.0d zlib/1.2.5 libssh2/1.2.7 Host: localhost Accept: */* Content-Length: 6581 Expect: 100-continue (data)

    I placed a copy of the full PUT in my scratchpad includeing the data that I am trying to send. If I don't use the CGI module and grab from <STDIN> I am able to get the data back, doing it this way may make things harder on me in the long run which is why I am trying to use the CGI Module in the first place. I thought that maybe the CGI moudle was chocking on the newlines in the sample file that I have to work from but making a copy of it and stripping them out did not help.

    EDIT: Using your suggestion of LWP I was able to do a PUT to my script and it returned the data, so my problem is with CURL not giving a conetent type/CGI looking for a content type and not finding one or a little of both...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://920464]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2014-12-19 01:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls