Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Disable LWP::Simple's autodeflating?

by Anonymous Monk
on Jan 31, 2013 at 04:35 UTC ( #1016203=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

A quick question. My LWP::Simple autodeflates .tar.gz files. How do I tell it to stop doing that?

$ ls -ln /cpan/authors/id/P/PM/PMQS/Compress-Raw-Zlib-2.060.tar.gz 
-rw-r--r-- 1 1000 1000 236107 Jan  8 03:02 /cpan/authors/id/P/PM/PMQS/Compress-Raw-Zlib-2.060.tar.gz

$ perl -MLWP::Simple -MFile::Slurp -e'write_file("Compress-Raw-Zlib-2.060.tar.gz", get("file:/cpan/authors/id/P/PM/PMQS/Compress-Raw-Zlib-2.060.tar.gz"))'; ls -ln Compress-Raw-Zlib-2.060.tar.gz
-rw-r--r-- 1 1000 1000 952320 Jan 31 11:32 Compress-Raw-Zlib-2.060.tar.gz

Comment on Disable LWP::Simple's autodeflating?
Re: Disable LWP::Simple's autodeflating? (use mirror)
by Anonymous Monk on Jan 31, 2013 at 04:40 UTC
    use mirror
      Please don't reinterpret the question by looking at the example. I specifically asked on how to disable that particular LWP::Simple's behavior. This behavior is not seen if I use LWP::UserAgent.

        Please don't reinterpret the question by looking at the example. I specifically asked on how to disable that particular LWP::Simple's behavior. This behavior is not seen if I use LWP::UserAgent.

        UTSL, go to LWP::Simple and look at the source (and the docs) -- LWP::Simple is simple, it is not customizable, there is no configuration option that you can use

Reaped: Delete:Accidental dup
by NodeReaper (Curate) on Jan 31, 2013 at 06:57 UTC
Re: Disable LWP::Simple's autodeflating?
by BrowserUk (Pope) on Jan 31, 2013 at 07:00 UTC

    Three possibilities:

    1. If you want the contents in a file, use getstore instead of get and writing it out yourself:
      perl -MLWP::Simple -e'getstore("file:/cpan/authors/id/P/PM/PMQS/Compre +ss-Raw-Zlib-2.060.tar.gz", "Compress-Raw-Zlib-2.060.tar.gz" )'
    2. Patch your copy of LWP::Simple with a new method (say: getRaw() ) that returns the content rather than the decoded content::
      sub getRaw ($) { my $response = $ua->get(shift); ## return $response->decoded_content if $response->is_success; return $response->content if $response->is_success; return undef; }
    3. use lwp-download [-a] <url> [<local path>]:
      lwp-download file:/cpan/authors/id/P/PM/PMQS/Compress-Raw-Zlib-2.060.t +ar.gz

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks, BrowserUK, especially for point #2. I decided to go with LWP::UserAgent.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1016203]
Approved by talexb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2014-11-27 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (180 votes), past polls