Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

CGI - POST - newbie
Hello everyone,

I am a newbie to the world of CGI/Perl. I have a following situation.
Running apache 2.0.43 - wrote a perl script that does the following..

exerpt from post.pl file

my $form = [ "USER"    => $userId,
"username"  => $username,
"partition" => $partition,
"itemID" => $itemID,
"page" => $page]

my $myURL = "http://myhost.com";

my $userAgent = new LWP::UserAgent();

my $request = HTTP::Request::Common::POST($myURL, $form);
my $response = $userAgent->request($request);
my $responseString = $response->as_string;
print $responseString;

Everything is happy accept that with HTTP POST - I do not get
redirected to the resulting page -  I still stay on post.pl file.

If you post to any page - you should ideally get redirected to where
you posted to.

Am I doing anything wrong here? How can I get around this problem?

Thanks

Jaimin

Report this thread to moderator Post Follow-up to this message
Old Post
Just Curious
08-27-04 08:56 PM


Re: CGI - POST - newbie

Just Curious wrote:
>
> I am a newbie to the world of CGI/Perl.

If you are new to CGI, HTML, HTTP and Perl all at the same time you will
need to work extra hard to be sure which one you are dealing with at any
given moment.  Not only is it a vital first step to solving problems for
yourself but it also creates bad feeling if you post a pure CGI
question to a Perl newsgroup or vice versa.

> I have a following situation.
> Running apache 2.0.43 - wrote a perl script that does the following..
>
> exerpt from post.pl file
>
> my $form = [ "USER"    => $userId,
>                  "username"  => $username,
>                  "partition" => $partition,
>                  "itemID" => $itemID,
>                  "page" => $page]
>
> my $myURL = "http://myhost.com";
>
>     my $userAgent = new LWP::UserAgent();
>
>     my $request = HTTP::Request::Common::POST($myURL, $form);
>     my $response = $userAgent->request($request);
>     my $responseString = $response->as_string;
>     print $responseString;
>
> Everything is happy accept that with HTTP POST - I do not get
> redirected to the resulting page -  I still stay on post.pl file.

You appear to be confusing CGI and LWP.

LWP is a web client written on Perl.  It communicated with a web server
elsewhere using HTTP.

CGI is an API used to communicate between an web server process and a
script providing dynamic content on that server.  The Perl module also
called CGI is a Perl wrapper for the CGI API.

> If you post to any page - you should ideally get redirected to where
> you posted to.

If the remote server at myhost.com is responding with a redirect then
maybe you could catch that and pass it on (but you'd have to tell
LWP::UserAgent not to try to follow the redirect first).  If the
redirect is relative you'd need to make it absolute.

> Am I doing anything wrong here?

It is possible that you have completely the wrong mental model of the
HTTP cycle.

> How can I get around this problem?

You would need to learn about HTTP (this has nothing to do with Perl or
CGI).

You may find the Content-Location header helps.  Then again you may not.


Report this thread to moderator Post Follow-up to this message
Old Post
Brian McCauley
08-27-04 08:56 PM


Re: CGI - POST - newbie

Just Curious wrote:
>
> I am a newbie to the world of CGI/Perl.

If you are new to CGI, HTML, HTTP and Perl all at the same time you will
need to work extra hard to be sure which one you are dealing with at any
given moment.  Not only is it a vital first step to solving problems for
yourself but it also creates bad feeling if you post a pure CGI
question to a Perl newsgroup or vice versa.

> I have a following situation.
> Running apache 2.0.43 - wrote a perl script that does the following..
>
> exerpt from post.pl file
>
> my $form = [ "USER"    => $userId,
>                  "username"  => $username,
>                  "partition" => $partition,
>                  "itemID" => $itemID,
>                  "page" => $page]
>
> my $myURL = "http://myhost.com";
>
>     my $userAgent = new LWP::UserAgent();
>
>     my $request = HTTP::Request::Common::POST($myURL, $form);
>     my $response = $userAgent->request($request);
>     my $responseString = $response->as_string;
>     print $responseString;
>
> Everything is happy accept that with HTTP POST - I do not get
> redirected to the resulting page -  I still stay on post.pl file.

You appear to be confusing CGI and LWP.

LWP is a web client written on Perl.  It communicated with a web server
elsewhere using HTTP.

CGI is an API used to communicate between an web server process and a
script providing dynamic content on that server.  The Perl module also
called CGI is a Perl wrapper for the CGI API.

> If you post to any page - you should ideally get redirected to where
> you posted to.

If the remote server at myhost.com is responding with a redirect then
maybe you could catch that and pass it on (but you'd have to tell
LWP::UserAgent not to try to follow the redirect first).  If the
redirect is relative you'd need to make it absolute.

> Am I doing anything wrong here?

It is possible that you have completely the wrong mental model of the
HTTP cycle.

> How can I get around this problem?

You would need to learn about HTTP (this has nothing to do with Perl or
CGI).

You may find the Content-Location header helps.  Then again you may not.


Report this thread to moderator Post Follow-up to this message
Old Post
Brian McCauley
09-03-04 01:57 PM


Re: CGI - POST - newbie
Gee whiz!
How about this simple script below?

use LWP::UserAgent;
use HTTP::Request;



"Brian McCauley" <nobull@mail.com> wrote in message
news:cgnotl$sfs$1@sun3.bham.ac.uk...
>
>
> Just Curious wrote: 
>
> If you are new to CGI, HTML, HTTP and Perl all at the same time you will
> need to work extra hard to be sure which one you are dealing with at any
> given moment.  Not only is it a vital first step to solving problems for
>   yourself but it also creates bad feeling if you post a pure CGI
> question to a Perl newsgroup or vice versa.
> 
>
> You appear to be confusing CGI and LWP.
>
> LWP is a web client written on Perl.  It communicated with a web server
> elsewhere using HTTP.
>
> CGI is an API used to communicate between an web server process and a
> script providing dynamic content on that server.  The Perl module also
> called CGI is a Perl wrapper for the CGI API.
> 
>
> If the remote server at myhost.com is responding with a redirect then
> maybe you could catch that and pass it on (but you'd have to tell
> LWP::UserAgent not to try to follow the redirect first).  If the
> redirect is relative you'd need to make it absolute.
> 
>
> It is possible that you have completely the wrong mental model of the
> HTTP cycle.
> 
>
> You would need to learn about HTTP (this has nothing to do with Perl or
> CGI).
>
> You may find the Content-Location header helps.  Then again you may not.
>



Report this thread to moderator Post Follow-up to this message
Old Post
BG
09-09-04 08:57 PM


Re: CGI - POST - newbie
Gee whiz!


Jaimin: How about this very simple script below?

use LWP::UserAgent;
use HTTP::Request;

my $userAgent = new LWP::UserAgent();
my $res = $userAgent->post( $myURL,
'Content-Type' => "bla bla bla",
Content => [ 'USER' => $userId, 'username' =>
$username, etc.                 ]  );

$response->as_string;

BG

"Brian McCauley" <nobull@mail.com> wrote in message
news:cgnotl$sfs$1@sun3.bham.ac.uk...
>
>
> Just Curious wrote: 
>
> If you are new to CGI, HTML, HTTP and Perl all at the same time you will
> need to work extra hard to be sure which one you are dealing with at any
> given moment.  Not only is it a vital first step to solving problems for
>   yourself but it also creates bad feeling if you post a pure CGI
> question to a Perl newsgroup or vice versa.
> 
>
> You appear to be confusing CGI and LWP.
>
> LWP is a web client written on Perl.  It communicated with a web server
> elsewhere using HTTP.
>
> CGI is an API used to communicate between an web server process and a
> script providing dynamic content on that server.  The Perl module also
> called CGI is a Perl wrapper for the CGI API.
> 
>
> If the remote server at myhost.com is responding with a redirect then
> maybe you could catch that and pass it on (but you'd have to tell
> LWP::UserAgent not to try to follow the redirect first).  If the
> redirect is relative you'd need to make it absolute.
> 
>
> It is possible that you have completely the wrong mental model of the
> HTTP cycle.
> 
>
> You would need to learn about HTTP (this has nothing to do with Perl or
> CGI).
>
> You may find the Content-Location header helps.  Then again you may not.
>



Report this thread to moderator Post Follow-up to this message
Old Post
BG
09-09-04 08:57 PM


Re: CGI - POST - newbie
Gee whiz!


Jaimin: How about this very simple script below?

use LWP::UserAgent;
use HTTP::Request;

my $userAgent = new LWP::UserAgent();
my $res = $userAgent->post( $myURL,
'Content-Type' => "bla bla bla",
Content => [ 'USER' => $userId, 'username' =>
$username, etc.                 ]  );

$response->as_string;

BG

"Brian McCauley" <nobull@mail.com> wrote in message
news:cgnotl$sfs$1@sun3.bham.ac.uk...
>
>
> Just Curious wrote: 
>
> If you are new to CGI, HTML, HTTP and Perl all at the same time you will
> need to work extra hard to be sure which one you are dealing with at any
> given moment.  Not only is it a vital first step to solving problems for
>   yourself but it also creates bad feeling if you post a pure CGI
> question to a Perl newsgroup or vice versa.
> 
>
> You appear to be confusing CGI and LWP.
>
> LWP is a web client written on Perl.  It communicated with a web server
> elsewhere using HTTP.
>
> CGI is an API used to communicate between an web server process and a
> script providing dynamic content on that server.  The Perl module also
> called CGI is a Perl wrapper for the CGI API.
> 
>
> If the remote server at myhost.com is responding with a redirect then
> maybe you could catch that and pass it on (but you'd have to tell
> LWP::UserAgent not to try to follow the redirect first).  If the
> redirect is relative you'd need to make it absolute.
> 
>
> It is possible that you have completely the wrong mental model of the
> HTTP cycle.
> 
>
> You would need to learn about HTTP (this has nothing to do with Perl or
> CGI).
>
> You may find the Content-Location header helps.  Then again you may not.
>



Report this thread to moderator Post Follow-up to this message
Old Post
BG
09-12-04 08:55 PM


Re: CGI - POST - newbie
Gee whiz!
How about this simple script below?

use LWP::UserAgent;
use HTTP::Request;



"Brian McCauley" <nobull@mail.com> wrote in message
news:cgnotl$sfs$1@sun3.bham.ac.uk...
>
>
> Just Curious wrote: 
>
> If you are new to CGI, HTML, HTTP and Perl all at the same time you will
> need to work extra hard to be sure which one you are dealing with at any
> given moment.  Not only is it a vital first step to solving problems for
>   yourself but it also creates bad feeling if you post a pure CGI
> question to a Perl newsgroup or vice versa.
> 
>
> You appear to be confusing CGI and LWP.
>
> LWP is a web client written on Perl.  It communicated with a web server
> elsewhere using HTTP.
>
> CGI is an API used to communicate between an web server process and a
> script providing dynamic content on that server.  The Perl module also
> called CGI is a Perl wrapper for the CGI API.
> 
>
> If the remote server at myhost.com is responding with a redirect then
> maybe you could catch that and pass it on (but you'd have to tell
> LWP::UserAgent not to try to follow the redirect first).  If the
> redirect is relative you'd need to make it absolute.
> 
>
> It is possible that you have completely the wrong mental model of the
> HTTP cycle.
> 
>
> You would need to learn about HTTP (this has nothing to do with Perl or
> CGI).
>
> You may find the Content-Location header helps.  Then again you may not.
>



Report this thread to moderator Post Follow-up to this message
Old Post
BG
09-14-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:51 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.