Furl::PSGI::HTTP - Furl's low-level interface, wired to PSGI


version 0.03


  use Furl::PSGI::HTTP;

  my $res = Furl::PSGI::HTTP->new(app => $my_app)->request(
    method => 'POST',
    url    => '',
    headers => [
      'Content-Type' => 'application/json',
    content => encode_json {
      type => 'dog',
      breed => 'chihuahua',


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.



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.


Furl::PSGI::HTTP is a Furl::HTTP


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.


Meredith Howard <>


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.