I have a script that I need to run which posts to a URL in order to retrieve a value. Encrypted strings are being passed, and decrypted ones are being returned. LWP has proven to be an inefficient (load/response-time) option, and so the next option is Curl. The issue is that no matter what I do, I am unable to suppress the headers from Curl. I need to just get the body of the response, not the headers. I have tried to do $curl->setopt(CURLOPT_HEADER, 0); with no success. Please see the code, and offer suggestions as to what I may do to resolve this issue.
#! /usr/bin/perl -w #"real" data changed to protect the guilty use strict; use WWW::Curl::Easy; use URI::Escape; my $curl = new WWW::Curl::Easy; my @strings = ("Encrypted String #1", "Encrypted String #2"); foreach my $encrypted (@strings) { my $query_string = "?action=decrypt&string=" . uri_escape($encrypte +d); $curl->setopt(CURLOPT_VERBOSE, 0); $curl->setopt(CURLOPT_HEADER, 0); $curl->setopt(CURLOPT_URL, 'https://www.somedomain.com/somescript.p +hp' . $query_string); # Starts the actual request $curl->perform; print "\n=-----------------------------------------=\n"; }
Here is a sample of the response I am getting back:
HTTP/1.1 200 OK Date: Thu, 29 May 2008 17:25:29 GMT Server: Apache/1.3.34 Ben-SSL/1.57 (Unix) PHP/4.4.2 X-Powered-By: PHP/4.4.2 Set-Cookie: PHPSESSID=716b50edcfb0291d088317c537f629ee; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre- +check=0 Pragma: no-cache Transfer-Encoding: chunked Content-Type: text/html string #1 =---------------------------------------------= HTTP/1.1 200 OK Date: Thu, 29 May 2008 17:25:29 GMT Server: Apache/1.3.34 Ben-SSL/1.57 (Unix) PHP/4.4.2 X-Powered-By: PHP/4.4.2 Set-Cookie: PHPSESSID=5a6b5de6dc36e01617a05b7bdbf8f384; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre- +check=0 Pragma: no-cache Transfer-Encoding: chunked Content-Type: text/html string #2 =---------------------------------------------=
Any thoughts on getting rid of those pesky headers?

In reply to Cannot suppress Curl headers by RSI_Don

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.