Solved

perl: useragent - need to remove all headers from GET

Posted on 2004-04-28
4
345 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 83 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 84 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 83 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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