Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^10: Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?

by BrowserUk (Pope)
on Nov 06, 2013 at 21:59 UTC ( #1061491=note: print w/ replies, xml ) Need Help??


in reply to Re^9: Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?
in thread Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?

FTR, my code is a few lines shorter than the LWP example zentara gave, does more (meaning it's more verbose than necessary), and doesn't use the problematic CGI->Vars which joins multi-values with null bits which aren't considered/handled in the example.

Personally, I wouldn't be looking to use CGI or PSGI.

Installing and invoking either behemoth to decode headers and post data, only to then exactly re-encode them for the forwarded request seems a futile exercise, when you can easily arrange for most serious webservers to re-write or re-direct the url without need for any code. And the very definition of technical debt.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^10: Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?
Re^11: Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?
by Your Mother (Canon) on Nov 06, 2013 at 23:38 UTC

    I tend to agree. That was not the OP's question though and it is easy to imagine the real use case is not a straight-up proxy. And exploring Perl options is more fun, well, not so much today apparently, and edifying.

      I tend to agree. That was not the OP's question though

      Really? I thought that was exactly what he asked for?

      A possible solution is, of course, to parse the data using CGI, then to form and send a POST request using LWP, but this seem un-Perl-like and inelegant. Surely there's a simpler solution?

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Now you’re just messing with me…

        Is there a way to take the request that was used to access a cgi script and turn it into an HTTP::Request object?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-12-29 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (184 votes), past polls