Is it possible to redirect a POST?

I know that you can redirect a user via cgi by sending the header:

Location: http://whatever.com/whatever?whatever

Is it possible to redirect like this with a post operation?
In other words, the above is just a plain get, with stuff on the query string, what about if someone executed a POST into my cgi script, but I want a different cgi script on a different server to handle the post. Can you redirect that post to the other server?
taotreeAsked:
Who is Participating?
 
jhurstConnect With a Mentor Commented:
YES  -however, the LOCATION header does not allow you to send posted information.  But the re-direct will work when the form is posted.

Probably the way to do what you want is to have a script that reads the posted paramneters and then converts them to the ?.... as expected in a GET before the re-direct.  The down-sides are:
1) there is usually a limit to the lenngth of the QUERY_STRING that the server will accept in the GET
2) The values of the parameters will become visible in the location bar.

0
 
taotreeAuthor Commented:
Adjusted points to 100
0
 
ozoCommented:
Or you might send a POST request from your CGI program to the other server.
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
TheMadManiacCommented:
Something to take into consideration with a redirect: most browsers will pop up a window telling the user that the POST request is being redirected. This is a good thing, but it might not what you want.

Floris 'i want to change my nick' van Gog
0
 
taotreeAuthor Commented:
Well, I'm basically taking these comments as a "no" to my question. I already knew most of what was said--I'm going to implement with the POST to GET routing and just hope no one exceeds the query string limit.

I guess my next question is why doesn't the HTTP spec let you do this? Why allow redirect of a get but not a post (with all data that is)?

Thanks!
0
 
TheMadManiacCommented:
The POST data is not contained within the header, GET data is. That might be why :)

Floris
0
 
taotreeAuthor Commented:
Doesn't seem like it would be that hard to have the Location header act in such a way that it tells the client, "okay redo your entire request to this other url". The client would then resend it's request along with all post data.

Oh, well. We'll live. I was considering the "server make post request then return the web page myself", but that could add up to a lot of extra bandwidth and might get expensive.

Here's another question, though, if I did that, is there anyway to tell the browser to change the URL in the location bar? Because if I return the web page--all the relative links will not work.
0
All Courses

From novice to tech pro — start learning today.