HTTP-Throwable-0.017000755000766000766 012215716241 13325 5ustar00rjbsrjbs000000000000README100644000766000766 53512215716241 14251 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017 This archive contains the distribution HTTP-Throwable, version 0.017: a set of strongly-typed, PSGI-friendly HTTP 1.1 exception libraries This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes100644000766000766 453012215716241 14703 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017Revision history for Perl extension HTTP::Throwable 0.017 2013-09-17 09:04:45 Asia/Tokyo - removed use of deprecated Class::MOP::load_class 0.016 2011-06-17 20:39:10 America/New_York - fix a test regex to work with DOS-style paths 0.015 2011-06-16 12:03:01 America/New_York - require Moose 1.23 to avoid bugs both various and sundry 0.014 2011-04-30 07:41:49 America/New_York - remove the use of // from a test, restoring perl 5.8 compatibility 0.013 2011-04-25 10:52:47 America/New_York - MooseX::StrictConstructor has changed API; track it 0.011 - fix Dist::Zilla configuration so that we get per-package $VERSION vars 0.010 [NOT BACKWARD COMPATIBLE] - significantly rewritten by rjbs, in terms of roles rather than subclasses - re-read the documentation! - HTTP::Throwable::Factory is now the piece intended most for end users - should be significantly easier to both use and extend 0.005 Sat. Feb. 12, 2011 - add proper support for RFC 2324 (thanks rjbs) - allowing more than one Proxy-Authenticate header (thanks to chansen for pointing this out, though he could have mentioned it before I released 0.004 :P) 0.004 Sat. Feb. 12, 2011 - allowing more than one WWW-Authenticate header (thanks to chansen for pointing this out) 0.003 Fri. Feb. 11, 2011 - introspection for status code via is_redirect, is_client_error and is_server_error (Brian Cassidy) 0.002 Tues. Feb. 8, 2011 - normalize *_location attributes to all be called location, since that is the name of the header - any time we allow additional headers to be passed in, the attribute is now called additional_headers instead of whatever it was before (usually cache_headers) - change the valid_methods attribute in HTTP::Throwable::MethodNotAllowed to be just allow (which is what the header is) - improved the type check on this as well - make the exceptions also function as PSGI apps - add to_app method - support &{} overload - added tests for this - overload stringification - added tests for this 0.001 Tues. Feb. 8, 2011 - first release LICENSE100644000766000766 4372512215716241 14446 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2011 by Infinity Interactive, Inc.. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2011 by Infinity Interactive, Inc.. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644000766000766 111512215716241 15050 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017name = HTTP-Throwable author = Stevan Little author = Ricardo Signes license = Perl_5 copyright_holder = Infinity Interactive, Inc. copyright_year = 2011 [@RJBS] [Authority] authority = cpan:STEVAN [Prereqs] Moose = 1.23 MooseX::StrictConstructor = 0.12 Throwable = 0.102080 Plack = 0.9967 List::AllUtils = 0 [Prereqs / TestRequires] Test::More = 0.88 Test::Fatal = 0.003 HTTP::Request::Common = 0 [RemovePrereqs] remove = t::lib::Test::HT META.yml100644000766000766 1455712215716241 14713 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017--- abstract: 'a set of strongly-typed, PSGI-friendly HTTP 1.1 exception libraries' author: - 'Stevan Little ' - 'Ricardo Signes ' build_requires: Capture::Tiny: 0 HTTP::Request::Common: 0 Plack::Builder: 0 Plack::Test: 0 Scalar::Util: 0 Test::Deep: 0 Test::Fatal: 0.003 Test::Moose: 0 Test::More: 0.96 base: 0 blib: 0 strict: 0 warnings: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300038, CPAN::Meta::Converter version 2.132140' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: HTTP-Throwable requires: List::AllUtils: 0 Module::Runtime: 0 Moose: 1.23 Moose::Role: 0 Moose::Util::TypeConstraints: 0 MooseX::Role::WithOverloading: 0.09 MooseX::StrictConstructor: 0.12 Plack: 0.9967 Plack::Util: 0 StackTrace::Auto: 0 Sub::Exporter: 0 Sub::Exporter::Util: 0 Throwable: 0.102080 overload: 0 resources: bugtracker: https://github.com/rjbs/HTTP-Throwable/issues homepage: https://github.com/rjbs/HTTP-Throwable repository: https://github.com/rjbs/HTTP-Throwable.git version: 0.017 x_Dist_Zilla: perl: version: 5.019003 plugins: - class: Dist::Zilla::Plugin::Git::GatherDir name: '@RJBS/Git::GatherDir' version: 2.014 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@RJBS/CheckPrereqsIndexed' version: 0.009 - class: Dist::Zilla::Plugin::CheckExtraTests name: '@RJBS/CheckExtraTests' version: 0.011 - class: Dist::Zilla::Plugin::PruneCruft name: '@RJBS/@Filter/PruneCruft' version: 4.300038 - class: Dist::Zilla::Plugin::ManifestSkip name: '@RJBS/@Filter/ManifestSkip' version: 4.300038 - class: Dist::Zilla::Plugin::MetaYAML name: '@RJBS/@Filter/MetaYAML' version: 4.300038 - class: Dist::Zilla::Plugin::License name: '@RJBS/@Filter/License' version: 4.300038 - class: Dist::Zilla::Plugin::Readme name: '@RJBS/@Filter/Readme' version: 4.300038 - class: Dist::Zilla::Plugin::ExecDir name: '@RJBS/@Filter/ExecDir' version: 4.300038 - class: Dist::Zilla::Plugin::ShareDir name: '@RJBS/@Filter/ShareDir' version: 4.300038 - class: Dist::Zilla::Plugin::MakeMaker name: '@RJBS/@Filter/MakeMaker' version: 4.300038 - class: Dist::Zilla::Plugin::Manifest name: '@RJBS/@Filter/Manifest' version: 4.300038 - class: Dist::Zilla::Plugin::TestRelease name: '@RJBS/@Filter/TestRelease' version: 4.300038 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@RJBS/@Filter/ConfirmRelease' version: 4.300038 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@RJBS/@Filter/UploadToCPAN' version: 4.300038 - class: Dist::Zilla::Plugin::AutoPrereqs name: '@RJBS/AutoPrereqs' version: 4.300038 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@RJBS/Git::NextVersion' version: 2.014 - class: Dist::Zilla::Plugin::PkgVersion name: '@RJBS/PkgVersion' version: 4.300038 - class: Dist::Zilla::Plugin::MetaConfig name: '@RJBS/MetaConfig' version: 4.300038 - class: Dist::Zilla::Plugin::MetaJSON name: '@RJBS/MetaJSON' version: 4.300038 - class: Dist::Zilla::Plugin::NextRelease name: '@RJBS/NextRelease' version: 4.300038 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@RJBS/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@RJBS/PodSyntaxTests' version: 4.300038 - class: Dist::Zilla::Plugin::ReportVersions::Tiny name: '@RJBS/ReportVersions::Tiny' version: 1.09 - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: module_finder: - ':InstallModules' script_finder: - ':ExecFiles' name: '@RJBS/Test::Compile' version: 2.018 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@RJBS/TestMoreWithSubtests' version: 4.300038 - class: Dist::Zilla::Plugin::PodWeaver name: '@RJBS/PodWeaver' version: 3.101642 - class: Dist::Zilla::Plugin::GithubMeta name: '@RJBS/GithubMeta' version: 0.30 - class: Dist::Zilla::Plugin::Git::Check name: '@RJBS/@Git/Check' version: 2.014 - class: Dist::Zilla::Plugin::Git::Commit name: '@RJBS/@Git/Commit' version: 2.014 - class: Dist::Zilla::Plugin::Git::Tag name: '@RJBS/@Git/Tag' version: 2.014 - class: Dist::Zilla::Plugin::Git::Push name: '@RJBS/@Git/Push' version: 2.014 - class: Dist::Zilla::Plugin::Authority name: Authority version: 1.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: 4.300038 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: 4.300038 - class: Dist::Zilla::Plugin::RemovePrereqs config: Dist::Zilla::Plugin::RemovePrereqs: modules_to_remove: - t::lib::Test::HT name: RemovePrereqs version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 4.300038 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 4.300038 x_authority: cpan:STEVAN MANIFEST100644000766000766 376512215716241 14552 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017Changes LICENSE MANIFEST META.json META.yml Makefile.PL README README.md dist.ini lib/HTTP/Throwable.pm lib/HTTP/Throwable/Factory.pm lib/HTTP/Throwable/Role/BoringText.pm lib/HTTP/Throwable/Role/Generic.pm lib/HTTP/Throwable/Role/NoBody.pm lib/HTTP/Throwable/Role/Redirect.pm lib/HTTP/Throwable/Role/Status/BadGateway.pm lib/HTTP/Throwable/Role/Status/BadRequest.pm lib/HTTP/Throwable/Role/Status/Conflict.pm lib/HTTP/Throwable/Role/Status/ExpectationFailed.pm lib/HTTP/Throwable/Role/Status/Forbidden.pm lib/HTTP/Throwable/Role/Status/Found.pm lib/HTTP/Throwable/Role/Status/GatewayTimeout.pm lib/HTTP/Throwable/Role/Status/Gone.pm lib/HTTP/Throwable/Role/Status/HTTPVersionNotSupported.pm lib/HTTP/Throwable/Role/Status/ImATeapot.pm lib/HTTP/Throwable/Role/Status/InternalServerError.pm lib/HTTP/Throwable/Role/Status/LengthRequired.pm lib/HTTP/Throwable/Role/Status/MethodNotAllowed.pm lib/HTTP/Throwable/Role/Status/MovedPermanently.pm lib/HTTP/Throwable/Role/Status/MultipleChoices.pm lib/HTTP/Throwable/Role/Status/NotAcceptable.pm lib/HTTP/Throwable/Role/Status/NotFound.pm lib/HTTP/Throwable/Role/Status/NotImplemented.pm lib/HTTP/Throwable/Role/Status/NotModified.pm lib/HTTP/Throwable/Role/Status/PreconditionFailed.pm lib/HTTP/Throwable/Role/Status/ProxyAuthenticationRequired.pm lib/HTTP/Throwable/Role/Status/RequestEntityTooLarge.pm lib/HTTP/Throwable/Role/Status/RequestTimeout.pm lib/HTTP/Throwable/Role/Status/RequestURITooLong.pm lib/HTTP/Throwable/Role/Status/RequestedRangeNotSatisfiable.pm lib/HTTP/Throwable/Role/Status/SeeOther.pm lib/HTTP/Throwable/Role/Status/ServiceUnavailable.pm lib/HTTP/Throwable/Role/Status/TemporaryRedirect.pm lib/HTTP/Throwable/Role/Status/Unauthorized.pm lib/HTTP/Throwable/Role/Status/UnsupportedMediaType.pm lib/HTTP/Throwable/Role/Status/UseProxy.pm lib/HTTP/Throwable/Role/TextBody.pm t/00-compile.t t/000-load.t t/000-report-versions-tiny.t t/001-basic.t t/002-to-app.t t/300-all.t t/400-all.t t/500-all.t t/lib/Test/HT.pm xt/release/changes_has_content.t xt/release/pod-syntax.t README.md100644000766000766 125012215716241 14663 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017# HTTP-Throwable This is a set of strongy-typed, PSGI-friendly exception classes corresponding to the HTTP error status code (4xx-5xx) as well as the redirection codes (3xx). ## Installation To install this module type the following: perl Makefile.PL make make test make install ## Dependencies This module requires these other modules and libraries: Moose MooseX::StrictConstructor Throwable Plack List::AllUtils ## Copyright and License Copyright (C) 2011 Infinity Interactive, Inc. (http://www.iinteractive.com) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. META.json100644000766000766 2407212215716241 15054 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017{ "abstract" : "a set of strongly-typed, PSGI-friendly HTTP 1.1 exception libraries", "author" : [ "Stevan Little ", "Ricardo Signes " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300038, CPAN::Meta::Converter version 2.132140", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "HTTP-Throwable", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41", "version" : "0.9901" } }, "runtime" : { "requires" : { "List::AllUtils" : "0", "Module::Runtime" : "0", "Moose" : "1.23", "Moose::Role" : "0", "Moose::Util::TypeConstraints" : "0", "MooseX::Role::WithOverloading" : "0.09", "MooseX::StrictConstructor" : "0.12", "Plack" : "0.9967", "Plack::Util" : "0", "StackTrace::Auto" : "0", "Sub::Exporter" : "0", "Sub::Exporter::Util" : "0", "Throwable" : "0.102080", "overload" : "0" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "HTTP::Request::Common" : "0", "Plack::Builder" : "0", "Plack::Test" : "0", "Scalar::Util" : "0", "Test::Deep" : "0", "Test::Fatal" : "0.003", "Test::Moose" : "0", "Test::More" : "0.96", "base" : "0", "blib" : "0", "strict" : "0", "warnings" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/rjbs/HTTP-Throwable/issues" }, "homepage" : "https://github.com/rjbs/HTTP-Throwable", "repository" : { "type" : "git", "url" : "https://github.com/rjbs/HTTP-Throwable.git", "web" : "https://github.com/rjbs/HTTP-Throwable" } }, "version" : "0.017", "x_Dist_Zilla" : { "perl" : { "version" : "5.019003" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@RJBS/Git::GatherDir", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@RJBS/CheckPrereqsIndexed", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@RJBS/CheckExtraTests", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@RJBS/@Filter/PruneCruft", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@RJBS/@Filter/ManifestSkip", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@RJBS/@Filter/MetaYAML", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@RJBS/@Filter/License", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@RJBS/@Filter/Readme", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@RJBS/@Filter/ExecDir", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@RJBS/@Filter/ShareDir", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@RJBS/@Filter/MakeMaker", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@RJBS/@Filter/Manifest", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@RJBS/@Filter/TestRelease", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@RJBS/@Filter/ConfirmRelease", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@RJBS/@Filter/UploadToCPAN", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@RJBS/AutoPrereqs", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@RJBS/Git::NextVersion", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@RJBS/PkgVersion", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@RJBS/MetaConfig", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@RJBS/MetaJSON", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@RJBS/NextRelease", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@RJBS/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@RJBS/PodSyntaxTests", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ReportVersions::Tiny", "name" : "@RJBS/ReportVersions::Tiny", "version" : "1.09" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "module_finder" : [ ":InstallModules" ], "script_finder" : [ ":ExecFiles" ] } }, "name" : "@RJBS/Test::Compile", "version" : "2.018" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@RJBS/TestMoreWithSubtests", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "name" : "@RJBS/PodWeaver", "version" : "3.101642" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@RJBS/GithubMeta", "version" : "0.30" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@RJBS/@Git/Check", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "name" : "@RJBS/@Git/Commit", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "name" : "@RJBS/@Git/Tag", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "name" : "@RJBS/@Git/Push", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "Authority", "version" : "1.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::RemovePrereqs", "config" : { "Dist::Zilla::Plugin::RemovePrereqs" : { "modules_to_remove" : [ "t::lib::Test::HT" ] } }, "name" : "RemovePrereqs", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "4.300038" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "4.300038" } }, "x_authority" : "cpan:STEVAN" } t000755000766000766 012215716241 13511 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017300-all.t100644000766000766 340612215716241 15111 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t#!/usr/bin/perl use strict; use warnings; use Test::More; use t::lib::Test::HT; ht_test(MultipleChoices => { location => '/test' }, { code => 300, reason => 'Multiple Choices', headers => [ Location => '/test' ], }); ht_test(MovedPermanently => { location => '/test' }, { code => 301, reason => 'Moved Permanently', headers => [ Location => '/test', ], }); ht_test( Found => { location => '/test', additional_headers => [ Expires => 'Soonish', ], }, { code => 302, reason => 'Found', headers => [ Location => '/test', Expires => 'Soonish', ], }, ); ht_test(SeeOther => { location => '/test' }, { code => 303, reason => 'See Other', headers => [ Location => '/test', ], }); ht_test( NotModified => { location => '/test', additional_headers => [ 'Expires' => 'Soonish', ], }, { code => 304, reason => 'Not Modified', as_string => '304 Not Modified', body => undef, length => 0, headers => [ Location => '/test', Expires => 'Soonish', ], }, ); ht_test(UseProxy => { location => '/proxy/test' }, { code => 305, reason => 'Use Proxy', headers => [ Location => '/proxy/test', ], }); ht_test( TemporaryRedirect => { location => '/test', additional_headers => [ 'Expires' => 'Soonish' ] }, { code => 307, reason => 'Temporary Redirect', headers => [ 'Location' => '/test', 'Expires' => 'Soonish', ], }, ); done_testing; 400-all.t100644000766000766 513212215716241 15110 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Test::Fatal; use Test::Moose; use t::lib::Test::HT; ht_test(BadRequest => {}, { code => 400, reason => 'Bad Request', }); ht_test( Unauthorized => { www_authenticate => 'Basic realm="realm"' }, { code => 401, reason => 'Unauthorized', headers => [ 'WWW-Authenticate' => 'Basic realm="realm"' ], }, ); ht_test( Unauthorized => { www_authenticate => [ 'Basic realm="basic realm"', 'Digest realm="digest realm"', ] }, { code => 401, reason => 'Unauthorized', headers => [ 'WWW-Authenticate' => 'Basic realm="basic realm"', 'WWW-Authenticate' => 'Digest realm="digest realm"', ], }, ); ht_test(Forbidden => {}, { code => 403, reason => 'Forbidden', }); ht_test(NotFound=> {}, { code => 404, reason => 'Not Found', }); ht_test(MethodNotAllowed => { allow => [ qw(GET PUT) ] }, { code => 405, reason => 'Method Not Allowed', headers => [ Allow => 'GET,PUT' ], }); like( exception { HTTP::Throwable::Factory->throw(MethodNotAllowed => { allow => [ 'GET', 'PUT', 'OPTIONS', 'PUT' ], }); }, qr/Attribute \(allow\) does not pass the type constraint/, '... type check works (must be unique list)', ); like( exception { HTTP::Throwable::Factory->throw(MethodNotAllowed => { allow => [ 'GET', 'PUT', 'OPTIONS', 'TEST' ], }); }, qr/Attribute \(allow\) does not pass the type constraint/, '... type check works (must be all known methods)', ); ht_test(NotAcceptable => {}, { code => 406, reason => 'Not Acceptable', }); ht_test( ProxyAuthenticationRequired => { proxy_authenticate => 'Basic realm="realm"' }, { code => 407, reason => 'Proxy Authentication Required', headers => [ 'Proxy-Authenticate' => 'Basic realm="realm"' ], }, ); ht_test( ProxyAuthenticationRequired => { proxy_authenticate => [ 'Basic realm="realm"', 'Digest realm="other_realm"', ], }, { code => 407, reason => 'Proxy Authentication Required', headers => [ 'Proxy-Authenticate' => 'Basic realm="realm"', 'Proxy-Authenticate' => 'Digest realm="other_realm"', ], }, ); ht_test(RequestTimeout => {}, { code => 408, reason => 'Request Timeout', }); ht_test(Conflict => {}, { code => 409, reason => 'Conflict', }); done_testing; 500-all.t100644000766000766 161612215716241 15114 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t#!/usr/bin/perl use strict; use warnings; use Test::Deep qw(ignore re); use Test::More; use Test::Fatal; use Test::Moose; use t::lib::Test::HT; ht_test(InternalServerError => {}, { code => 500, reason => 'Internal Server Error', length => ignore(), body => re(qr{500 Internal Server Error.+at t.lib.Test.HT.pm}s), }); ht_test(NotImplemented => {}, { code => 501, reason => 'Not Implemented', }); ht_test(BadGateway => {}, { code => 502, reason => 'Bad Gateway', }); ht_test(ServiceUnavailable => { retry_after => 'A Little While' }, { code => 503, reason => 'Service Unavailable', headers => [ 'Retry-After' => 'A Little While' ], }); ht_test(GatewayTimeout => {}, { code => 504, reason => 'Gateway Timeout', }); ht_test(HTTPVersionNotSupported => {}, { code => 505, reason => 'HTTP Version Not Supported', }); done_testing; Makefile.PL100644000766000766 416012215716241 15361 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "a set of strongly-typed, PSGI-friendly HTTP 1.1 exception libraries", "AUTHOR" => "Stevan Little , Ricardo Signes ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "HTTP-Throwable", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "HTTP::Throwable", "PREREQ_PM" => { "List::AllUtils" => 0, "Module::Runtime" => 0, "Moose" => "1.23", "Moose::Role" => 0, "Moose::Util::TypeConstraints" => 0, "MooseX::Role::WithOverloading" => "0.09", "MooseX::StrictConstructor" => "0.12", "Plack" => "0.9967", "Plack::Util" => 0, "StackTrace::Auto" => 0, "Sub::Exporter" => 0, "Sub::Exporter::Util" => 0, "Throwable" => "0.102080", "overload" => 0 }, "TEST_REQUIRES" => { "Capture::Tiny" => 0, "HTTP::Request::Common" => 0, "Plack::Builder" => 0, "Plack::Test" => 0, "Scalar::Util" => 0, "Test::Deep" => 0, "Test::Fatal" => "0.003", "Test::Moose" => 0, "Test::More" => "0.96", "base" => 0, "blib" => 0, "strict" => 0, "warnings" => 0 }, "VERSION" => "0.017", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); 000-load.t100644000766000766 16412215716241 15233 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t#!/usr/bin/perl use strict; use warnings; use Test::More; BEGIN { use_ok('HTTP::Throwable'); } done_testing;001-basic.t100644000766000766 244512215716241 15422 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Test::Fatal; use Test::Moose; use t::lib::Test::HT; ht_test( { status_code => 500, reason => 'Internal Server Error' }, { code => 500, reason => 'Internal Server Error', assert => sub { my $e = shift; is( "$e", '500 Internal Server Error', '... got the right string overload', ); if ($e->does('HTTP::Throwable::Role::TextBody')) { is_deeply( $e->(), [ 500, [ 'Content-Type' => 'text/plain', 'Content-Length' => 25, ], [ '500 Internal Server Error' ] ], '... got the right &{} overload transformation' ); } }, }, ); subtest "strict constructors all around" => sub { my $error = exception { HTTP::Throwable::Factory->throw(MovedPermanently => { location => '/foo', bogus => 123, }); }; like( $error, qr{unknown attribute\(s\) init_arg passed to the constructor}, "http throwables have strict constructors", ); }; done_testing; 002-to-app.t100644000766000766 470512215716241 15543 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t#!/usr/bin/perl use strict; use warnings; use HTTP::Throwable::Factory; use Test::More; use Plack::Test; use Plack::Builder; use HTTP::Request::Common qw[ GET ]; test_psgi( app => builder { mount '/old' => HTTP::Throwable::Factory->new_exception( MovedPermanently => { location => '/new' } ); mount '/new' => sub { [ 200, [], ['HERE']]; }; }, client => sub { my $cb = shift; { my $req = GET "/old"; my $res = $cb->($req); is($res->code, 301, '... got the right status code'); is($res->header('Content-Type'), 'text/plain', '... got the right Content-Type header'); is($res->header('Content-Length'), 21, '... got the right Content-Length header'); is($res->header('Location'), '/new', '... got the right Allow header'); is($res->content, '301 Moved Permanently', '... got the right content body'); } { my $req = GET "/new"; my $res = $cb->($req); is($res->code, 200, '... got the right status code'); is($res->content, 'HERE', '... got the right content body'); } } ); test_psgi( app => HTTP::Throwable::Factory->new_exception( MethodNotAllowed => { allow => [ qw(POST PUT) ] } ), client => sub { my $cb = shift; { my $req = GET "/"; my $res = $cb->($req); is($res->code, 405, '... got the right status code'); is($res->header('Content-Type'), 'text/plain', '... got the right Content-Type header'); is($res->header('Content-Length'), 22, '... got the right Content-Length header'); is($res->header('Allow'), 'POST,PUT', '... got the right Allow header'); is($res->content, '405 Method Not Allowed', '... got the right content body'); } } ); test_psgi( app => HTTP::Throwable::Factory->new_exception('NotFound'), client => sub { my $cb = shift; { my $req = GET "/"; my $res = $cb->($req); is($res->code, 404, '... got the right status code'); is($res->header('Content-Type'), 'text/plain', '... got the right Content-Type header'); is($res->header('Content-Length'), 13, '... got the right Content-Length header'); is($res->content, '404 Not Found', '... got the right content body'); } } ); done_testing; 00-compile.t100644000766000766 421512215716241 15705 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/tuse strict; use warnings; # This test was generated via Dist::Zilla::Plugin::Test::Compile 2.018 use Test::More 0.88; use Capture::Tiny qw{ capture }; my @module_files = qw( HTTP/Throwable.pm HTTP/Throwable/Factory.pm HTTP/Throwable/Role/BoringText.pm HTTP/Throwable/Role/Generic.pm HTTP/Throwable/Role/NoBody.pm HTTP/Throwable/Role/Redirect.pm HTTP/Throwable/Role/Status/BadGateway.pm HTTP/Throwable/Role/Status/BadRequest.pm HTTP/Throwable/Role/Status/Conflict.pm HTTP/Throwable/Role/Status/ExpectationFailed.pm HTTP/Throwable/Role/Status/Forbidden.pm HTTP/Throwable/Role/Status/Found.pm HTTP/Throwable/Role/Status/GatewayTimeout.pm HTTP/Throwable/Role/Status/Gone.pm HTTP/Throwable/Role/Status/HTTPVersionNotSupported.pm HTTP/Throwable/Role/Status/ImATeapot.pm HTTP/Throwable/Role/Status/InternalServerError.pm HTTP/Throwable/Role/Status/LengthRequired.pm HTTP/Throwable/Role/Status/MethodNotAllowed.pm HTTP/Throwable/Role/Status/MovedPermanently.pm HTTP/Throwable/Role/Status/MultipleChoices.pm HTTP/Throwable/Role/Status/NotAcceptable.pm HTTP/Throwable/Role/Status/NotFound.pm HTTP/Throwable/Role/Status/NotImplemented.pm HTTP/Throwable/Role/Status/NotModified.pm HTTP/Throwable/Role/Status/PreconditionFailed.pm HTTP/Throwable/Role/Status/ProxyAuthenticationRequired.pm HTTP/Throwable/Role/Status/RequestEntityTooLarge.pm HTTP/Throwable/Role/Status/RequestTimeout.pm HTTP/Throwable/Role/Status/RequestURITooLong.pm HTTP/Throwable/Role/Status/RequestedRangeNotSatisfiable.pm HTTP/Throwable/Role/Status/SeeOther.pm HTTP/Throwable/Role/Status/ServiceUnavailable.pm HTTP/Throwable/Role/Status/TemporaryRedirect.pm HTTP/Throwable/Role/Status/Unauthorized.pm HTTP/Throwable/Role/Status/UnsupportedMediaType.pm HTTP/Throwable/Role/Status/UseProxy.pm HTTP/Throwable/Role/TextBody.pm ); my @scripts = qw( ); # no fake home requested my @warnings; for my $lib (@module_files) { my ($stdout, $stderr, $exit) = capture { system($^X, '-Mblib', '-e', qq{require q[$lib]}); }; is($?, 0, "$lib loaded ok"); warn $stderr if $stderr; push @warnings, $stderr if $stderr; } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; done_testing; Test000755000766000766 012215716241 15176 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t/libHT.pm100644000766000766 1117312215716241 16232 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/t/lib/Testpackage t::lib::Test::HT; use strict; use warnings; use HTTP::Throwable::Factory; use Scalar::Util qw(reftype); use Test::Deep qw(cmp_deeply bag); use Test::Fatal; use Test::Moose; use Test::More; use Sub::Exporter -setup => { exports => [ qw(ht_test) ], groups => [ default => [ '-all' ] ], }; { package MyFactory; use base 'HTTP::Throwable::Factory'; sub extra_roles { return qw( HTTP::Throwable::Role::NoBody ); } } sub ht_test { my ($identifier, $arg); ($identifier, $arg) = ref $_[0] ? (undef, shift) : (shift, shift || {}); my $comment = (defined $_[0] and ! ref $_[0]) ? shift(@_) : sprintf("ht_test at %s, line %s", (caller)[1, 2]); my $extra = (! defined $_[0]) ? {} : (! reftype $_[0]) ? confess("bogus extra value") : (reftype $_[0] eq 'CODE') ? { assert => $_[0] } : (reftype $_[0] eq 'HASH') ? $_[0] : confess("bogus extra value"); subtest $comment => sub { for my $factory_class ( 'HTTP::Throwable::Factory', 'MyFactory', ) { subtest "...using $factory_class" => sub { local $Test::Builder::Level = $Test::Builder::Level + 1; my $err = exception { $factory_class->throw($identifier, $arg); }; does_ok($err, 'HTTP::Throwable'); does_ok($err, 'Throwable'); if (my $code = $extra->{code}) { is($err->status_code, $code, "got expected status code"); $code =~ /^3/ ? ok( $err->is_redirect, "it's a redirect" ) : ok( ! $err->is_redirect, "it's not a redirect" ); $code =~ /^4/ ? ok( $err->is_client_error, "it's a client error") : ok( ! $err->is_client_error, "it's a not client error"); $code =~ /^5/ ? ok( $err->is_server_error, "it's a server error") : ok( ! $err->is_server_error, "it's not a server error"); } if (defined $extra->{reason}) { is($err->reason, $extra->{reason}, "got expected reason"); } my $status_line; if (defined $extra->{code} and defined $extra->{reason}) { $status_line = join q{ }, @$extra{ qw(code reason) }; is( $err->status_line, $status_line, "expected status line", ); } # XXX: Gross, sorry. -- rjbs, 2011-02-21 my $as_string = exists $extra->{as_string} ? $extra->{as_string} : $factory_class eq 'MyFactory' ? $status_line : exists $extra->{body} ? $extra->{body} : $status_line; cmp_deeply($err->as_string, $as_string, "expected as_string") if defined $as_string; { my $body = exists $extra->{body} ? $extra->{body} : $status_line; # XXX: Another gross conditional -- rjbs, 2011-02-21 $body = undef if $factory_class eq 'MyFactory'; my $length = defined $extra->{length} ? $extra->{length} : defined length $body ? length $body : 0; my $psgi = $err->as_psgi; my $expect = [ $extra->{code}, bag( (defined $body ? ('Content-Type' => 'text/plain') : ()), 'Content-Length' => $length, @{ $extra->{headers} || [] }, ), [ defined $body ? $body : () ] ]; cmp_deeply( $psgi, $expect, '... got the right PSGI transformation' ); } if ($extra->{assert}) { local $_ = $err; $extra->{assert}->($err); } } } }; } 1; HTTP000755000766000766 012215716241 14573 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/libThrowable.pm100644000766000766 2721712215716241 17251 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTPpackage HTTP::Throwable; BEGIN { $HTTP::Throwable::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::VERSION = '0.017'; } use Moose::Role; use MooseX::StrictConstructor; use MooseX::Role::WithOverloading 0.09; use overload '&{}' => 'to_app', '""' => 'as_string', fallback => 1; use Plack::Util (); with 'Throwable'; has 'status_code' => ( is => 'ro', isa => 'Int', builder => 'default_status_code', ); has 'reason' => ( is => 'ro', isa => 'Str', required => 1, builder => 'default_reason', ); has 'message' => ( is => 'ro', isa => 'Str', predicate => 'has_message', ); # TODO: type this attribute more strongly -- rjbs, 2011-02-21 has 'additional_headers' => ( is => 'ro', isa => 'ArrayRef' ); sub build_headers { my ($self, $body) = @_; my @headers; @headers = @{ $self->body_headers($body) }; if ( my $additional_headers = $self->additional_headers ) { push @headers => @$additional_headers; } return \@headers; } sub status_line { my $self = shift; my $out = $self->status_code . " " . $self->reason; $out .= " " . $self->message if $self->message; return $out; } requires 'body'; requires 'body_headers'; requires 'as_string'; sub as_psgi { my $self = shift; my $body = $self->body; my $headers = $self->build_headers( $body ); [ $self->status_code, $headers, [ defined $body ? $body : () ] ]; } sub to_app { my $self = shift; sub { my $env; $self->as_psgi( $env ) } } sub is_redirect { my $status = (shift)->status_code; return $status >= 300 && $status < 400; } sub is_client_error { my $status = (shift)->status_code; return $status >= 400 && $status < 500; } sub is_server_error { my $status = (shift)->status_code; return $status >= 500 && $status < 600; } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable - a set of strongly-typed, PSGI-friendly HTTP 1.1 exception libraries =head1 VERSION version 0.017 =head1 SYNOPSIS B: The interface for HTTP::Throwable has changed significantly between 0.005 and 0.010. Further backward incompatibilities may appear in the next few weeks, as the interface is refined. This notice will be removed when it has stabilized. I, you probably want to use L, so here's a sample of how that works: use HTTP::Throwable::Factory qw(http_throw http_exception); # you can just throw a generic exception... HTTP::Throwable::Factory->throw({ status_code => 500, reason => 'Internal Server Error', message => 'Something has gone very wrong!' }); # or with a little sugar... http_throw({ status_code => 500, reason => 'Internal Server Error', message => 'Something has gone very wrong!' }); # ...but it's much more convenient to throw well-defined exceptions, like # this: http_throw(InternalServerError => { message => 'Something has gone very wrong!', }); # or you can use the exception objects as PSGI apps: builder { mount '/old' => http_exception(MovedPermanently => { location => '/new' }), # ... }; =head1 DESCRIPTION HTTP-Throwable provides a set of strongly-typed, PSGI-friendly exception implementations corresponding to the HTTP error status code (4xx-5xx) as well as the redirection codes (3xx). This particular package (HTTP::Throwable) is the shared role for all the exceptions involved. It's not intended that you use HTTP::Throwable directly, although you can, and instructions for using it correctly are given below. Instead, you probably want to use L, which will assemble exception classes from roles needed to build an exception for your use case. For example, you can throw a redirect: use HTTP::Throwable::Factory qw(http_throw); http_throw(MovedPermanently => { location => '/foo-bar' }); ...or a generic fully user-specified exception... http_throw({ status_code => 512, reason => 'Server on fire', message => "Please try again after heavy rain", }); For a list of pre-defined, known errors, see L below. These types will have the correct status code and reason, and will understand extra status-related arguments like redirect location or authentication realms. For information on using HTTP::Throwable directly, see L, below. =head2 HTTP::Exception This module is similar to HTTP::Exception with a few, well uhm, exceptions. First, we are not implementing the 1xx and 2xx status codes, it is this authors opinion that those not being errors or an exception control flow (redirection) should not be handled with exceptions. And secondly, this module is very PSGI friendly in that it can turn your exception into a PSGI response with just a method call. All that said HTTP::Exception is a wonderful module and if that better suits your needs, then by all means, use it. =head2 Note about Stack Traces It should be noted that even though these are all exception objects, only the 500 Internal Server Error error actually includes the stack trace (albiet optionally). This is because more often then not you will not actually care about the stack trace and therefore do not the extra overhead. If you do find you want a stack trace though, it is as simple as adding the L role to your exceptions. =head1 ATTRIBUTES =head2 status_code This is the status code integer as specified in the HTTP spec. =head2 resason This is the reason phrase as specified in the HTTP spec. =head2 message This is an additional message string that can be supplied, which I be used when stringifying or building an HTTP response. =head2 additional_headers This is an arrayref of pairs that will be added to the headers of the exception when converted to a HTTP message. =head1 METHODS =head2 status_line This returns a string that would be used as a status line in a response, like C<404 Not Found>. =head2 as_string This returns a string representation of the exception. This method B be implemented by any class consuming this role. =head2 as_psgi This returns a representation of the exception object as PSGI response. In theory, it accepts a PSGI environment as its only argument, but currently the environment is ignored. =head2 to_app This is the standard Plack convention for Ls. It will return a CODE ref which expects the C<$env> parameter and returns the results of C. =head2 &{} We overload C<&{}> to call C, again in keeping with the L convention. =head1 WELL-KNOWN TYPES Below is a list of the well-known types recognized by the factory and shipped with this distribution. The obvious 4xx and 5xx errors are included but we also include the 3xx redirection status codes. This is because, while not really an error, the 3xx status codes do represent an exceptional control flow. The implementation for each of these is in a role with a name in the form C. For example, "Gone" is C. When throwing the exception with the factory, just pass "Gone" =head2 Redirection 3xx This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request. The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. =over 4 =item 300 L =item 301 L =item 302 L =item 303 L =item 304 L =item 305 L =item 307 L =back =head2 Client Error 4xx The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included entity to the user. =over 4 =item 400 L =item 401 L =item 403 L =item 404 L =item 405 L =item 406 L =item 407 L =item 408 L =item 409 L =item 410 L =item 411 L =item 412 L =item 413 L =item 414 L =item 415 L =item 416 L =item 417 L =back =head2 Server Error 5xx Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has erred or is incapable of performing the request. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. User agents SHOULD display any included entity to the user. These response codes are applicable to any request method. =over 4 =item 500 L =item 501 L =item 502 L =item 503 L =item 504 L =item 505 L =back =head1 COMPOSING WITH HTTP::THROWABLE In general, we expect that you'll use L or a subclass to throw exceptions. You can still use HTTP::Throwable directly, though, if you keep these things in mind: HTTP::Throwable is mostly concerned about providing basic headers and a PSGI representation. It doesn't worry about the body or a stringification. You B provide the methods C and C and C. The C method returns the string (of octets) to be sent as the HTTP entity. That body is passed to the C method, which must return an arrayref of headers to add to the response. These will generally include the Content-Type and Content-Length headers. The C method should return a printable string, even if the body is going to be empty. For convenience, these three methods are implemented by the roles L and L. =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: a set of strongly-typed, PSGI-friendly HTTP 1.1 exception libraries release000755000766000766 012215716241 15321 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/xtpod-syntax.t100644000766000766 21212215716241 17727 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/xt/release#!perl use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); 000-report-versions-tiny.t100644000766000766 650412215716241 20502 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/tuse strict; use warnings; use Test::More 0.88; # This is a relatively nice way to avoid Test::NoWarnings breaking our # expectations by adding extra tests, without using no_plan. It also helps # avoid any other test module that feels introducing random tests, or even # test plans, is a nice idea. our $success = 0; END { $success && done_testing; } # List our own version used to generate this my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.09\n"; eval { # no excuses! # report our Perl details my $want = "any version"; $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; }; defined($@) and diag("$@"); # Now, our module version dependencies: sub pmver { my ($module, $wanted) = @_; $wanted = " (want $wanted)"; my $pmver; eval "require $module;"; if ($@) { if ($@ =~ m/Can't locate .* in \@INC/) { $pmver = 'module not found.'; } else { diag("${module}: $@"); $pmver = 'died during require.'; } } else { my $version; eval { $version = $module->VERSION; }; if ($@) { diag("${module}: $@"); $pmver = 'died during VERSION check.'; } elsif (defined $version) { $pmver = "$version"; } else { $pmver = ''; } } # So, we should be good, right? return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); } eval { $v .= pmver('Capture::Tiny','any version') }; eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; eval { $v .= pmver('HTTP::Request::Common','any version') }; eval { $v .= pmver('List::AllUtils','any version') }; eval { $v .= pmver('Module::Runtime','any version') }; eval { $v .= pmver('Moose','1.23') }; eval { $v .= pmver('Moose::Role','any version') }; eval { $v .= pmver('Moose::Util::TypeConstraints','any version') }; eval { $v .= pmver('MooseX::Role::WithOverloading','0.09') }; eval { $v .= pmver('MooseX::StrictConstructor','0.12') }; eval { $v .= pmver('Plack','0.9967') }; eval { $v .= pmver('Plack::Builder','any version') }; eval { $v .= pmver('Plack::Test','any version') }; eval { $v .= pmver('Plack::Util','any version') }; eval { $v .= pmver('Scalar::Util','any version') }; eval { $v .= pmver('StackTrace::Auto','any version') }; eval { $v .= pmver('Sub::Exporter','any version') }; eval { $v .= pmver('Sub::Exporter::Util','any version') }; eval { $v .= pmver('Test::Deep','any version') }; eval { $v .= pmver('Test::Fatal','0.003') }; eval { $v .= pmver('Test::Moose','any version') }; eval { $v .= pmver('Test::More','0.96') }; eval { $v .= pmver('Test::Pod','1.41') }; eval { $v .= pmver('Throwable','0.102080') }; eval { $v .= pmver('base','any version') }; eval { $v .= pmver('blib','any version') }; eval { $v .= pmver('overload','any version') }; eval { $v .= pmver('strict','any version') }; eval { $v .= pmver('version','0.9901') }; eval { $v .= pmver('warnings','any version') }; # All done. $v .= <<'EOT'; Thanks for using my code. I hope it works for you. If not, please try and include this output in the bug report. That will help me reproduce the issue and solve your problem. EOT diag($v); ok(1, "we really didn't test anything, just reporting data"); $success = 1; # Work around another nasty module on CPAN. :/ no warnings 'once'; $Template::Test::NO_FLUSH = 1; exit 0; Throwable000755000766000766 012215716241 16522 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTPFactory.pm100644000766000766 1351212215716241 20651 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwablepackage HTTP::Throwable::Factory; BEGIN { $HTTP::Throwable::Factory::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Factory::VERSION = '0.017'; } use Moose; use Sub::Exporter::Util (); use Sub::Exporter -setup => { exports => [ http_throw => Sub::Exporter::Util::curry_method('throw'), http_exception => Sub::Exporter::Util::curry_method('new_exception'), ], }; use Module::Runtime; sub throw { my $factory = shift; my $ident = (! ref $_[0]) ? shift(@_) : undef; my $arg = shift || {}; $factory->class_for($ident, $arg)->throw($arg); } sub new_exception { my $factory = shift; my $ident = (! ref $_[0]) ? shift(@_) : undef; my $arg = shift || {}; $factory->class_for($ident, $arg)->new($arg); } sub core_roles { return qw( HTTP::Throwable ); } sub extra_roles { return qw( HTTP::Throwable::Role::TextBody ); } sub roles_for_ident { my ($self, $ident) = @_; return "HTTP::Throwable::Role::Status::$ident"; } sub roles_for_no_ident { my ($self, $ident) = @_; return qw( HTTP::Throwable::Role::Generic HTTP::Throwable::Role::BoringText ); } sub base_class { 'Moose::Object' } sub class_for { my ($self, $ident) = @_; my @roles; if (defined $ident) { @roles = $self->roles_for_ident($ident); } else { @roles = $self->roles_for_no_ident; } Module::Runtime::use_module($_) for @roles; my $class = Moose::Meta::Class->create_anon_class( superclasses => [ $self->base_class ], roles => [ $self->core_roles, $self->extra_roles, @roles ], cache => 1, ); require MooseX::StrictConstructor; MooseX::StrictConstructor->import({ into => $class->name }); return $class->name; } 1; =pod =head1 NAME HTTP::Throwable::Factory - a factory that throws HTTP::Throwables for you =head1 VERSION version 0.017 =head1 OVERVIEW L is a role that makes it easy to build exceptions that, once thrown, can be turned into L-style HTTP responses. Because HTTP::Throwable and all its related roles are, well, roles, they can't be instantiated or thrown directly. Instead, they must be built into classes first. HTTP::Throwable::Factory takes care of this job, building classes out of the roles you need for the exception you want to throw. You can use the factory to either I or I an exception of either a I or I type. Building and throwing are very similar -- the only difference is whether or not the newly built object is thrown or returned. To throw an exception, use the C method on the factory. To return it, use the C method. In the examples below, we'll just use C. To throw a generic exception -- one where you must specify the status code and reason, and any other headers -- you pass C a hashref of arguments that will be passed to the exception class's constructor. HTTP::Throwable::Factory->throw({ status_code => 301, reason => 'Moved Permanently', additional_headers => [ Location => '/new', ], }); To throw a specific type of exception, include an exception type identifier, like this: HTTP::Throwable::Factory->throw(MovedPermanently => { location => '/new' }); The type identifier is (by default) the end of a role name in the form C. The full list of such included roles is given in L. =head2 Exports You can import routines called C and C that work like the C and C methods, respectively, but are not called as methods. For example: use HTTP::Throwable::Factory 'http_exception'; builder { mount '/old' => http_exception('Gone'), }; =head1 SUBCLASSING One of the big benefits of using HTTP::Throwable::Factory is that you can subclass it to change the kind of exceptions it provides. If you subclass it, you can change its behavior by overriding the following methods -- provided in the order of likelihood that you'd want to override them, most likely first. =head2 extra_roles This method returns a list of role names that will be included in any class built by the factory. By default, it includes only L to satisfy HTTP::Throwable's requirements for methods needed to build a body. This is the method you're most likely to override in a subclass. =head2 roles_for_ident =head2 roles_for_no_ident This methods convert the exception type identifier to a role to apply. For example, if you call: Factory->throw(NotFound => { ... }) ...then C is called with "NotFound" as its argument. If C is called I a type identifier, C is called. By default, C returns C and C returns L and L. =head2 base_class This is the base class that will be subclassed and into which all the roles will be composed. By default, it is L, the universal base Moose class. =head2 core_roles This method returns the roles that are expected to be applied to every HTTP::Throwable exception. This method's results might change over time, and you are encouraged I> to alter it. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: a factory that throws HTTP::Throwables for you changes_has_content.t100644000766000766 201112215716241 21635 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/xt/release#!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.017'; my $trial_token = '-TRIAL'; SKIP: { ok(-e $changes_file, "$changes_file file exists") or skip 'Changes is missing', 1; ok(_get_changes($newver), "$changes_file has content for $newver"); } done_testing; # _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit # by Jerome Quelin sub _get_changes { my $newver = shift; # parse changelog to find commit message open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; my $changelog = join('', <$fh>); close $fh; my @content = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented split /\n/, $changelog; shift @content; # drop the version line # drop unindented last line and trailing blank lines pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); # return number of non-blank lines return scalar @content; } Role000755000766000766 012215716241 17423 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/ThrowableNoBody.pm100644000766000766 226712215716241 21322 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Rolepackage HTTP::Throwable::Role::NoBody; BEGIN { $HTTP::Throwable::Role::NoBody::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::NoBody::VERSION = '0.017'; } use Moose::Role; sub body { return } sub body_headers { my ($self, $body) = @_; return [ 'Content-Length' => 0, ]; } sub as_string { $_[0]->status_line } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::NoBody - an exception with no body =head1 VERSION version 0.017 =head1 OVERVIEW This is a very simple role, implementing the required C, C, and C for L. When an HTTP::Throwable exception uses this role, its PSGI response will have no entity body. It will report a Content-Length of zero. It will stringify to its status line. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: an exception with no body Generic.pm100644000766000766 214312215716241 21475 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Rolepackage HTTP::Throwable::Role::Generic; BEGIN { $HTTP::Throwable::Role::Generic::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Generic::VERSION = '0.017'; } use Moose::Role; with 'HTTP::Throwable'; sub default_status_code { confess "generic HTTP::Throwable must be given status code in constructor"; } sub default_reason { confess "generic HTTP::Throwable must be given reason in constructor"; } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Generic - a generic built-by-hand exception =head1 VERSION version 0.017 =head1 DESCRIPTION This role is used (for boring internals-related reasons) when you throw an exception with no special roles mixed in. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: a generic built-by-hand exception Redirect.pm100644000766000766 266512215716241 21673 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Rolepackage HTTP::Throwable::Role::Redirect; BEGIN { $HTTP::Throwable::Role::Redirect::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Redirect::VERSION = '0.017'; } use Moose::Role; has 'location' => ( is => 'ro', isa => 'Str', required => 1, ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); push @$headers => ('Location' => $self->location); return $headers; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Redirect - an exception that is a redirect =head1 VERSION version 0.017 =head1 OVERVIEW This is an extremely simple method used by most of the 3xx series of exceptions. It adds a C attribute that will be provided as the Location header when the exception is converted to an HTTP message. Note that "MultipleChoices," the 300 status code is I currently a redirect, as its Location header is optional. This may change in the future of the semantics of this role are refined. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: an exception that is a redirect TextBody.pm100644000766000766 304012215716241 21660 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Rolepackage HTTP::Throwable::Role::TextBody; BEGIN { $HTTP::Throwable::Role::TextBody::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::TextBody::VERSION = '0.017'; } use Moose::Role; sub body { $_[0]->text_body } sub body_headers { my ($self, $body) = @_; return [ 'Content-Type' => 'text/plain', 'Content-Length' => length $body, ]; } sub as_string { $_[0]->body } requires 'text_body'; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::TextBody - an exception with a plaintext body =head1 VERSION version 0.017 =head1 OVERVIEW This is a very simple role, implementing the required C, C, and C for L. In turn, it requires that a C method be provided. When an HTTP::Throwable exception uses this role, its PSGI response will have a C content type and will send the result of calling its C method as the response body. It will also stringify to the text body. The role L can be useful to provide a C method that issues the C as the body. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: an exception with a plaintext body BoringText.pm100644000766000766 232412215716241 22207 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Rolepackage HTTP::Throwable::Role::BoringText; BEGIN { $HTTP::Throwable::Role::BoringText::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::BoringText::VERSION = '0.017'; } use Moose::Role; sub text_body { $_[0]->status_line } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::BoringText - provide the simplest text_body method possible =head1 VERSION version 0.017 =head1 OVERVIEW This role is as simple as can be. It provides a single method, C, which returns the result of calling the C method. This method exists so that exception classes can easily be compatible with the L role to provide a plain text body when converted to an HTTP message. Most of the core well-known exception types consume this method. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: provide the simplest text_body method possible Status000755000766000766 012215716241 20706 5ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/RoleGone.pm100644000766000766 356512215716241 22305 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::Gone; BEGIN { $HTTP::Throwable::Role::Status::Gone::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::Gone::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 410 } sub default_reason { 'Gone' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::Gone - 410 Gone =head1 VERSION version 0.017 =head1 DESCRIPTION The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise. The 410 response is primarily intended to assist the task of web maintenance by notifying the recipient that the resource is intentionally unavailable and that the server owners desire that remote links to that resource be removed. Such an event is common for limited-time, promotional services and for resources belonging to individuals no longer working at the server's site. It is not necessary to mark all permanently unavailable resources as "gone" or to keep the mark for any length of time -- that is left to the discretion of the server owner. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 410 Gone Found.pm100644000766000766 302512215716241 22457 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::Found; BEGIN { $HTTP::Throwable::Role::Status::Found::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::Found::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::Redirect', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 302 } sub default_reason { 'Found' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::Found - 302 Found =head1 VERSION version 0.017 =head1 DESCRIPTION The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field. The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). =head1 ATTRIBUTES =head2 location This is a required string, which will be used in the Location header when creating a PSGI response. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 302 Found Conflict.pm100644000766000766 354412215716241 23153 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::Conflict; BEGIN { $HTTP::Throwable::Role::Status::Conflict::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::Conflict::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 409 } sub default_reason { 'Conflict' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::Conflict - 409 Conflict =head1 VERSION version 0.017 =head1 DESCRIPTION The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough information for the user to recognize the source of the conflict. Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be possible and is not required. Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being used and the entity being PUT included changes to a resource which conflict with those made by an earlier (third-party) request, the server might use the 409 response to indicate that it can't complete the request. In this case, the response entity would likely contain a list of the differences between the two versions in a format defined by the response Content-Type. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 409 Conflict NotFound.pm100644000766000766 256612215716241 23151 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::NotFound; BEGIN { $HTTP::Throwable::Role::Status::NotFound::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::NotFound::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 404 } sub default_reason { 'Not Found' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::NotFound - 404 Not Found =head1 VERSION version 0.017 =head1 DESCRIPTION The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 404 Not Found SeeOther.pm100644000766000766 310712215716241 23123 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::SeeOther; BEGIN { $HTTP::Throwable::Role::Status::SeeOther::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::SeeOther::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::Redirect', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 303 } sub default_reason { 'See Other' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::SeeOther - 303 See Other =head1 VERSION version 0.017 =head1 DESCRIPTION The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be cacheable. The different URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 303 See Other UseProxy.pm100644000766000766 230012215716241 23175 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::UseProxy; BEGIN { $HTTP::Throwable::Role::Status::UseProxy::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::UseProxy::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::Redirect', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 305 } sub default_reason { 'Use Proxy' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::UseProxy - 305 Use Proxy =head1 VERSION version 0.017 =head1 DESCRIPTION The requested resource MUST be accessed through the proxy given by the Location field. The Location field gives the URI of the proxy. The recipient is expected to repeat this single request via the proxy. 305 responses MUST only be generated by origin servers. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 305 Use Proxy Forbidden.pm100644000766000766 251612215716241 23304 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::Forbidden; BEGIN { $HTTP::Throwable::Role::Status::Forbidden::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::Forbidden::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 403 } sub default_reason { 'Forbidden' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::Forbidden - 403 Forbidden =head1 VERSION version 0.017 =head1 DESCRIPTION The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 403 Forbidden ImATeapot.pm100644000766000766 373712215716241 23241 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::ImATeapot; BEGIN { $HTTP::Throwable::Role::Status::ImATeapot::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::ImATeapot::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', ); has 'short' => (is => 'ro', isa => 'Bool', default => 0); has 'stout' => (is => 'ro', isa => 'Bool', default => 0); sub default_status_code { 418 } sub default_reason { q{I'm a teapot} } my $TEAPOT = <<'END'; ( _ ) ) _,(_)._ (( I'M A LITTLE TEAPOT__X__ ___,(_______). ) ,'__. / \ /\_ /,' / |""| \ / / | | | |__| |,' / \`.| / `. : : / `. :.,' `-.________,-' END sub text_body { my $self = shift; my $base = $TEAPOT; my $msg = $self->short && $self->stout ? " SHORT AND STOUT" : $self->short ? " SHORT NOT STOUT" : $self->stout ? " MERELY STOUT" : " WITH A SPOUT"; $base =~ s/__X__/$msg/; return $base; } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::ImATeapot - 418 I'm a teapot =head1 VERSION version 0.017 =head1 DESCRIPTION This exception provides RFC2324 support, in accordance with section 2.3.3: Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout. Boolean attributes C and C are provided, and default to false. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 418 I'm a teapot BadGateway.pm100644000766000766 207212215716241 23415 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::BadGateway; BEGIN { $HTTP::Throwable::Role::Status::BadGateway::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::BadGateway::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 502 } sub default_reason { 'Bad Gateway' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::BadGateway - 502 Bad Gateway =head1 VERSION version 0.017 =head1 DESCRIPTION The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 502 Bad Gateway BadRequest.pm100644000766000766 205112215716241 23441 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::BadRequest; BEGIN { $HTTP::Throwable::Role::Status::BadRequest::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::BadRequest::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 400 } sub default_reason { 'Bad Request' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::BadRequest - 400 Bad Request =head1 VERSION version 0.017 =head1 DESCRIPTION The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 400 Bad Request NotModified.pm100644000766000766 537012215716241 23612 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::NotModified; BEGIN { $HTTP::Throwable::Role::Status::NotModified::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::NotModified::VERSION = '0.017'; } use Moose::Role; use Plack::Util (); with( 'HTTP::Throwable', 'HTTP::Throwable::Role::Redirect', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 304 } sub default_reason { 'Not Modified' } around 'as_psgi' => sub { my $next = shift; my $self = shift; my $psgi = $self->$next(); # MUST NOT have a message body, see below Plack::Util::header_set( $psgi->[1], 'Content-Length' => 0 ); Plack::Util::header_remove( $psgi->[1], 'Content-Type'); $psgi->[2] = []; $psgi; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::NotModified - 304 Not Modified =head1 VERSION version 0.017 =head1 DESCRIPTION If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields. The response MUST include the following header fields: =over 4 =item Date, unless its omission is required by section 14.18.1 If a clockless origin server obeys these rules, and proxies and clients add their own Date to any response received without one (as already specified by [RFC 2068], section 14.19), caches will operate correctly. =item ETag and/or Content-Location, if the header would have been sent in a 200 response to the same request =item Expires, Cache-Control, and/or Vary, if the field-value might differ from that sent in any previous response for the same variant =back If the conditional GET used a strong cache validator, the response SHOULD NOT include other entity-headers. Otherwise (i.e., the conditional GET used a weak validator), the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers. If a 304 response indicates an entity not currently cached, then the cache MUST disregard the response and repeat the request without the conditional. If a cache uses a received 304 response to update a cache entry, the cache MUST update the entry to reflect any new field values given in the response. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 304 Not Modified Unauthorized.pm100644000766000766 467312215716241 24077 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::Unauthorized; BEGIN { $HTTP::Throwable::Role::Status::Unauthorized::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::Unauthorized::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 401 } sub default_reason { 'Unauthorized' } has 'www_authenticate' => ( is => 'ro', isa => 'Str | ArrayRef[ Str ]', required => 1, ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); my $www_auth = $self->www_authenticate; if ( ref $www_auth ) { push @$headers => (map { ('WWW-Authenticate' => $_) } @$www_auth); } else { push @$headers => ('WWW-Authenticate' => $www_auth ); } $headers; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::Unauthorized - 401 Unauthorized =head1 VERSION version 0.017 =head1 DESCRIPTION The request requires user authentication. The response MUST include a WWW-Authenticate header field containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field. If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. =head1 ATTRIBUTES =head2 www_authenticate This is a required string or array of string that will be used to populate the 'WWW-Authenticate' header(s) when creating a PSGI response. =head1 SEE ALSO HTTP Authentication: Basic and Digest Access Authentication - L WWW-Authenticate Header - L =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 401 Unauthorized NotAcceptable.pm100644000766000766 413412215716241 24112 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::NotAcceptable; BEGIN { $HTTP::Throwable::Role::Status::NotAcceptable::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::NotAcceptable::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 406 } sub default_reason { 'Not Acceptable' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::NotAcceptable - 406 Not Acceptable =head1 VERSION version 0.017 =head1 DESCRIPTION The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request. Unless it was a HEAD request, the response SHOULD include an entity containing a list of available entity characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. Depending upon the format and the capabilities of the user agent, selection of the most appropriate choice MAY be performed automatically. However, this specification does not define any standard for such automatic selection. Note: HTTP/1.1 servers are allowed to return responses which are not acceptable according to the accept headers sent in the request. In some cases, this may even be preferable to sending a 406 response. User agents are encouraged to inspect the headers of an incoming response to determine if it is acceptable. If the response could be unacceptable, a user agent SHOULD temporarily stop receipt of more data and query the user for a decision on further actions. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 406 Not Acceptable GatewayTimeout.pm100644000766000766 227212215716241 24357 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::GatewayTimeout; BEGIN { $HTTP::Throwable::Role::Status::GatewayTimeout::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::GatewayTimeout::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 504 } sub default_reason { 'Gateway Timeout' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::GatewayTimeout - 504 Gateway Timeout =head1 VERSION version 0.017 =head1 DESCRIPTION The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 504 Gateway Timeout LengthRequired.pm100644000766000766 223412215716241 24327 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::LengthRequired; BEGIN { $HTTP::Throwable::Role::Status::LengthRequired::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::LengthRequired::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 411 } sub default_reason { 'Length Required' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::LengthRequired - 411 Length Required =head1 VERSION version 0.017 =head1 DESCRIPTION The server refuses to accept the request without a defined Content-Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 411 Length Required NotImplemented.pm100644000766000766 223212215716241 24327 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::NotImplemented; BEGIN { $HTTP::Throwable::Role::Status::NotImplemented::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::NotImplemented::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 501 } sub default_reason { 'Not Implemented' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::NotImplemented - 501 Not Implemented =head1 VERSION version 0.017 =head1 DESCRIPTION The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 501 Not Implemented RequestTimeout.pm100644000766000766 214412215716241 24404 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::RequestTimeout; BEGIN { $HTTP::Throwable::Role::Status::RequestTimeout::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::RequestTimeout::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 408 } sub default_reason { 'Request Timeout' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::RequestTimeout - 408 Request Timeout =head1 VERSION version 0.017 =head1 DESCRIPTION The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 408 Request Timeout MultipleChoices.pm100644000766000766 507612215716241 24505 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::MultipleChoices; BEGIN { $HTTP::Throwable::Role::Status::MultipleChoices::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::MultipleChoices::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 300 } sub default_reason { 'Multiple Choices' } has 'location' => ( is => 'ro', isa => 'Str' ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); if ( my $location = $self->location ) { push @$headers => ('Location' => $location); } $headers; }; no Moose; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::MultipleChoices - 300 Multiple Choices =head1 VERSION version 0.017 =head1 DESCRIPTION The requested resource corresponds to any one of a set of representations, each with its own specific location, and agent-driven negotiation information is being provided so that the user (or user agent) can select a preferred representation and redirect its request to that location. Unless it was a HEAD request, the response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field. Depending upon the format and the capabilities of the user agent, selection of the most appropriate choice MAY be performed automatically. However, this specification does not define any standard for such automatic selection. If the server has a preferred choice of representation, it SHOULD include the specific URI for that representation in the Location field; user agents MAY use the Location field value for automatic redirection. This response is cacheable unless indicated otherwise. =head1 ATTRIBUTES =head2 location This is an optional string, which, if supplied, will be used in the Location header when creating a PSGI response. Note that this is I (at present) the location attribute provided by the role L, which this role does not include. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 300 Multiple Choices MethodNotAllowed.pm100644000766000766 427512215716241 24625 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::MethodNotAllowed; BEGIN { $HTTP::Throwable::Role::Status::MethodNotAllowed::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::MethodNotAllowed::VERSION = '0.017'; } use Moose::Role; use Moose::Util::TypeConstraints; use List::AllUtils qw[ uniq ]; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); enum 'HTTP::Throwable::Type::Method' => qw[ OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT ]; # TODO: Consider adding a coersion to upper-case lower-cased strings and to # uniq the given input. -- rjbs, 2011-02-21 subtype 'HTTP::Throwable::Type::MethodList' => as 'ArrayRef' => where { (scalar uniq @{$_}) == (scalar @{$_}) }; sub default_status_code { 405 } sub default_reason { 'Method Not Allowed' } has 'allow' => ( is => 'ro', isa => 'HTTP::Throwable::Type::MethodList[ HTTP::Throwable::Type::Method ]', required => 1 ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); push @$headers => ('Allow' => join "," => @{ $self->allow }); $headers; }; no Moose::Role; no Moose::Util::TypeConstraints; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::MethodNotAllowed - 405 Method Not Allowed =head1 VERSION version 0.017 =head1 DESCRIPTION The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource. =head1 ATTRIBUTES =head2 allow This is an ArrayRef of HTTP methods, it is required and the HTTP methods will be type checked to ensure validity and uniqueness. =head1 SEE ALSO HTTP Methods - L =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 405 Method Not Allowed MovedPermanently.pm100644000766000766 307712215716241 24704 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::MovedPermanently; BEGIN { $HTTP::Throwable::Role::Status::MovedPermanently::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::MovedPermanently::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::Redirect', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 301 } sub default_reason { 'Moved Permanently' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::MovedPermanently - 301 Moved Permanently =head1 VERSION version 0.017 =head1 DESCRIPTION The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise. The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 301 Moved Permanently ExpectationFailed.pm100644000766000766 225012215716241 24773 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::ExpectationFailed; BEGIN { $HTTP::Throwable::Role::Status::ExpectationFailed::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::ExpectationFailed::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 417 } sub default_reason { 'Expectation Failed' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::ExpectationFailed - 417 Expectation Failed =head1 VERSION version 0.017 =head1 DESCRIPTION The expectation given in an Expect request-header field could not be met by this server, or, if the server is a proxy, the server has unambiguous evidence that the request could not be met by the next-hop server. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 417 Expectation Failed RequestURITooLong.pm100644000766000766 303612215716241 24720 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::RequestURITooLong; BEGIN { $HTTP::Throwable::Role::Status::RequestURITooLong::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::RequestURITooLong::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 414 } sub default_reason { 'Request-URI Too Long' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::RequestURITooLong - 414 Request-URI Too Long =head1 VERSION version 0.017 =head1 DESCRIPTION The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information, when the client has descended into a URI "black hole" of redirection (e.g., a redirected URI prefix that points to a suffix of itself), or when the server is under attack by a client attempting to exploit security holes present in some servers using fixed-length buffers for reading or manipulating the Request-URI. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 414 Request-URI Too Long TemporaryRedirect.pm100644000766000766 323612215716241 25054 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::TemporaryRedirect; BEGIN { $HTTP::Throwable::Role::Status::TemporaryRedirect::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::TemporaryRedirect::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', 'HTTP::Throwable::Role::Redirect', ); sub default_status_code { 307 } sub default_reason { 'Temporary Redirect' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::TemporaryRedirect - 307 Temporary Redirect =head1 VERSION version 0.017 =head1 DESCRIPTION The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field. The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s), since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 307 Temporary Redirect PreconditionFailed.pm100644000766000766 245612215716241 25155 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::PreconditionFailed; BEGIN { $HTTP::Throwable::Role::Status::PreconditionFailed::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::PreconditionFailed::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 412 } sub default_reason { 'Precondition Failed' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::PreconditionFailed - 412 Precondition Failed =head1 VERSION version 0.017 =head1 DESCRIPTION The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server. This response code allows the client to place preconditions on the current resource metainformation (header field data) and thus prevent the requested method from being applied to a resource other than the one intended. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 412 Precondition Failed ServiceUnavailable.pm100644000766000766 345412215716241 25156 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::ServiceUnavailable; BEGIN { $HTTP::Throwable::Role::Status::ServiceUnavailable::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::ServiceUnavailable::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 503 } sub default_reason { 'Service Unavailable' } has 'retry_after' => ( is => 'ro', isa => 'Str' ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); if ( my $retry = $self->retry_after ) { push @$headers => ('Retry-After' => $retry); } $headers; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::ServiceUnavailable - 503 Service Unavailable =head1 VERSION version 0.017 =head1 DESCRIPTION The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response. Note: The existence of the 503 status code does not imply that a server must use it when becoming overloaded. Some servers may wish to simply refuse the connection. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 503 Service Unavailable InternalServerError.pm100644000766000766 275112215716241 25366 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::InternalServerError; BEGIN { $HTTP::Throwable::Role::Status::InternalServerError::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::InternalServerError::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'StackTrace::Auto', ); sub default_status_code { 500 } sub default_reason { 'Internal Server Error' } has 'show_stack_trace' => ( is => 'ro', isa => 'Bool', default => 1 ); sub text_body { my ($self) = @_; my $out = $self->status_line; $out .= "\n\n" . $self->stack_trace->as_string if $self->show_stack_trace; return $out; } no Moose; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::InternalServerError - 500 Internal Server Error =head1 VERSION version 0.017 =head1 DESCRIPTION The server encountered an unexpected condition which prevented it from fulfilling the request. =head1 ATTRIBUTES =head2 show_stack_trace This is a boolean attribute which by default is true and indicates to the C method whether or not to show the stack trace in the output. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 500 Internal Server Error UnsupportedMediaType.pm100644000766000766 221412215716241 25535 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::UnsupportedMediaType; BEGIN { $HTTP::Throwable::Role::Status::UnsupportedMediaType::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::UnsupportedMediaType::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 415 } sub default_reason { 'Unsupported Media Type' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::UnsupportedMediaType - 415 Unsupported Media Type =head1 VERSION version 0.017 =head1 DESCRIPTION The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 415 Unsupported Media Type RequestEntityTooLarge.pm100644000766000766 342512215716241 25672 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::RequestEntityTooLarge; BEGIN { $HTTP::Throwable::Role::Status::RequestEntityTooLarge::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::RequestEntityTooLarge::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 413 } sub default_reason { 'Request Entity Too Large' } has 'retry_after' => ( is => 'ro', isa => 'Str' ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); if ( my $retry = $self->retry_after ) { push @$headers => ('Retry-After' => $retry); } $headers; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::RequestEntityTooLarge - 413 Request Entity Too Large =head1 VERSION version 0.017 =head1 DESCRIPTION The server is refusing to process a request because the request entity is larger than the server is willing or able to process. The server MAY close the connection to prevent the client from continuing the request. If the condition is temporary, the server SHOULD include a Retry-After header field to indicate that it is temporary and after what time the client MAY try again. =head1 ATTRIBUTES =head2 retry_after This is an optional string to be used to add a Retry-After header in the PSGI response. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 413 Request Entity Too Large HTTPVersionNotSupported.pm100644000766000766 264112215716241 26123 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::HTTPVersionNotSupported; BEGIN { $HTTP::Throwable::Role::Status::HTTPVersionNotSupported::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::HTTPVersionNotSupported::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 505 } sub default_reason { 'HTTP Version Not Supported' } no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::HTTPVersionNotSupported - 505 HTTP Version Not Supported =head1 VERSION version 0.017 =head1 DESCRIPTION The server does not support, or refuses to support, the HTTP protocol version that was used in the request message. The server is indicating that it is unable or unwilling to complete the request using the same major version as the client, other than with this error message. The response SHOULD contain an entity describing why that version is not supported and what other protocols are supported by that server. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 505 HTTP Version Not Supported ProxyAuthenticationRequired.pm100644000766000766 435312215716241 27133 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::ProxyAuthenticationRequired; BEGIN { $HTTP::Throwable::Role::Status::ProxyAuthenticationRequired::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::ProxyAuthenticationRequired::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 407 } sub default_reason { 'Proxy Authentication Required' } has 'proxy_authenticate' => ( is => 'ro', isa => 'Str | ArrayRef[ Str ]', required => 1, ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); my $proxy_auth = $self->proxy_authenticate; if ( ref $proxy_auth ) { push @$headers => (map { ('Proxy-Authenticate' => $_) } @$proxy_auth); } else { push @$headers => ('Proxy-Authenticate' => $proxy_auth ); } $headers; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::ProxyAuthenticationRequired - 407 Proxy Authentication Required =head1 VERSION version 0.017 =head1 DESCRIPTION This code is similar to 401 (Unauthorized), but indicates that the client must first authenticate itself with the proxy. The proxy MUST return a Proxy-Authenticate header field containing a challenge applicable to the proxy for the requested resource. The client MAY repeat the request with a suitable Proxy-Authorization header field. =head1 ATTRIBUTES =head2 proxy_authenticate This is a required string or array of strings that will be used to populate the 'Proxy-Authenticate' header(s) when creating a PSGI response. =head1 SEE ALSO HTTP Authentication: Basic and Digest Access Authentication - L Proxy-Authenticate Header - L =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 407 Proxy Authentication Required RequestedRangeNotSatisfiable.pm100644000766000766 401212215716241 27147 0ustar00rjbsrjbs000000000000HTTP-Throwable-0.017/lib/HTTP/Throwable/Role/Statuspackage HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable; BEGIN { $HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable::AUTHORITY = 'cpan:STEVAN'; } { $HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable::VERSION = '0.017'; } use Moose::Role; with( 'HTTP::Throwable', 'HTTP::Throwable::Role::BoringText', ); sub default_status_code { 416 } sub default_reason { 'Requested Range Not Satisfiable' } has 'content_range' => ( is => 'ro', isa => 'Str' ); around 'build_headers' => sub { my $next = shift; my $self = shift; my $headers = $self->$next( @_ ); if ( my $content_range = $self->content_range ) { push @$headers => ('Content-Range' => $content_range); } $headers; }; no Moose::Role; 1; =pod =head1 NAME HTTP::Throwable::Role::Status::RequestedRangeNotSatisfiable - 416 Requested Range Not Satisfiable =head1 VERSION version 0.017 =head1 DESCRIPTION A server SHOULD return a response with this status code if a request included a Range request-header field, and none of the range-specifier values in this field overlap the current extent of the selected resource, and the request did not include an If-Range request-header field. (For byte-ranges, this means that the first-byte-pos of all of the byte-range-spec values were greater than the current length of the selected resource.) When this status code is returned for a byte-range request, the response SHOULD include a Content-Range entity-header field specifying the current length of the selected resource. This response MUST NOT use the multipart/byteranges content-type. =head1 AUTHORS =over 4 =item * Stevan Little =item * Ricardo Signes =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ # ABSTRACT: 416 Requested Range Not Satisfiable