Net::Travis::API::UA::Response - Subclass of HTTP::Tiny::UA::Response for utility methods
version 0.002000
This class warps extends HTTP::Tiny::UA::Response and adds a few utility methods and features that either
HTTP::Tiny::UA::Response
github-pull:HTTP-Tiny-UA#3
content_json
Returns the type/subtype portion of the content-type header.
type/subtype
content-type
Returns undef if there was no content-type header.
undef
if ( $result->content_type eq 'application/json' ) { ... }
Returns all parameter parts of the content-type header as an ArrayRef.
parameter
ArrayRef
Returns an empty ArrayRef if no such parameters were sent in the content-type header, or there was no content-type header.
for my $header ( @{ $result->content_type_params } ) { if ( $header =~ /^charset=(.+)/ ) { print "A charset of $1 was specified! :D"; } }
Returns ->content after applying type specific decoding.
->content
At present, this means everything that is not text/* will simply yield ->content
text/*
And everything that is text/* without a text/*;charset=someencoding will simply yield ->content
text/*;charset=someencoding
my $foo = $result->decoded_content(); # text/* with a specified encoding interpreted properly.
Optionally, you can pass a forced encoding to apply and override smart detection.
my $foo = $result->decoded_content('utf-8'); # type specific encodings ignored, utf-8 forced.
Returns a the data decoded from JSON.
Returns undef if the data
->content_json() # decodes automatically as per applicable encoding # or returns undef if its not application/json ->content_json(undef) # Forces decoding as json, but defers the text encoding # method to use either utf-8 or an encoding specified # by a ;charset= parameter. ->content_json('utf-8') # Forces decoding as json, and forces the text decoding to utf-
json
Optional.
A JSON Object for decoding JSON
Kent Fredric <kentnl@cpan.org>
This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::Travis::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Travis::API
CPAN shell
perl -MCPAN -e shell install Net::Travis::API
For more information on module installation, please visit the detailed CPAN module installation guide.