IO::All::LWP(3pm)
๐ IO::All::LWP ๐
okay so bestie, this is the IO::All::LWP page from the User Contributed Perl Documentation section โ it's the little glue module that lets IO::All do its thing over the network, and honestly? it's giving main character energy. โจ
โจ NAME โจ
IO::All::LWP โ the IO::All interface to LWP, no cap ๐ซถ
๐ธ SYNOPSIS ๐ธ
use IO::All;
"hello world\n" > io('ftp://localhost/test/x'); # save to FTP
$content < io('http://example.org'); # GET webpage
io('http://example.org') > io('index.html'); # save webpage
like. look at that. three lines and you're on the internet. iconic behavior fr fr ๐
๐ฆ DESCRIPTION ๐ฆ
So this module is literally the glue between IO::All and LWP, which means you can read and write files through the network using that super cute <IO:All> interface you already know and love. ๐
But here's the thing โ you do not use this module directly. Nope. You just use IO::All, and it's smart enough to know when to autoload IO::All::HTTP, IO::All::HTTPS, IO::All::FTP, or IO::All::Gopher, which are the ones actually implementing the specific protocols, all built on top of IO::All::LWP. it's giving delegation, it's giving teamwork ๐
๐ฅ EXECUTION MODEL ๐ฅ
GET requests ๐
When the IO::All object gets opened, the URI is fetched and stored by the object in an internal file handle. After that you can access it like literally any other file, using all the IO::All methods and operators, and yeah it can be tied and everything. slay.
PUT requests ๐ฎ
When the IO::All object gets opened, an internal file handle is created. You can write to that file handle with all your fave IO::All methods and operators, and it can be tied too, etc. And if $io->put is not called explicitly? then when the IO::All object is closed โ either explicitly via $io->close or automatically upon destruction โ the actual PUT request is made. surprise! it was queued the whole time ๐
the bad news ๐ญ
The whole file is stored in memory after getting it or before putting it. So if you're dealing with multi-gigabyte files, that may cause problems. multi. gigabyte. bestie. your RAM is NOT ready. ๐
๐ METHODS ๐
The simplest way of doing things is via the overloaded operators > and <, like in the SYNOPSIS. They handle automatically opening and closing the files and connections as needed. effortless. but if you want a finer degree of control, there's a whole methods menu:
This is a subclass of IO::All. On top of the inherited methods, you also get:
uaโ set or get the user agent object (LWP::UserAgentor a subclass). If you call it with a list, that list gets passed toLWP::UserAgent->new. If you call it with an object, that object is used directly as the user agent. And ngl, there's a default user agent if you don't specify one, so you're never left hanging. ๐uriโ set or get the URI. It can take either a URI object or a string, and it returns a URI object. Heads up though: calling this method overrides theuserandpasswordfields, because URIs can contain authentication information. the way that it just takes over like that ๐ณuserโ set or get the user name for authentication. and remember, the user name (and the password too) can also be set as part of the URL, like"http://me:secret@example.com/". sneaky and convenient ๐passwordโ set or get the password for authentication. and again, the password can also be set as part of the URL, as discussed above. (yes bestie, we talked about this one line ago ๐)getโ GET the current URI usingLWP. Or, if you call it with anHTTP::Requestobject as a parameter, it does that request instead. It returns theHTTP::Responseobject.putโ PUT to the current URI usingLWP. If called with anHTTP::Requestobject, it does that request instead. If called with a scalar, it PUTs that as the content to the current URI, instead of the current accumulated content. choose your own adventure โจresponseโ return theHTTP::Responseobject. that's it. that's the whole job. we respect it.requestโ does anLWPrequest. It requires anHTTP::Requestobject as a parameter. Returns anHTTP::Responseobject. no parameter? no request. rules are rules.openโ overrides theopenmethod fromIO::All. It takes care of GETting the content, or of setting up the internal buffer for PUTting. And just like theopenmethod fromIO::All, it can take a mode:<for GET and>for PUT. ๐closeโ overrides theclosemethod fromIO::All. It takes care of PUTting the content. the grand finale ๐
๐ง DEPENDENCIES ๐ง
This module uses LWP for all the heavy lifting (it's the muscle ๐ช). It also requires perl-5.8.0 or a more recent version. so like, vintage perl is fine, but not that vintage.
โญ SEE ALSO โญ
IO::All, LWP, IO::All::HTTP, IO::All::FTP. go read those too bestie, iykyk ๐
๐ AUTHORS ๐
Ivan Tubert-Brohman <itub@cpan.org> and Brian Ingerson <ingy@cpan.org>
Thanks to Sergey Gleizer for the ua method. ๐ซถ
๐ธ COPYRIGHT ๐ธ
Copyright (c) 2007. Ivan Tubert-Brohman and Brian Ingerson. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
and that's the whole page, bestie! this one's running onperl v5.32.0and it was last touched on2021-01-04โ shoutout to theIO::All::LWP(3pm)era. stay networked, stay hydrated, and pls don't load a multi-gigabyte file into memory. mwah ๐โจ
๐ฆ where this page comes from
- debian bookworm: libio-all-lwp-perl 0.14-2.1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libio-all-lwp-perl 0.14-2.1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libio-all-lwp-perl 0.14-2.1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libio-all-lwp-perl 0.14-2.1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libio-all-lwp-perl 0.14-2.1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libio-all-lwp-perl 0.14-2.1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms