Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

perl: useragent - need to remove all headers from GET

Posted on 2004-04-28
4
Medium Priority
?
354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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

722 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