in reply to Re: Crypt::SSLeay performing a HTTP POST
in thread Crypt::SSLeay performing a HTTP POST

Thanks. I do not see a use Crypt::SSLeay line. Is there a clear definition of the parameters to be passed in the post. I understand it will be dependent upon the number of fields on the page to complete, but I am confused on what other parameters are required versus optional. For example - language.

  • Comment on Re^2: Crypt::SSLeay performing a HTTP POST

Replies are listed 'Best First'.
Re^3: Crypt::SSLeay performing a HTTP POST
by almut (Canon) on Jun 04, 2010 at 17:20 UTC
    I do not see a use Crypt::SSLeay line.

    That's why I supplied the strace as 'proof' :) — Crypt::SSLeay is loaded automatically for HTTPS requests.

    Is there a clear definition of the parameters to be passed in the post...

    That's entirely site/URI-dependent. I just made a request using Firefox and traced it using the "Live HTTP Headers" addon to see what's being sent.

      So how dows LWP know to use Crypt::SSLeay? Becasue of the HTTPS in the URL? How does it know how to find my openSSL DDL files? I did add the square brackets.

        Becasue of the HTTPS in the URL?

        Yes.

        How does it know how to find my openSSL DDL files?

        It requires the respective SSL module when needed (see LWP::Protocol::https10 for details). The XS part of the module (the .dll) subsequently loads the other 3rd-party DLLs it depends on according to how it has been linked. How exactly this happens is more a question of the dynamic linker of the OS  (Windows isn't my field of expertise, so I can't tell you the details...)

      Thanks! I think I am starting to understand. Below is my code. It hangs during the post and I am sure that it is incorrect, but do not know why. In poking around the documentation, it shows the URL:PORT which in my case is 443. I am believing that LWP is actually attempting a HTTP post to the URL on port 443 - but I need it to do a HTTPS post. I believe this because when I open a browser with the same URL:443, it hangs as well. I installed OpenSSL to its own directory, but see no mention that it is being accessed via LWP.

      require 'c:\ken2\config.pl'; use strict; use warnings; use LWP::UserAgent; use Crypt::SSLeay; my $url = "https://secure_URL_here/"; print "$url\n"; my $port = 443; my $lwp = LWP::UserAgent->new( ); print "here\n"; my $response = $lwp->post("$url:443", DATA=>our $USER, DATA=>our $PASS + ); if($response->is_success){ print $response->content; } else{ print $response->status_line, "\n"; }

        I'd use Wireshark to see what's sent across the wire.

        Also, as I already mentioned yesterday, you need square brackets [ DATA=>our $USER, DATA=>our $PASS ]  (LWP needs them to disambiguate HTTP headers from HTML form key/value pairs).

        You do not need this port 443 stuff. That IS the standard port for HTTPS, Port Numbers - IANA — Internet Assigned Numbers Authority. I would take that out just to simplify things - don't repeat defaults...that's why there are defaults!

        See almuts post at Re: Crypt::SSLeay performing a HTTP POST again. "DATA=>our $USER, DATA=>our $PASS" is wrong. (1) Each field that you supply information for will have a unique name, two fields can't both be called "DATA". (2) I doubt that this is the place for a Perl scoping declaration like "our,my,local". If a syntax won't "fly" in a hash table definition, it won't "fly" in a POST. At the end of the day, your LWP thing is going to supply "field,value" pairs. This '=>' operator is called a "fat comma" and what is on the left has to be unique and what is on the right has to be valid just like you were defining a hash.