diff -Nru libcatalyst-action-rest-perl-1.20/Changes libcatalyst-action-rest-perl-1.21/Changes --- libcatalyst-action-rest-perl-1.20/Changes 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/Changes 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,7 @@ Revision history for Catalyst-Action-REST +1.21 2017-12-05 10:05:25-05:00 America/New_York + 1.20 2015-10-29 15:28:27-05:00 America/Chicago - Documentation fixes. diff -Nru libcatalyst-action-rest-perl-1.20/debian/changelog libcatalyst-action-rest-perl-1.21/debian/changelog --- libcatalyst-action-rest-perl-1.20/debian/changelog 2015-11-09 20:51:19.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/debian/changelog 2017-12-11 19:45:34.000000000 +0000 @@ -1,3 +1,27 @@ +libcatalyst-action-rest-perl (1.21-1) unstable; urgency=medium + + * Team upload + + [ Salvatore Bonaccorso ] + * debian/control: Use HTTPS transport protocol for Vcs-Git URI + + [ gregor herrmann ] + * debian/copyright: change Copyright-Format 1.0 URL to HTTPS. + + [ Salvatore Bonaccorso ] + * debian/control: Remove Franck Joncourt from Uploaders. + Thanks to Tobias Frost (Closes: #831283) + + [ gregor herrmann ] + * Remove Jonathan Yu from Uploaders. Thanks for your work! + + [ Damyan Ivanov ] + * New upstream version 1.21 + * declare conformance with Policy 4.1.2 (no changes) + * update years of upstream copyright + + -- Damyan Ivanov Mon, 11 Dec 2017 19:45:34 +0000 + libcatalyst-action-rest-perl (1.20-1) unstable; urgency=medium [ gregor herrmann ] diff -Nru libcatalyst-action-rest-perl-1.20/debian/control libcatalyst-action-rest-perl-1.21/debian/control --- libcatalyst-action-rest-perl-1.20/debian/control 2015-11-09 20:50:58.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/debian/control 2017-12-11 19:43:38.000000000 +0000 @@ -1,11 +1,10 @@ Source: libcatalyst-action-rest-perl Maintainer: Debian Perl Group -Uploaders: Jonathan Yu , - Franck Joncourt , - gregor herrmann , +Uploaders: gregor herrmann , Ansgar Burchardt , Florian Schlichting Section: perl +Testsuite: autopkgtest-pkg-perl Priority: optional Build-Depends: debhelper (>= 9) Build-Depends-Indep: perl, @@ -23,11 +22,10 @@ liburi-find-perl, libwww-perl, libyaml-syck-perl -Standards-Version: 3.9.6 +Standards-Version: 4.1.2 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libcatalyst-action-rest-perl.git -Vcs-Git: git://anonscm.debian.org/pkg-perl/packages/libcatalyst-action-rest-perl.git +Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libcatalyst-action-rest-perl.git Homepage: https://metacpan.org/release/Catalyst-Action-REST -Testsuite: autopkgtest-pkg-perl Package: libcatalyst-action-rest-perl Architecture: all @@ -56,4 +54,3 @@ changes the dispatch to append an underscore and method name. It will dispatch either to the action with the generating name or to a regular method. - diff -Nru libcatalyst-action-rest-perl-1.20/debian/copyright libcatalyst-action-rest-perl-1.21/debian/copyright --- libcatalyst-action-rest-perl-1.20/debian/copyright 2015-11-09 20:50:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/debian/copyright 2017-12-11 19:44:26.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Contact: Arthur Axel "fREW" Schmidt Source: https://metacpan.org/release/Catalyst-Action-REST Upstream-Name: Catalyst-Action-REST @@ -14,7 +14,7 @@ 2006-2015, Daisuke Maki 2006-2015, J. Shirley 2006-2015, Hans Dieter Pearcey - 2006-2014, Tomas Doran + 2006-2017, Tomas Doran 2006-2015, Gavin Henry 2006-2015, Gerv http://www.gerv.net/ 2006-2015, Colin Newell diff -Nru libcatalyst-action-rest-perl-1.20/dist.ini libcatalyst-action-rest-perl-1.21/dist.ini --- libcatalyst-action-rest-perl-1.20/dist.ini 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/dist.ini 2017-12-05 15:05:27.000000000 +0000 @@ -2,7 +2,7 @@ author = Tomas Doran license = Perl_5 copyright_holder = Tomas Doran -version = 1.20 +version = 1.21 [NextRelease] [@Git] diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/Callback.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/Callback.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/Callback.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/Callback.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize::Callback; -$Catalyst::Action::Deserialize::Callback::VERSION = '1.20'; +$Catalyst::Action::Deserialize::Callback::VERSION = '1.21'; use Moose; use namespace::autoclean; use Scalar::Util qw(openhandle); diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/JSON/XS.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/JSON/XS.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/JSON/XS.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/JSON/XS.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize::JSON::XS; -$Catalyst::Action::Deserialize::JSON::XS::VERSION = '1.20'; +$Catalyst::Action::Deserialize::JSON::XS::VERSION = '1.21'; use Moose; use namespace::autoclean; BEGIN { diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/JSON.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/JSON.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/JSON.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/JSON.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize::JSON; -$Catalyst::Action::Deserialize::JSON::VERSION = '1.20'; +$Catalyst::Action::Deserialize::JSON::VERSION = '1.21'; use Moose; use namespace::autoclean; use Scalar::Util qw(openhandle); diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/View.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/View.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/View.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/View.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize::View; -$Catalyst::Action::Deserialize::View::VERSION = '1.20'; +$Catalyst::Action::Deserialize::View::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/XML/Simple.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/XML/Simple.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/XML/Simple.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/XML/Simple.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize::XML::Simple; -$Catalyst::Action::Deserialize::XML::Simple::VERSION = '1.20'; +$Catalyst::Action::Deserialize::XML::Simple::VERSION = '1.21'; use Moose; use namespace::autoclean; use Scalar::Util qw(openhandle); diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/YAML.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/YAML.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize/YAML.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize/YAML.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize::YAML; -$Catalyst::Action::Deserialize::YAML::VERSION = '1.20'; +$Catalyst::Action::Deserialize::YAML::VERSION = '1.21'; use Moose; use namespace::autoclean; use Scalar::Util qw(openhandle); diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/DeserializeMultiPart.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/DeserializeMultiPart.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/DeserializeMultiPart.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/DeserializeMultiPart.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::DeserializeMultiPart; -$Catalyst::Action::DeserializeMultiPart::VERSION = '1.20'; +$Catalyst::Action::DeserializeMultiPart::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Deserialize.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Deserialize.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Deserialize; -$Catalyst::Action::Deserialize::VERSION = '1.20'; +$Catalyst::Action::Deserialize::VERSION = '1.21'; use Moose; use namespace::autoclean; @@ -117,6 +117,36 @@ When you use this module, the request class will be changed to L. +=head1 RFC 7231 Compliance Mode + +To maintain backwards compatibility with the module's original functionality, +where it was assumed the deserialize and serialize content types are the same, +an optional compliance mode can be enabled to break this assumption. + + __PACKAGE__->config( + 'compliance_mode' => 1, + 'default' => 'text/x-yaml', + 'stash_key' => 'rest', + 'map' => { + 'text/x-yaml' => 'YAML', + 'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ], + }, + 'deserialize_default => 'application/json', + 'deserialize_map' => { + 'application/json' => 'JSON', + }, + ); + +Three extra keys are added to the controller configuration. compliance_mode, a +boolean to enable the mode. And a parallel set of content type mappings +'deserialize_default' and 'deserialize_map' to mirror the default/map +configuration keys. + +The module will use the default/map keys when negotiating the serializing +content type specified by the client in the Accept header. And will use the +deserialize_default/deserialize_map in conjunction with the Content-Type +header where the client is giving the content type being sent in the request. + =head1 CUSTOM ERRORS For building custom error responses when de-serialization fails, you can create diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/REST/ForBrowsers.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/REST/ForBrowsers.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/REST/ForBrowsers.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/REST/ForBrowsers.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::REST::ForBrowsers; -$Catalyst::Action::REST::ForBrowsers::VERSION = '1.20'; +$Catalyst::Action::REST::ForBrowsers::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/REST.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/REST.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/REST.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/REST.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::REST; -$Catalyst::Action::REST::VERSION = '1.20'; +$Catalyst::Action::REST::VERSION = '1.21'; use utf8; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/Callback.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/Callback.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/Callback.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/Callback.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::Callback; -$Catalyst::Action::Serialize::Callback::VERSION = '1.20'; +$Catalyst::Action::Serialize::Callback::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/JSON/XS.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/JSON/XS.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/JSON/XS.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/JSON/XS.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::JSON::XS; -$Catalyst::Action::Serialize::JSON::XS::VERSION = '1.20'; +$Catalyst::Action::Serialize::JSON::XS::VERSION = '1.21'; use Moose; use namespace::autoclean; BEGIN { diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/JSON.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/JSON.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/JSON.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/JSON.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::JSON; -$Catalyst::Action::Serialize::JSON::VERSION = '1.20'; +$Catalyst::Action::Serialize::JSON::VERSION = '1.21'; use Moose; use namespace::autoclean; @@ -20,6 +20,12 @@ my $self = shift; my ( $controller, $c ) = @_; + if (my $options = $controller->{json_options_encode}) { + foreach my $opt (keys %$options) { + $self->encoder->$opt( $options->{$opt} ); + } + } + my $stash_key = ( $controller->{'serialize'} ? $controller->{'serialize'}->{'stash_key'} : diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/JSONP.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/JSONP.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/JSONP.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/JSONP.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::JSONP; -$Catalyst::Action::Serialize::JSONP::VERSION = '1.20'; +$Catalyst::Action::Serialize::JSONP::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/View.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/View.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/View.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/View.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::View; -$Catalyst::Action::Serialize::View::VERSION = '1.20'; +$Catalyst::Action::Serialize::View::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/XML/Simple.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/XML/Simple.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/XML/Simple.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/XML/Simple.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::XML::Simple; -$Catalyst::Action::Serialize::XML::Simple::VERSION = '1.20'; +$Catalyst::Action::Serialize::XML::Simple::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/YAML/HTML.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/YAML/HTML.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/YAML/HTML.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/YAML/HTML.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::YAML::HTML; -$Catalyst::Action::Serialize::YAML::HTML::VERSION = '1.20'; +$Catalyst::Action::Serialize::YAML::HTML::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/YAML.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/YAML.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize/YAML.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize/YAML.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize::YAML; -$Catalyst::Action::Serialize::YAML::VERSION = '1.20'; +$Catalyst::Action::Serialize::YAML::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/SerializeBase.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/SerializeBase.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/SerializeBase.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/SerializeBase.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::SerializeBase; -$Catalyst::Action::SerializeBase::VERSION = '1.20'; +$Catalyst::Action::SerializeBase::VERSION = '1.21'; use Moose; use namespace::autoclean; @@ -39,6 +39,8 @@ my $sclass = $search_path . "::"; my $sarg; my $map; + my $compliance_mode; + my $default; my $config; @@ -53,6 +55,28 @@ $config = $controller; } $map = $config->{'map'}; + $default = $config->{'default'} if $config->{'default'}; + + # If we're in RFC 7231 compliance mode we need to determine if we're + # serializing or deserializing, then set the request object to + # look at the appropriate set of supported content types. + $compliance_mode = $config->{'compliance_mode'}; + if($compliance_mode) { + my $serialize_mode = (split '::', $search_path)[-1]; + if($serialize_mode eq 'Deserialize') { + # Tell the request object to only look at the Content-Type header + $c->request->set_content_type_only(); + + # If we're in compliance mode and doing deserializing we want + # to use the allowed content types for deserializing, not the + # serializer map + $map = $config->{'deserialize_map'}; + $default = $config->{'deserialize_default'} if $config->{'deserialize_default'}; + } elsif($serialize_mode eq 'Serialize') { + # Tell the request object to only look at the Accept header + $c->request->set_accept_only(); + } + } # pick preferred content type my @accepted_types; # priority order, best first @@ -68,7 +92,7 @@ # then content types requested by caller push @accepted_types, @{ $c->request->accepted_content_types }; # then the default - push @accepted_types, $config->{'default'} if $config->{'default'}; + push @accepted_types, $default if $default; # pick the best match that we have a serializer mapping for my ($content_type) = grep { $map->{$_} } @accepted_types; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Action/Serialize.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Action/Serialize.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Action::Serialize; -$Catalyst::Action::Serialize::VERSION = '1.20'; +$Catalyst::Action::Serialize::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Controller/REST.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Controller/REST.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Controller/REST.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Controller/REST.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Controller::REST; -$Catalyst::Controller::REST::VERSION = '1.20'; +$Catalyst::Controller::REST::VERSION = '1.21'; use Moose; use namespace::autoclean; @@ -147,11 +147,22 @@ deprecated and you will receive warnings in your log. You can also add a hash in your controller config to pass options to the json object. +There are two options. C are used when decoding incoming JSON, and C +is used when encoding JSON for output. + For instance, to relax permissions when deserializing input, add: + __PACKAGE__->config( json_options => { relaxed => 1 } ) +To indent the JSON output so it becomes more human readable, add: + + __PACKAGE__->config( + json_options_encode => { indent => 1 } + ) + + =item * C => C If a callback=? parameter is passed, this returns javascript in the form of: $callback($serializedJSON); @@ -293,6 +304,7 @@ 'application/json' => 'JSON', 'text/x-json' => 'JSON', }, + 'compliance_mode' => 0, ); sub begin : ActionClass('Deserialize') { } diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Request/REST/ForBrowsers.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Request/REST/ForBrowsers.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Request/REST/ForBrowsers.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Request/REST/ForBrowsers.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Request::REST::ForBrowsers; -$Catalyst::Request::REST::ForBrowsers::VERSION = '1.20'; +$Catalyst::Request::REST::ForBrowsers::VERSION = '1.21'; use Moose; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/Request/REST.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/Request/REST.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/Request/REST.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/Request/REST.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::Request::REST; -$Catalyst::Request::REST::VERSION = '1.20'; +$Catalyst::Request::REST::VERSION = '1.21'; use Moose; use Catalyst::Utils; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/TraitFor/Request/REST/ForBrowsers.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/TraitFor/Request/REST/ForBrowsers.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/TraitFor/Request/REST/ForBrowsers.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/TraitFor/Request/REST/ForBrowsers.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::TraitFor::Request::REST::ForBrowsers; -$Catalyst::TraitFor::Request::REST::ForBrowsers::VERSION = '1.20'; +$Catalyst::TraitFor::Request::REST::ForBrowsers::VERSION = '1.21'; use Moose::Role; use namespace::autoclean; diff -Nru libcatalyst-action-rest-perl-1.20/lib/Catalyst/TraitFor/Request/REST.pm libcatalyst-action-rest-perl-1.21/lib/Catalyst/TraitFor/Request/REST.pm --- libcatalyst-action-rest-perl-1.20/lib/Catalyst/TraitFor/Request/REST.pm 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/lib/Catalyst/TraitFor/Request/REST.pm 2017-12-05 15:05:27.000000000 +0000 @@ -1,5 +1,5 @@ package Catalyst::TraitFor::Request::REST; -$Catalyst::TraitFor::Request::REST::VERSION = '1.20'; +$Catalyst::TraitFor::Request::REST::VERSION = '1.21'; use Moose::Role; use HTTP::Headers::Util qw(split_header_words); use namespace::autoclean; @@ -11,6 +11,7 @@ isa => 'ArrayRef', lazy => 1, builder => '_build_accepted_content_types', + clearer => 'clear_accepted_cache', init_arg => undef, ); @@ -22,24 +23,107 @@ init_arg => undef, ); +# +# By default the module looks at both Content-Type and +# Accept and uses the selected content type for both +# deserializing received data and serializing the response. +# However according to RFC 7231, Content-Type should be +# used to specify the payload type of the data sent by +# the requester and Accept should be used to negotiate +# the content type the requester would like back from +# the server. Compliance mode adds support so the method +# described in the RFC is more closely model. +# +# Using a bitmask to represent the the two content type +# header schemes. +# 0x1 for Accept +# 0x2 for Content-Type + +has 'compliance_mode' => ( + is => 'ro', + isa => 'Int', + lazy => 1, + writer => '_set_compliance_mode', + default => 0x3, +); + +# Set request object to only use the Accept header when building +# accepted_content_types +sub set_accept_only { + my $self = shift; + + # Clear the accepted_content_types cache if we've changed + # allowed headers + $self->clear_accepted_cache(); + $self->_set_compliance_mode(0x1); +} + +# Set request object to only use the Content-Type header when building +# accepted_content_types +sub set_content_type_only { + my $self = shift; + + $self->clear_accepted_cache(); + $self->_set_compliance_mode(0x2); +} + +# Clear serialize/deserialize compliance mode, allow all headers +# in both situations +sub clear_compliance_mode { + my $self = shift; + + $self->clear_accepted_cache(); + $self->_set_compliance_mode(0x3); +} + +# Return true if bit set to examine Accept header +sub accept_allowed { + my $self = shift; + + return $self->compliance_mode & 0x1; +} + +# Return true if bit set to examine Content-Type header +sub content_type_allowed { + my $self = shift; + + return $self->compliance_mode & 0x2; +} + +# Private writer to set if we're looking at Accept or Content-Type headers +sub _set_compliance_mode { + my $self = shift; + my $mode_bits = shift; + + $self->compliance_mode($mode_bits); +} + sub _build_accepted_content_types { my $self = shift; my %types; # First, we use the content type in the HTTP Request. It wins all. + # But only examine it if we're not in compliance mode or if we're + # in deserializing mode $types{ $self->content_type } = 3 - if $self->content_type; + if $self->content_type && $self->content_type_allowed(); - if ($self->method eq "GET" && $self->param('content-type')) { + # Seems backwards, but users are used to adding &content-type= to the uri to + # define what content type they want to recieve back, in the equivalent Accept + # header. Let the users do what they're used to, it's outside the RFC + # specifications anyhow. + if ($self->method eq "GET" && $self->param('content-type') && $self->accept_allowed()) { $types{ $self->param('content-type') } = 2; } # Third, we parse the Accept header, and see if the client # takes a format we understand. + # But only examine it if we're not in compliance mode or if we're + # in serializing mode # # This is taken from chansen's Apache2::UploadProgress. - if ( $self->header('Accept') ) { + if ( $self->header('Accept') && $self->accept_allowed() ) { $self->accept_only(1) unless keys %types; my $accept_header = $self->header('Accept'); @@ -96,7 +180,7 @@ This is a L applied to L that adds a few methods to the request object to facilitate writing REST-y code. Currently, these methods are all related to the content types accepted by -the client. +the client and the content type sent in the request. =head1 METHODS diff -Nru libcatalyst-action-rest-perl-1.20/LICENSE libcatalyst-action-rest-perl-1.21/LICENSE --- libcatalyst-action-rest-perl-1.20/LICENSE 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/LICENSE 2017-12-05 15:05:27.000000000 +0000 @@ -1,4 +1,4 @@ -This software is copyright (c) 2015 by Tomas Doran. +This software is copyright (c) 2017 by Tomas Doran. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. @@ -12,7 +12,7 @@ --- The GNU General Public License, Version 1, February 1989 --- -This software is Copyright (c) 2015 by Tomas Doran. +This software is Copyright (c) 2017 by Tomas Doran. This is free software, licensed under: @@ -272,7 +272,7 @@ --- The Artistic License 1.0 --- -This software is Copyright (c) 2015 by Tomas Doran. +This software is Copyright (c) 2017 by Tomas Doran. This is free software, licensed under: diff -Nru libcatalyst-action-rest-perl-1.20/Makefile.PL libcatalyst-action-rest-perl-1.21/Makefile.PL --- libcatalyst-action-rest-perl-1.20/Makefile.PL 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/Makefile.PL 2017-12-05 15:05:27.000000000 +0000 @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.041. +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.009. use strict; use warnings; @@ -31,7 +31,7 @@ "Test::More" => "0.88", "Test::Requires" => 0 }, - "VERSION" => "1.20", + "VERSION" => "1.21", "test" => { "TESTS" => "t/*.t" } diff -Nru libcatalyst-action-rest-perl-1.20/MANIFEST libcatalyst-action-rest-perl-1.21/MANIFEST --- libcatalyst-action-rest-perl-1.20/MANIFEST 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/MANIFEST 2017-12-05 15:05:27.000000000 +0000 @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.041. +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.009. Changes LICENSE MANIFEST diff -Nru libcatalyst-action-rest-perl-1.20/META.json libcatalyst-action-rest-perl-1.21/META.json --- libcatalyst-action-rest-perl-1.20/META.json 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/META.json 2017-12-05 15:05:27.000000000 +0000 @@ -4,7 +4,7 @@ "Tomas Doran " ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.150005", + "generated_by" : "Dist::Zilla version 6.009, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], @@ -62,6 +62,7 @@ }, "x_authority" : "cpan:BOBTFISH" }, - "version" : "1.20" + "version" : "1.21", + "x_serialization_backend" : "Cpanel::JSON::XS version 3.0233" } diff -Nru libcatalyst-action-rest-perl-1.20/META.yml libcatalyst-action-rest-perl-1.21/META.yml --- libcatalyst-action-rest-perl-1.20/META.yml 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/META.yml 2017-12-05 15:05:27.000000000 +0000 @@ -9,7 +9,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 -generated_by: 'Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.150005' +generated_by: 'Dist::Zilla version 6.009, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -28,4 +28,5 @@ resources: Authority: cpan:BOBTFISH bugtracker: https://rt.cpan.org/Dist/Display.html?Name=Catalyst-Action-REST -version: '1.20' +version: '1.21' +x_serialization_backend: 'YAML::Tiny version 1.70' diff -Nru libcatalyst-action-rest-perl-1.20/t/author-pod-syntax.t libcatalyst-action-rest-perl-1.21/t/author-pod-syntax.t --- libcatalyst-action-rest-perl-1.20/t/author-pod-syntax.t 2015-10-29 20:28:29.000000000 +0000 +++ libcatalyst-action-rest-perl-1.21/t/author-pod-syntax.t 2017-12-05 15:05:27.000000000 +0000 @@ -2,8 +2,8 @@ BEGIN { unless ($ENV{AUTHOR_TESTING}) { - require Test::More; - Test::More::plan(skip_all => 'these tests are for testing by the author'); + print qq{1..0 # SKIP these tests are for testing by the author\n}; + exit } }