Why not adopt me?
NAME
Furl::PSGI::HTTP - Furl's low-level interface, wired to PSGI
VERSION
version 0.03
SYNOPSIS
use Furl::PSGI::HTTP;
my $res = Furl::PSGI::HTTP->new(app => $my_app)->request(
  method => 'POST',
  url    => 'https://foo.baz.net/etc',
  headers => [
    'Content-Type' => 'application/json',
  ],
  content => encode_json {
    type => 'dog',
    breed => 'chihuahua',
  },
);
DESCRIPTION
This is where the magic happens for Furl::PSGI, similar to Furl and Furl::HTTP. Given a PSGI app, all requests are sent to it and no network connections should be made.
METHODS
new
Supports all options in "new" in Furl::HTTP, and additionally requires an app attribute which should be a PSGI app (a code ref), which will receive ALL requests handled by the Furl::PSGI::HTTP instance returned.
INHERITANCE
Furl::PSGI::HTTP is a Furl::HTTP
NOTES
Furl::HTTP does a ton of work inside "request" in Furl::HTTP. In order to capture all of the behavior of Furl, and to avoid having to keep up with any changes, I didn't want to reimplement request. Instead, we turn all of the connect methods into stubs, and change write_all to build an internal buffer of the request as a string, as well as change read_timeout into a method that takes the buffered request, parses it, invokes the PSGI app, then turns the PSGI response into a string to pretend we're getting an HTTP reply back on a socket. This has its own stability risks as Furl changes, but it's much, much simpler than taking on all work that happens in request.
AUTHOR
Meredith Howard <mhoward@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2019 by Meredith Howard.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.