HTTP::Tiny::FromHTTPRequest - Perform a request based on a plain HTTP request or HTTP::Request object
version 0.02
use v5.10;
use HTTP::Tiny::FromHTTPRequest;
use HTTP::Request;
my $http = HTTP::Tiny::FromHTTPRequest->new;
my $plain_request = q~
POST / HTTP/1.1
Content-Length: 104
User-Agent: HTTP-Tiny/0.025
Content-Type: multipart/form-data; boundary=go7DX
Connection: close
Host: localhost:3000
--go7DX
Content-Disposition: form-data; name="file"; filename="test.txt"
This is a test
--go7DX--
~;
my $response_from_object = $http->request( HTTP::Request->parse( $plain_request ) );
if ( $response_from_object->{success} ) {
say "Successful request from HTTP::Request object";
}
my $response_from_plain = $http->request( $plain_request );
if ( $response_from_plain->{success} ) {
say "Successful request from plain HTTP request";
}
The distribution is contained in a Git repository, so simply clone the repository
$ git clone git://github.com/reneeb/HTTP-Tiny-FromHTTPRequest.git
and change into the newly-created directory.
$ cd HTTP-Tiny-FromHTTPRequest
The project uses Dist::Zilla
to
build the distribution, hence this will need to be installed before
continuing:
$ cpanm Dist::Zilla
To install the required prequisite packages, run the following set of commands:
$ dzil authordeps --missing | cpanm
$ dzil listdeps --author --missing | cpanm
The distribution can be tested like so:
$ dzil test
To run the full set of tests (including author and release-process tests),
add the --author
and --release
options:
$ dzil test --author --release
Renee Baecker reneeb@cpan.org
This software is Copyright (c) 2018 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)