Solved

How to redirect with POST request

Posted on 2001-06-19
6
595 Views
Last Modified: 2008-03-10
To redirect with GET request I use header Location: http...
but how can I redirect POST request?
0
Comment
Question by:serg111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:Sapa
ID: 6208857
You cannot redirect POST to another POST. The POST request can be only the first one in the chain of redirects. But you can pass all POST'ed parameters in URL, if the list is not too big, has no uploads and, of course, the script where you redirect to allows GET method.

Another trick is using Javascript and auto-submited form instead of simple redirect. For example, POST to url1.cgi
will produce such HTML output:

<html>
<body onLoad="document.form1.submit()">
<form name="form1" action="url2.cgi" method="POST">
<input type="hidden" name="param1" value="value1">
<input type="hidden" name="param2" value="value2">
...
<input type="hidden" name="paramN" value="valueN">
</form>
</body>
</html>

- Sapa
0
 
LVL 2

Author Comment

by:serg111
ID: 6208906
The script doesn't allow GET method, POST only :-(

And I want just to redirect , not use intermediate page with Javascript.
0
 
LVL 5

Expert Comment

by:Sapa
ID: 6209878
RFC-2616 ("Hypertext Transfer Protocol -- HTTP/1.1")
Chapter 10.3 ("Redirection 3xx"), page 61

"This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.  The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A client SHOULD detect infinite redirection loops, since such loops generate network traffic for each redirection."

Chapter 10.3.2 ("301 Moved Permanently"), page 62

"If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

Note: When automatically redirecting a POST request after receiving a 301 status code, some existing HTTP/1.0 user agents will erroneously change it into a GET request."

Chapter 10.3.3 ("302 Found"), page 63
"If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

Note: RFC 1945 and RFC 2068 specify that the client is not allowed to change the method on the redirected request.  However, most existing user agent implementations treat 302 as if it were a 303 response, performing a GET on the Location field-value regardless of the original request method. The status codes 303 and 307 have been added for servers that wish to make unambiguously clear which kind of reaction is expected of the client."

Chapter 10.3.8 ("307 Temporary Redirect"), page 65
"If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued."

Full text of RFC-2616 you can read there: http://rfc.net/rfc2616.html

So, HTTP/1.1 standard allows POST-to-POST redirecttion,
but _with_user_confirmation_only! Really, MSIE, NN and AOL browsers are "some existing HTTP/1.0 user agents" which "will erroneously change it into a GET request".

Sorry for ruining your bright hopes.

- Sapa


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:serg111
ID: 6215200
Sapa,

please, change answer to comments.
If noone can answer this question I would accept your comments
0
 
LVL 5

Accepted Solution

by:
Sapa earned 100 total points
ID: 6215351
Let it be comment... although it was an answer.

- Sapa
0
 
LVL 4

Expert Comment

by:Oliver_Dornauf
ID: 7759669
you can usen an HTTP 307 to redirect an post request.
Look at www.pda-systems.com thy have an tutorial wich shows this
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove Malware code from PHP file 6 107
Perl, group, sort, count question 6 158
compress files in RAR using perl 13 94
Perl Script - Remove column of data based on column value 2 59
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question