Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

IO::All::LWP
IO::All interface to LWP

IO::All::LWP - IO::All interface to LWP


NAME

IO::All::LWP - IO::All interface to LWP


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


DESCRIPTION

This module acts as glue between the IO::All manpage and LWP, so that files can be read and written through the network using the convenient IO:All interface. Note that this module is not used directly: you just use the IO::All manpage, which knows when to autoload the IO::All::HTTP manpage, the IO::All::HTTPS manpage, the IO::All::FTP manpage, or the IO::All::Gopher manpage, which implement the specific protocols based on the IO::All::LWP manpage.


EXECUTION MODEL

GET requests. When the IO::All object is opened, the URI is fetched and stored by the object in an internal file handle. It can then be accessed like any other file via the IO::All methods and operators, it can be tied, etc.

PUT requests. When the IO::All object is opened, an internal file handle is created. It is possible to that file handle using the various IO::All methods and operators, it can be tied, etc. If $io->put is not called explicitly, when the IO::All object is closed, either explicitly via $io->close or automatically upon destruction, the actual PUT request is made.

The bad news is that the whole file is stored in memory after getting it or before putting it. This may cause problems if you are dealing with multi-gigabyte files!


METHODS

The simplest way of doing things is via the overloaded operators > and <, as shown in the SYNOPSIS. These take care of automatically opening and closing the files and connections as needed. However, various methods are available to provide a finer degree of control.

This is a subclass of the IO::All manpage. In addition to the inherited methods, the following methods are available:

  • ua
  • Set or get the user agent object (the LWP::UserAgent manpage or a subclass). If called with a list, the list is passed to LWP::UserAgent->new. If called with an object, the object is used directly as the user agent. Note that there is a default user agent if no user agent is specified.

  • uri
  • Set or get the URI. It can take either a URI object or a string, and it returns an URI object. Note that calling this method overrides the user and password fields, because URIs can contain authentication information.

  • user
  • Set or get the user name for authentication. Note that the user name (and the password) can also be set as part of the URL, as in ``http://me:secret@example.com/''.

  • password
  • Set or get the password for authentication. Note that the password can also be set as part of the URL, as discussed above.

  • get
  • GET the current URI using LWP. Or, if called with an the HTTP::Request manpage object as a parameter, it does that request instead. It returns the the HTTP::Response manpage object.

  • put
  • PUT to the current URI using LWP. If called with an the HTTP::Request manpage object, 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.

  • response
  • Return the the HTTP::Response manpage object.

  • request
  • Does an LWP request. It requires an the HTTP::Request manpage object as a parameter. Returns an the HTTP::Response manpage object.

  • open
  • Overrides the open method from the IO::All manpage. It takes care of GETting the content, or of setting up the internal buffer for PUTting. Just like the open method from the IO::All manpage, it can take a mode: '<' for GET and '>' for PUT.

  • close
  • Overrides the close method from the IO::All manpage. It takes care of PUTting the content.


DEPENDENCIES

This module uses LWP for all the heavy lifting. It also requires perl-5.8.0 or a more recent version.


SEE ALSO

the IO::All manpage, LWP, the IO::All::HTTP manpage, the IO::All::FTP manpage.


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

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy