Solved

How to redirect with POST request

Posted on 2001-06-19
6
581 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating the data using Oracle DBD module. 5 67
Writing a parser for java language 4 80
create a gui in perl 3 88
Matching a random pattern with one common character 2 62
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

810 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