Coder Social home page Coder Social logo

http-tinyish's Introduction

NAME

HTTP::Tinyish - HTTP::Tiny compatible HTTP client wrappers

SYNOPSIS

my $http = HTTP::Tinyish->new(agent => "Mozilla/4.0");

my $res = $http->get("http://www.cpan.org/");
warn $res->{status};

$http->post("http://example.com/post", {
    headers => { "Content-Type" => "application/x-www-form-urlencoded" },
    content => "foo=bar&baz=quux",
});

$http->mirror("http://www.cpan.org/modules/02packages.details.txt.gz", "./02packages.details.txt.gz");

DESCRIPTION

HTTP::Tinyish is a wrapper module for HTTP client modules LWP, HTTP::Tiny and HTTP client software curl and wget.

It provides an API compatible to HTTP::Tiny, and the implementation has been extracted out of App::cpanminus. This module can be useful in a restrictive environment where you need to be able to download CPAN modules without an HTTPS support in built-in HTTP library.

BACKEND SELECTION

Backends are searched in the order of: LWP, HTTP::Tiny, curl and wget. HTTP::Tinyish will auto-detect if the backend also supports HTTPS, and use the appropriate backend based on the given URL to the request methods.

For example, if you only have HTTP::Tiny but without SSL related modules, it is possible that:

my $http = HTTP::Tinyish->new;

$http->get("http://example.com");  # uses HTTP::Tiny
$http->get("https://example.com"); # uses curl

COMPATIBILITIES

All request related methods such as get, post, put, delete, request, patch and mirror are supported.

LWP

  • LWP backend requires LWP 5.802 or over to be functional, and LWP::Protocol::https to send HTTPS requests.
  • mirror method doesn't consider third options hash into account (i.e. you can't override the HTTP headers).
  • proxy is automatically detected from environment variables.
  • timeout, max_redirect, agent, default_headers and verify_SSL are translated.

HTTP::Tiny

Because the actual HTTP::Tiny backend is used, all APIs are supported.

Curl

  • This module has been tested with curl 7.22 and later.
  • HTTPS support is automatically detected by running curl --version and see its protocol output.
  • timeout, max_redirect, agent, default_headers and verify_SSL are supported.

Wget

  • This module requires Wget 1.12 and later.
  • Wget prior to 1.15 doesn't support sending custom HTTP methods, so if you use $http->put for example, you'll get an internal error response (599).
  • HTTPS support is automatically detected.
  • mirror() method doesn't send If-Modified-Since header to the server, which will result in full-download every time because wget doesn't support --timestamping combined with -O option.
  • timeout, max_redirect, agent, default_headers and verify_SSL are supported.

SIMILAR MODULES

  • File::Fetch - is core since 5.10. Has support for non-HTTP protocols such as ftp and git. Does not support HTTPS or basic authentication as of this writing.
  • Plient - provides more complete runtime API, but seems only compatible on Unix environments. Does not support mirror() method.

AUTHOR

Tatsuhiko Miyagawa

COPYRIGHT

Tatsuhiko Miyagawa, 2015-

LICENSE

This module is licensed under the same terms as Perl itself.

http-tinyish's People

Contributors

anatofuz avatar atoomic avatar miyagawa avatar skaji avatar stigtsp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.