Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

perl: useragent - need to remove all headers from GET

Posted on 2004-04-28
4
Medium Priority
?
355 Views
Last Modified: 2008-03-06
I need to get only the content of the file I'm getting, I don't want any headers.

Example, although this doesn't seem to work:

$ua = LWP::UserAgent->new;
$request = HTTP::Request->new('GET',$url);
$request->authorization_basic($username_server, $password_server);
$data = $response->content()->as_string;

Any help would be much appreciated.

Thank you very much.

Best regards,

Dr34m3r
0
Comment
Question by:dr34m3rs
4 Comments
 
LVL 1

Assisted Solution

by:pillaib
pillaib earned 332 total points
ID: 10937192
Hi Friend,

I got something from Google...

Try this,
http://www.oreilly.com/openbook/webclient/ch06.html#33831

Good Luck,
PB
0
 
LVL 18

Accepted Solution

by:
kandura earned 336 total points
ID: 10937371
$data = $response->content;
should give you only the body of the response, not the headers.

Maybe you should check whether the request was successful:

# check the outcome
  if ($response->is_success) {
     print $response->content;
  }
  else {
     print "Error: " . $response->status_line . "\n";
  }

0
 
LVL 20

Assisted Solution

by:jmcg
jmcg earned 332 total points
ID: 10939464
It looks like you left out the line that actually performs the GET request and puts the result in $response.

my $response = $ua->request( $request);

0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 10942156
Hey thank you for your responses. I went another way and went through the POST method. That worked great. But for the future all your answers helped, so I am going to split the points.

Thank you everyone :)

Dr34m3r
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question