Re: Preserving POST data on external redirect?
On Mon, 24 Jun 2002, Kirk Bowe wrote: Date: Mon, 24 Jun 2002 16:22:42 +0100 (BST) From: Kirk Bowe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Preserving POST data on external redirect? Hi all, my content handler does some work with POSTed data, and at the end wants to redirect to a totally unrelated server, preserving the POST data that the client originally sent, so that the unrelated server can do its own further processing with its own mod_perl, cgi, or whatever. I can't get it to work, as I think I'm getting confused by some pre-Apache::Request hints that I've seen for this. This is the mess I've got so far (condensed): sub handler { my $r = Apache::Request-new(shift); ... some calls to other subs here to do work ... $r-method(POST); $r-method_number(M_POST); $r-headers_in-unset(Content-length); $r-args($content); $r-header_out('Location' = http://j.random.server.com/foo.cgi;); $r-status(REDIRECT); $r-send_http_header; return REDIRECT; } It redirects, but doesn't pass the POST data. I thought it may have been due to the original post data being deleted because I use it, so I tried using Request-instance instead of Request-new, but that made no difference either. Is it actually possible to do it if I'm using the Request object? Cheers I think this is what you want: http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_a_POST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no ky
Re: Preserving POST data on external redirect?
Hi, yes that's one of the pages that I've been looking at, and the code is almost identical (I've tried M_GET / GET as well). Still nothing happening for me :-) Cheers Kirk. On Mon, 24 Jun 2002, Ken Y. Clark wrote: On Mon, 24 Jun 2002, Kirk Bowe wrote: Date: Mon, 24 Jun 2002 16:22:42 +0100 (BST) From: Kirk Bowe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Preserving POST data on external redirect? Hi all, my content handler does some work with POSTed data, and at the end wants to redirect to a totally unrelated server, preserving the POST data that the client originally sent, so that the unrelated server can do its own further processing with its own mod_perl, cgi, or whatever. I can't get it to work, as I think I'm getting confused by some pre-Apache::Request hints that I've seen for this. This is the mess I've got so far (condensed): sub handler { my $r = Apache::Request-new(shift); ... some calls to other subs here to do work ... $r-method(POST); $r-method_number(M_POST); $r-headers_in-unset(Content-length); $r-args($content); $r-header_out('Location' = http://j.random.server.com/foo.cgi;); $r-status(REDIRECT); $r-send_http_header; return REDIRECT; } It redirects, but doesn't pass the POST data. I thought it may have been due to the original post data being deleted because I use it, so I tried using Request-instance instead of Request-new, but that made no difference either. Is it actually possible to do it if I'm using the Request object? Cheers I think this is what you want: http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_a_POST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no ky
Re: Preserving POST data on external redirect?
A few things to note here... You cannot post to a remote server in this fashion. You can take a POST request to your server and convert it to a GET request to another server, which may not be what you want. To take POST content and POST it to another server you must proxy the request. By proxy, I mean using LWP to make the request to the remote server via POST, and delivering that returned content back to the user. That's the easy part. Now you'll have to fix all the relative URLs within that document so that they point to the remote server rather than to your server, which is further complicated by things like CSS and Javascript. Look into libwww-perl (LWP) and HTML::TreeBuilder (for fixing the links). I'm sure that there is stuff in this lists' archives which go into more detail on both of those... Hope that helps, Rob On Mon, Jun 24, 2002 at 12:03:50PM -0400, Ken Y. Clark wrote: On Mon, 24 Jun 2002, Kirk Bowe wrote: Date: Mon, 24 Jun 2002 16:22:42 +0100 (BST) From: Kirk Bowe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Preserving POST data on external redirect? Hi all, my content handler does some work with POSTed data, and at the end wants to redirect to a totally unrelated server, preserving the POST data that the client originally sent, so that the unrelated server can do its own further processing with its own mod_perl, cgi, or whatever. I can't get it to work, as I think I'm getting confused by some pre-Apache::Request hints that I've seen for this. This is the mess I've got so far (condensed): sub handler { my $r = Apache::Request-new(shift); ... some calls to other subs here to do work ... $r-method(POST); $r-method_number(M_POST); $r-headers_in-unset(Content-length); $r-args($content); $r-header_out('Location' = http://j.random.server.com/foo.cgi;); $r-status(REDIRECT); $r-send_http_header; return REDIRECT; } It redirects, but doesn't pass the POST data. I thought it may have been due to the original post data being deleted because I use it, so I tried using Request-instance instead of Request-new, but that made no difference either. Is it actually possible to do it if I'm using the Request object? Cheers I think this is what you want: http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_a_POST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no ky
Re: Preserving POST data on external redirect?
Hi, The RFC 2068 (HTTP/1.1) specify that: 301 e 302 responses to POSTs shouldn't be redirected unless they can be confirm by user. Also notes that some UA transform the POST to a GET, erroniously. Merlin, The Mage On Monday 24 June 2002 11:50 am, Kirk Bowe wrote: : Hi, yes that's one of the pages that I've been looking at, and the code is : almost identical (I've tried M_GET / GET as well). Still nothing : happening for me :-) : : Cheers : : Kirk. : : On Mon, 24 Jun 2002, Ken Y. Clark wrote: : On Mon, 24 Jun 2002, Kirk Bowe wrote: : Date: Mon, 24 Jun 2002 16:22:42 +0100 (BST) : From: Kirk Bowe [EMAIL PROTECTED] : To: [EMAIL PROTECTED] : Subject: Preserving POST data on external redirect? : : : : Hi all, my content handler does some work with POSTed data, and at the : end : wants to redirect to a totally unrelated server, preserving the POST : data that the client originally sent, so that the unrelated server can : do its own further processing with its own mod_perl, cgi, or whatever. : : I can't get it to work, as I think I'm getting confused by some : pre-Apache::Request hints that I've seen for this. This is the mess : I've got so far (condensed): : : sub handler : { : my $r = Apache::Request-new(shift); : : ... some calls to other subs here to do work ... : : $r-method(POST); : $r-method_number(M_POST); : $r-headers_in-unset(Content-length); : $r-args($content); : $r-header_out('Location' = http://j.random.server.com/foo.cgi;); : $r-status(REDIRECT); : $r-send_http_header; : : return REDIRECT; : } : : It redirects, but doesn't pass the POST data. I thought it may have : been due to the original post data being deleted because I use it, so I : tried using Request-instance instead of Request-new, but that made no : difference either. Is it actually possible to do it if I'm using the : Request object? : : Cheers : : I think this is what you want: : : http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_ : a_POST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no : : ky -- Merlin, The Mage themage.camelot.co.pt
Re: Preserving POST data on external redirect?
Ken Y. Clark [EMAIL PROTECTED] wrote: On Mon, 24 Jun 2002, Kirk Bowe wrote: Hi all, my content handler does some work with POSTed data, and at the end wants to redirect to a totally unrelated server, preserving the POST data that the client originally sent, so that the unrelated server can do its own further processing with its own mod_perl, cgi, or whatever. I can't get it to work, as I think I'm getting confused by some pre-Apache::Request hints that I've seen for this. This is the mess I've got so far (condensed): sub handler { my $r = Apache::Request-new(shift); ... some calls to other subs here to do work ... $r-method(POST); $r-method_number(M_POST); $r-headers_in-unset(Content-length); $r-args($content); $r-header_out('Location' = http://j.random.server.com/foo.cgi;); $r-status(REDIRECT); $r-send_http_header; return REDIRECT; } It redirects, but doesn't pass the POST data. It can't, because this is the browsers job. Your script doesn't make a connection the other server. You have to do transparent proxying or depend on the browser. I think this is what you want: http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_a_POST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no Host not found... --Nikolaus
Re: Preserving POST data on external redirect?
The link asks to change POST to GET. However, there is a limit on the length of the URL so the POST data may be truncated and the redirect action may not work properly. Also, make sure to escapeURL() in the URL (which will also add extra chars in the URL). Peter Bi - Original Message - From: Kirk Bowe [EMAIL PROTECTED] To: Ken Y. Clark [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, June 24, 2002 8:50 AM Subject: Re: Preserving POST data on external redirect? Hi, yes that's one of the pages that I've been looking at, and the code is almost identical (I've tried M_GET / GET as well). Still nothing happening for me :-) Cheers Kirk. On Mon, 24 Jun 2002, Ken Y. Clark wrote: On Mon, 24 Jun 2002, Kirk Bowe wrote: Date: Mon, 24 Jun 2002 16:22:42 +0100 (BST) From: Kirk Bowe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Preserving POST data on external redirect? Hi all, my content handler does some work with POSTed data, and at the end wants to redirect to a totally unrelated server, preserving the POST data that the client originally sent, so that the unrelated server can do its own further processing with its own mod_perl, cgi, or whatever. I can't get it to work, as I think I'm getting confused by some pre-Apache::Request hints that I've seen for this. This is the mess I've got so far (condensed): sub handler { my $r = Apache::Request-new(shift); ... some calls to other subs here to do work ... $r-method(POST); $r-method_number(M_POST); $r-headers_in-unset(Content-length); $r-args($content); $r-header_out('Location' = http://j.random.server.com/foo.cgi;); $r-status(REDIRECT); $r-send_http_header; return REDIRECT; } It redirects, but doesn't pass the POST data. I thought it may have been due to the original post data being deleted because I use it, so I tried using Request-instance instead of Request-new, but that made no difference either. Is it actually possible to do it if I'm using the Request object? Cheers I think this is what you want: http://theoryx5.uwinnipeg.ca/cgi-bin/guide-filter?page=snippets/Redirect_a_P OST_Request_Forward.html;query=GET%20POST;match=and;where=all;stem=no ky