ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-web
perl-win32-web
HTTP request arguments/content
by Marijn Pessers other posts by this author
Jan 29 2007 6:48AM messages near this date
view in the new Beta List Site
Re: Trying to Send mail | Re: HTTP request arguments/content
Hello,

 

I have been trying to open a html page in perl. It works but I can't send
the correct arguments (post values) with it to work.

 

Here is the code:

 

[begin snippet]

.

my $browser = LWP::UserAgent-> new;

.

sub get_page_http($$$$$;$){

  my $browser  = shift;

  my $remote  = shift || 'localhost';

  my $path    = shift;

  my $leverancier_nr = shift;

  my $FMnummer = shift;

  my $datastring = shift || '';#### raw datastring

  

  my $res;

  

  log_print "get_page: $remote:$path ($datastring)\n";

  

  my $ua = LWP::UserAgent-> new();

  my $url = new URI::URL($remote.$path);

  <some code to define the content length> 

  my $hdrs = new HTTP::Headers('Content-Length' =>  $content_length);

  my @arg = ('submit_waarde' =>  '', 'page' => 'zks1', 'submit_waarde' => '',
'leverancier_nr' =>  $leverancier_nr, 'FMnummer' => $FMnummer);

  my $retry=1;

  while($retry){

    my $formpost= HTTP::Request-> new('POST', $url, $hdrs, @arg);

$res = $browser-> request($formpost);

          if($res-> is_error){

            $retry++;

            if($retry> 2){

              $retry=0;

              ####only try twice

            }

          }

          $retry=0;

  }

  if (wantarray){

    #my($header,$html_body)=split /$BLANK/,$res-> content,2;

    return ($res-> headers,$res->content);

  }else{

    return $res-> content;

  }

}

[end snippet]

 

The problem is that I can not get the post arguments correctly. I have been
trying to put them in the header of using message in the HTTP::Message
class.

  .

  my $mssg = HTTP::Message-> new;

  .

 

Can you tell me how to post the post values?

 

Greetings,

 

Marijn Pessers

 
Thread:
Marijn Pessers
Bill Luebkert
Marijn Pessers
David Landgren
Bill Luebkert

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved