Hi,
     I sent wrong code before. Take a look at this one.
I am trying to write a script in Perl to go outside the firewall and
access a site.

When I use a GET method, it works fine, but when I use POST, I am not able
to go outside the firewall. I am using a socks server to go outside the
firewall. Its giving me Error 500, "A connection with a remote socket was
reset by that socket." Could you please let me know if I am doing anything
wrong here. The code in question is highlighted in blue. Thanks in Advance.

 And here is part of the code, I was talking about.

    if( $shippers{ $shipper }->[ 0 ] =~ /get/i )
    {
      my $url, %data, $url, $response;
      my $userAgent = new LWP::UserAgent();

      $url = $shippers{ $shipper }->[ 1 ];

      $userAgent->proxy(['http','ftp'] => 'http://socks:1080');
      my $req = GET( $url, \%data );

      $response = $userAgent->request( $req );

      if( $response->is_error() )
      {        if( defined( $errorurl ) )
          {
               print "Location: ", $errorurl, "\n\n";
          }
      }

      # Send user to appropriate page.
      print "Location: ", $shippers{ $shipper }->[ 1 ], "\n\n";
    }
    elsif( $shippers{ $shipper }->[ 0 ] =~ /post/i )
    {
      my $url, %data, $dataString, $rest, @values, $key, $value, $response;
      my $userAgent = new LWP::UserAgent();

      # Get url.
      $url = $shippers{ $shipper }->[ 1 ];

      # Create a hash with appropriate key=value pairs based on the string.

      @values = split( /\&/, $shippers{ $shipper }->[ 2 ] );

      foreach $thing ( @values )
      {
        ( $key, $value ) = split( /=/, $thing );
        $value =~ s/\%3D\%/=/g;
        $data{ $key } = $value;
      }

      $userAgent->proxy(['http','ftp'] => 'http://socks:1080' );

      # Create a POST request.
      my $req = POST( $url, \%data );
      $response = $userAgent->request( $req );
      if( $response->is_error() )
      {   if( defined( $errorurl ) )
     {
               print "Location: ", $errorurl, "\n\n";
               print "error = ", $response->error_as_HTML;
          }
        exit( 0 );
      }
      $content = $response->as_string;


Praveen Tatineni
Esites Development
526 9828 (T/L)
919 486 9828 (External)
RTP, NC


Reply via email to