Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Nov 05, 2013 at 06:57 UTC ( [id://1061253]=note: print w/replies, xml ) Need Help??


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

I need a script to receive a POST request and then to send that same POST request to a different script. I don't mean that this is a redirect; the script simply notifies another script.

In theory, the first script could just immediately exec the second script. The second script would inherit the same environment (ie. CONTENT_LENGTH) and STDIN (from which it can read the POST data).

This would be very simple & efficient. The first script would (in theory) need be nothing more than:

#! perl exec 'theSecond.pl';

But then, what would be the point? Why not just put the code from the second script in the first avoid the need for the exec?


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: Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?
  • Download Code

Replies are listed 'Best First'.
Re^2: Shortest/quickest way for Perl to take POST data it receives and send a POST request with this data to another URL?
by tunafish (Beadle) on Nov 05, 2013 at 07:33 UTC

    Scripts are on different machines, so this solution is not viable.

      Scripts are on different machines,

      You should make that clear in your question then.

      Is it under your control? Do you have NFS access to it?

      If so, you could still exec it.

      However, if that other machine is another web-server and you need to invoke the remote script via its url, then it makes a lie of "I don't mean that this is a redirect;", because that is exactly what a redirect does.

      Clear questions get good answers.


      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.

        Stupid people write unclear questions!

        I meant -- I guess incorrectly -- that this is not a redirect in the HTTP sense of it. There will not be a 301, 302 or 303 HTTP response to the user's POST request. The user will not be sent to interact directly with script 2. All of this action is happening behind the scenes. The user interacts with script 1 from start to finish, but at a certain point, script 1 sends a POST request to script 2.

        Edited to add: Just re-read the original question. I did specifically ask about how to have one script send a POST request to a second script, so I'm really not sure how that was an "unclear question". I think you read into the question something that I didn't actually ask.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-18 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found