Solved

perl: useragent - need to remove all headers from GET

Posted on 2004-04-28
4
348 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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.…
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…

856 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