Re: help with HTTP::Request for POST
on di, 18 feb 2003 16:43:22 GMT, Scott Lutz wrote: What I am attempting to do, is do a server side form action redirect based on a regex on a field from the form. It now seems that this is just going to POST the form data, and leave the user hanging. Is HTTP::Request the best way to direct the user and the form data to the appropriate page? This is a vary slightly modified version of the example in the docs, and yet it returns no more data than this in my log, though the script is chmod'd 755 : [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great You are *still* not producing any output... -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with HTTP::Request for POST
On Tuesday, Feb 18, 2003, at 08:43 US/Pacific, Scott Lutz wrote: What I am attempting to do, is do a server side form action redirect based on a regex on a field from the form. [..] [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great Here is the script: #!/usr/bin/perl -wT use strict; use HTTP::Request::Common; use LWP::UserAgent; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; my $ua = LWP::UserAgent-new; if ($q-param(domain) =~ /\.ca$/) { $ua-request(POST 'https://domains/perl/ca_reg.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } else { $ua-request(POST 'https://domains/perl/reg_system.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } Please do not hesitate to contact me directly if you have any more questions! assuming that the above is your script there is the minor problem that it is not sending anything back to the browser which is the 'exit prematurely' argument what you will want to do is send a redirect back to the browser to query the other scripts... the other alternative is to use a piece of javascripting that will resolve this on the client side before sending a request back to the server. you can think of this in terms of say my @targets = qw(ca_reg.cgi ca_system.cgi); my $index = 0; my $jscript = 'script language=JavaScript type=text/javascript !-- function doit(){ var base_uri = https://domains/perl/;; var urls=new Array();' .\n;' foreach my $targ (@targets) { $jscript .= 'urls[' . $index++ . ']=' . $targ . \;\n; } $jscript .= 'var nChosen = document.FormName.sysname.selectedIndex; var wordup = base_uri + urls[nChosen]; document.FormName.action= wordup; document.FormName.method = POST; return true; } //-- /SCRIPT'; my $form = 'form name=FormName action=../ onsubmit=doit() target=_top' # # the part where you stuff in the 'hidden values' you want, # such as the domain,affiliate_id, etc... or put them in # other things that this 'form' would send back # .. If you put that '$jscript' into the head.../head and show your 'form' in the body.../body when you user 'submits' it will go through the 'javascript' to resolve the 'real method' and sent the Post to the two scripts. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with HTTP::Request for POST
On Tuesday, Feb 18, 2003, at 10:33 US/Pacific, Scott Lutz wrote: [..] Thanks for the input drieux! All of the information that I have found has said that you can not change the form action using IE, which is why I was led to the server side method. I will try the javascript, to see how it works! [..] If you really want to go with the server side push, then you will need to do something on the order of: # # stuff that resolves the uri into the form of a GET # print Content-Type: $type . $CRLF . Location: $uri . $CRLF . $CRLF; but I have not figured a way to get that to tell the browser to relocate to the $uri and retransmit the POST data along - have tried a few tricks, none of them worked out. the javascript idea was proposed here a while back, and I was hoping for what you are hoping for, but also it is not really an IE problem, unless it is a problem in pre-IE5 versions, but I do not have any versions of IE prior to 5.2 for Mac... But I can say that the trick I sent you is based upon code I have that works with IE5/IE6(win), Netscape 4, Netscape 6/7 Omniweb, Some times spinning up the javascripting IS the trick. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: help with HTTP::Request for POST
Thanks for the input drieux! All of the information that I have found has said that you can not change the form action using IE, which is why I was led to the server side method. I will try the javascript, to see how it works! Scott Lutz Pacific Online Support Phone: 604.638.6010 Fax: 604.638.6020 Toll Free: 1.877.503.9870 http://www.pacificonline.com -Original Message- From: drieux [mailto:[EMAIL PROTECTED]] Sent: February 18, 2003 10:02 AM To: Scott Lutz Cc: cgi cgi-list Subject: Re: help with HTTP::Request for POST On Tuesday, Feb 18, 2003, at 08:43 US/Pacific, Scott Lutz wrote: What I am attempting to do, is do a server side form action redirect based on a regex on a field from the form. [..] [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great Here is the script: #!/usr/bin/perl -wT use strict; use HTTP::Request::Common; use LWP::UserAgent; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; my $ua = LWP::UserAgent-new; if ($q-param(domain) =~ /\.ca$/) { $ua-request(POST 'https://domains/perl/ca_reg.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } else { $ua-request(POST 'https://domains/perl/reg_system.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } Please do not hesitate to contact me directly if you have any more questions! assuming that the above is your script there is the minor problem that it is not sending anything back to the browser which is the 'exit prematurely' argument what you will want to do is send a redirect back to the browser to query the other scripts... the other alternative is to use a piece of javascripting that will resolve this on the client side before sending a request back to the server. you can think of this in terms of say my @targets = qw(ca_reg.cgi ca_system.cgi); my $index = 0; my $jscript = 'script language=JavaScript type=text/javascript !-- function doit(){ var base_uri = https://domains/perl/;; var urls=new Array();' .\n;' foreach my $targ (@targets) { $jscript .= 'urls[' . $index++ . ']=' . $targ . \;\n; } $jscript .= 'var nChosen = document.FormName.sysname.selectedIndex; var wordup = base_uri + urls[nChosen]; document.FormName.action= wordup; document.FormName.method = POST; return true; } //-- /SCRIPT'; my $form = 'form name=FormName action=../ onsubmit=doit() target=_top' # # the part where you stuff in the 'hidden values' you want, # such as the domain,affiliate_id, etc... or put them in # other things that this 'form' would send back # .. If you put that '$jscript' into the head.../head and show your 'form' in the body.../body when you user 'submits' it will go through the 'javascript' to resolve the 'real method' and sent the Post to the two scripts. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
help with HTTP::Request for POST
This is a vary slightly modified version of the example in the docs, and yet it returns no more data than this in my log : [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great Here is the script: #!/usr/bin/perl -wT use strict; use HTTP::Request::Common; use LWP::UserAgent; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; my $ua = LWP::UserAgent-new; if ($q-param(domain) =~ /\.ca$/) { $ua-request(POST 'https://domains/perl/ca_reg.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } else { $ua-request(POST 'https://domains/perl/reg_system.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } Please do not hesitate to contact me directly if you have any more questions! Cheers, Scott Lutz Pacific Online Support Phone: 604.638.6010 Fax: 604.638.6020 Toll Free: 1.877.503.9870 http://www.pacificonline.com * Manage Your Account Online ! Pacific Online Control Panel http://www.pacificonline.com/customer_support -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with HTTP::Request for POST
on Tue, 18 Feb 2003 00:57:57 GMT, [EMAIL PROTECTED] (Scott Lutz) wrote: This is a vary slightly modified version of the example in the docs, and yet it returns no more data than this in my log : [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great Your program is not outputting anything. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: help with HTTP::Request for POST
Scott Lutz wrote: This is a vary slightly modified version of the example in the docs, and yet it returns no more data than this in my log : [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great [snip script] Premature end of script headers nearly always means incorrect permissions on your script. Try chmod 755. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: help with HTTP::Request for POST
I think I am going to move this over to the CGI list! :o) Scott Lutz Pacific Online Support Phone: 604.638.6010 Fax: 604.638.6020 Toll Free: 1.877.503.9870 http://www.pacificonline.com -Original Message- From: Scott Lutz Sent: February 17, 2003 4:58 PM To: [EMAIL PROTECTED] Subject: help with HTTP::Request for POST This is a vary slightly modified version of the example in the docs, and yet it returns no more data than this in my log : [Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgi Any help with what might be missing would be great Here is the script: #!/usr/bin/perl -wT use strict; use HTTP::Request::Common; use LWP::UserAgent; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; my $ua = LWP::UserAgent-new; if ($q-param(domain) =~ /\.ca$/) { $ua-request(POST 'https://domains/perl/ca_reg.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } else { $ua-request(POST 'https://domains/perl/reg_system.cgi', [ domain = $q-param(domain), affiliate_id = $q-param(affiliate_id), action = $q-param(lookup), ]); } Please do not hesitate to contact me directly if you have any more questions! Cheers, Scott Lutz Pacific Online Support Phone: 604.638.6010 Fax: 604.638.6020 Toll Free: 1.877.503.9870 http://www.pacificonline.com * Manage Your Account Online ! Pacific Online Control Panel http://www.pacificonline.com/customer_support -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]