I'm having trouble getting my curl to post correctly with WWW::Curl, or at least having trouble mimicking the -d command line option.
The following shows the command line example that works using -k to turn off cert checking and -d to send the post arguments
(Command Line Example that works) shell#curl -d 'level=2&pass=password&hsam_timeout=20' -k https://1.1.1 +.1/auth AUTH: OK SESSION: 4221231856 (EXAMPLE TEST with module distro t/new/06http-post.t) $curl->setopt( CURLOPT_URL, $ENV{CURL_TEST_URL} ); $curl->setopt( CURLOPT_READFUNCTION, \&read_callback ); $curl->setopt( CURLOPT_INFILESIZE, $max ); $curl->setopt( CURLOPT_UPLOAD, 1 ); $curl->setopt( CURLOPT_CUSTOMREQUEST, 'POST' ); my $code = $curl->perform; (My code that also turns off the ssl check) $curl->setopt( CURLOPT_URL,'https://1.1.1.1/auth?level=2&pass=password +&hsam_timeout=20' ); $curl->setopt( CURLOPT_READFUNCTION, \&read_callback ); $curl->setopt( CURLOPT_INFILESIZE, $max ); $curl->setopt( CURLOPT_UPLOAD, 1 ); $curl->setopt( CURLOPT_CUSTOMREQUEST, 'POST' ); $curl->setopt(CURLOPT_SSL_VERIFYPEER,0); $curl->setopt(CURLOPT_SSL_VERIFYHOST,0); my $code = $curl->perform;
Any ideas if I am doing this wrong? Do I need to use the following options instead?
$curl->setopt( CURLOPT_POST, 1); $curl->setopt( CURLOPT_POSTFIELDSIZE, 100); $curl->setopt( CURLOPT_POSTFIELDS, "level=2&pass=password&hsam_timeout +=20");

Here is the error I'm getting:
> POST /auth?level=2&pass=password&hsam_timeout=20 HTTP/1.1 Host: 10.2.200.101 Accept: */* Content-Length: 100 Expect: 100-continue < HTTP/1.1 417 Expectation Failed < Connection: close < Content-Length: 0 < Date: Tue, 19 May 2009 02:16:25 GMT < Server: httpd < * Closing connection #0

In reply to Correct way to POST with Perl Curl? by josh803316

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.