WWW-Curl-Simple-0.100191/000755 000765 000024 00000000000 12252507161 015344 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/Changes000644 000765 000024 00000006765 12252507161 016655 0ustar00andreasstaff000000 000000 Revision history for WWW-Curl-Simple 0.100191 2013-12-13 11:34:55 Asia/Bangkok - Fix #10: Update pod to reflect changed default value 0.100190 2013-10-28 21:11:09 America/Lima - Use immutable classes, thanks @haarg 0.100189 2013-09-02 11:19:11 Asia/Bangkok - No longer use new constants, use variables instead. Properly fix it for older libcurls I hope :P 0.100188 2013-08-28 09:12:03 Asia/Bangkok - Check for existance of CURLPROTO_HTTP before attempting to use it, should fix us so we work better with older libcurls again. 0.100187 2013-08-10 17:53:22 Asia/Bangkok - Change SYNOPSIS to work with Test::Synopsis - Fix #8 by reformating some old changelogs 0.100186 2013-07-15 16:10:09 Asia/Bangkok - Make it possible to turn OFF ssl peer verification The default is still to be secure, but it is now possible to be insecure if you want (neilbowers) - Default to follow 5 redirects The number can be changed, and redirect follows can be disabled (neilbowers) 0.100185 2012-02-23 11:08:36 Europe/Oslo - Merge more doc fixes from chromatic - fixes RT#70782 - Test can run in parallel now (no shared port number) 0.100184 2011-05-06 20:58:31 Asia/Bangkok - Merge pull request from chromatic to hopefully fix RT#60074 0.100183 2011-02-19 07:59:03 Europe/Oslo - Fix busy looping by nanosleeping in perform [thanks Eugene Y Jen for report] 0.100182 2011-01-19 05:30:33 Europe/Oslo - Documentation fixes [thanks chromatic] 0.100181 2010-01-18 09:28:41 Europe/Oslo - Note to self: Do not release when sleepy. Properly fix test-skipping. There is no such module as Net::Server::Base damnit. 0.100180 2010-01-18 08:50:01 Europe/Oslo - Skip one test if we don't have Net::Server::Base installed 0.100171 2010-01-17 12:05:39 Europe/Oslo - Attempt to support older versions of libcurl trough some magic 0.100170 2010-01-17 09:56:48 Europe/Oslo - Adjust a test that fails on some versions of libcurl 0.100160 2010-01-16 06:10:12 Europe/Oslo - Switch to filehandles for storing data, should perform better - Better documentation about return values [Marcus Ramberg] INCOMPAT: The return value for add_request is changed. It now returns the WWW::Curl::Simple::Request-object that was added. - Added has_request and delete_request to help with multi-request handling [RT#46293] 0.05 2009-06-10 07:44:00+0200 New options: - timeout: Set timeout for content in seconds - connection_timeout: Set timeout for connection in seconds - fatal: (defaults to true), if false, will carp, not croak, on errors. 0.04 2009-05-25 13:06:00+0200 Set a default UserAgent header, since some services seem to require a UserAgent header. 0.03 2009-04-20 09:32:00+0200 Bump version. 0.02 2009-04-20 09:11:00+0200 INCOMPAT: Fix some compat issues with LWP::Parallel::UserAgent. We now return an hash like they do, with objects that have the same methods INCOMPAT: $curl->perform on a multi-request now returns objects that have ->request and ->response methods, instead of the ->response directly. Fix really bad response-fuckup. 0.01 2009-04-14 09:37:00+0200 First version, very basic interface. Does not support everything yet WWW-Curl-Simple-0.100191/dist.ini000644 000765 000024 00000000301 12252507161 017002 0ustar00andreasstaff000000 000000 name = WWW-Curl-Simple author = Andreas Marienborg license = Perl_5 copyright_holder = Andreas Marienborg [@ANDREMAR] prereq_skip = Net::Server name = WWW-Curl-Simple WWW-Curl-Simple-0.100191/lib/000755 000765 000024 00000000000 12252507161 016112 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/LICENSE000644 000765 000024 00000043675 12252507161 016370 0ustar00andreasstaff000000 000000 This software is copyright (c) 2013 by Andreas Marienborg. 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) 2013 by Andreas Marienborg. 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) 2013 by Andreas Marienborg. 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 WWW-Curl-Simple-0.100191/Makefile.PL000644 000765 000024 00000003232 12252507161 017316 0ustar00andreasstaff000000 000000 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "A Simpler interface to WWW::Curl", "AUTHOR" => "Andreas Marienborg ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "WWW-Curl-Simple", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "WWW::Curl::Simple", "PREREQ_PM" => { "Carp" => 0, "HTTP::Request" => 0, "HTTP::Response" => 0, "Moose" => 0, "Scalar::Util" => 0, "Time::HiRes" => "1.9705", "WWW::Curl::Easy" => 0, "WWW::Curl::Multi" => 0, "namespace::clean" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::Exception" => 0, "Test::More" => "0.96", "base" => 0, "strict" => 0, "warnings" => 0 }, "VERSION" => "0.100191", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Carp" => 0, "File::Spec" => 0, "HTTP::Request" => 0, "HTTP::Response" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Moose" => 0, "Scalar::Util" => 0, "Test::Exception" => 0, "Test::More" => "0.96", "Time::HiRes" => "1.9705", "WWW::Curl::Easy" => 0, "WWW::Curl::Multi" => 0, "base" => 0, "namespace::clean" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); WWW-Curl-Simple-0.100191/MANIFEST000644 000765 000024 00000001305 12252507161 016474 0ustar00andreasstaff000000 000000 Changes LICENSE MANIFEST META.json META.yml Makefile.PL README TODO dist.ini lib/WWW/Curl/Simple.pm lib/WWW/Curl/Simple/Request.pm t/00-compile.t t/00.load.t t/000-report-versions-tiny.t t/10.simple.t t/20.timeout.t t/Testserver.pm t/author-10.usage.multi.t t/author-10.usage.single.t t/author-20.non-fatal.t t/author-20.timeout-old.t t/author-30.max-redirects.t t/author-31.check-ssl-certs.t t/author-99.pua-compat.t t/certs t/release-changes_has_content.t t/release-cpan-changes.t t/release-pod-coverage.t t/release-pod-syntax.t t/release-synopsis.t xt/benchmarks/bench.pl xt/benchmarks/benchit.pl xt/benchmarks/i/curl-simple.pl xt/benchmarks/i/curl.pl xt/benchmarks/i/lwp.pl xt/benchmarks/n/curl-simple.pl WWW-Curl-Simple-0.100191/META.json000644 000765 000024 00000034266 12252507161 017000 0ustar00andreasstaff000000 000000 { "abstract" : "A Simpler interface to WWW::Curl", "author" : [ "Andreas Marienborg " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.132830", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "WWW-Curl-Simple", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "version" : "0.9901" } }, "runtime" : { "requires" : { "Carp" : "0", "HTTP::Request" : "0", "HTTP::Response" : "0", "Moose" : "0", "Scalar::Util" : "0", "Time::HiRes" : "1.9705", "WWW::Curl::Easy" : "0", "WWW::Curl::Multi" : "0", "namespace::clean" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::Exception" : "0", "Test::More" : "0.96", "base" : "0", "strict" : "0", "warnings" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/omega/www-curl-simple/issues" }, "homepage" : "https://github.com/omega/www-curl-simple", "repository" : { "type" : "git", "url" : "https://github.com/omega/www-curl-simple.git", "web" : "https://github.com/omega/www-curl-simple" } }, "version" : "0.100191", "x_Dist_Zilla" : { "perl" : { "version" : "5.016003" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@ANDREMAR/Git::GatherDir", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@ANDREMAR/CheckPrereqsIndexed", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@ANDREMAR/CheckExtraTests", "version" : null }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@ANDREMAR/@Filter/PruneCruft", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@ANDREMAR/@Filter/ManifestSkip", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@ANDREMAR/@Filter/MetaYAML", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@ANDREMAR/@Filter/License", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@ANDREMAR/@Filter/Readme", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@ANDREMAR/@Filter/ExtraTests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@ANDREMAR/@Filter/ExecDir", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@ANDREMAR/@Filter/ShareDir", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@ANDREMAR/@Filter/MakeMaker", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@ANDREMAR/@Filter/Manifest", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@ANDREMAR/@Filter/TestRelease", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@ANDREMAR/@Filter/ConfirmRelease", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@ANDREMAR/@Filter/UploadToCPAN", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@ANDREMAR/AutoPrereqs", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@ANDREMAR/MetaConfig", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@ANDREMAR/MetaJSON", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@ANDREMAR/NextRelease", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Repository", "name" : "@ANDREMAR/Repository", "version" : "0.19" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@ANDREMAR/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "script_finder" : [ ":ExecFiles" ] } }, "name" : "@ANDREMAR/Test::Compile", "version" : "2.037" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "name" : "@ANDREMAR/Test::CPAN::Changes", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::ReportVersions::Tiny", "name" : "@ANDREMAR/ReportVersions::Tiny", "version" : "1.10" }, { "class" : "Dist::Zilla::Plugin::ContributorsFromGit", "name" : "@ANDREMAR/ContributorsFromGit", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@ANDREMAR/PodSyntaxTests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@ANDREMAR/PodCoverageTests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FileFinder::Filter", "name" : "@ANDREMAR/OurFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@ANDREMAR/PkgVersion", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Test::Synopsis", "name" : "@ANDREMAR/Test::Synopsis", "version" : "2.000004" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@ANDREMAR/TestMoreWithSubtests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugin" : "@ANDREMAR", "finder" : [ "@ANDREMAR/OurFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::Encoding", "name" : "@ANDREMAR/Encoding", "version" : "0.02" }, { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.003" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@RJBS/Name", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@RJBS/Version", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/Prelude", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Synopsis", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Description", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Overview", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@RJBS/Stability", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Attributes", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Methods", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "Functions", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@RJBS/Leftovers", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@RJBS/postlude", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@RJBS/Authors", "version" : "4.003" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "Contributors", "version" : "0.006" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@RJBS/Legal", "version" : "4.003" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@RJBS/List", "version" : "4.003" } ] } }, "name" : "@ANDREMAR/PodWeaver", "version" : "4.002" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@ANDREMAR/@Git/Check", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "name" : "@ANDREMAR/@Git/Commit", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "name" : "@ANDREMAR/@Git/Tag", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "name" : "@ANDREMAR/@Git/Push", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@ANDREMAR/Git::NextVersion", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@ANDREMAR/GithubMeta", "version" : "0.42" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.006" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.006" } }, "x_contributors" : [ "Bj\u00f8rn-Olav Strand ", "Graham Knop ", "Marcus Ramberg ", "Neil Bowers ", "chromatic " ] } WWW-Curl-Simple-0.100191/META.yml000644 000765 000024 00000021772 12252507161 016626 0ustar00andreasstaff000000 000000 --- abstract: 'A Simpler interface to WWW::Curl' author: - 'Andreas Marienborg ' build_requires: File::Spec: 0 IO::Handle: 0 IPC::Open3: 0 Test::Exception: 0 Test::More: 0.96 base: 0 strict: 0 warnings: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.132830' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: WWW-Curl-Simple requires: Carp: 0 HTTP::Request: 0 HTTP::Response: 0 Moose: 0 Scalar::Util: 0 Time::HiRes: 1.9705 WWW::Curl::Easy: 0 WWW::Curl::Multi: 0 namespace::clean: 0 resources: bugtracker: https://github.com/omega/www-curl-simple/issues homepage: https://github.com/omega/www-curl-simple repository: https://github.com/omega/www-curl-simple.git version: 0.100191 x_Dist_Zilla: perl: version: 5.016003 plugins: - class: Dist::Zilla::Plugin::Git::GatherDir name: '@ANDREMAR/Git::GatherDir' version: 2.019 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@ANDREMAR/CheckPrereqsIndexed' version: 0.009 - class: Dist::Zilla::Plugin::CheckExtraTests name: '@ANDREMAR/CheckExtraTests' version: ~ - class: Dist::Zilla::Plugin::PruneCruft name: '@ANDREMAR/@Filter/PruneCruft' version: 5.006 - class: Dist::Zilla::Plugin::ManifestSkip name: '@ANDREMAR/@Filter/ManifestSkip' version: 5.006 - class: Dist::Zilla::Plugin::MetaYAML name: '@ANDREMAR/@Filter/MetaYAML' version: 5.006 - class: Dist::Zilla::Plugin::License name: '@ANDREMAR/@Filter/License' version: 5.006 - class: Dist::Zilla::Plugin::Readme name: '@ANDREMAR/@Filter/Readme' version: 5.006 - class: Dist::Zilla::Plugin::ExtraTests name: '@ANDREMAR/@Filter/ExtraTests' version: 5.006 - class: Dist::Zilla::Plugin::ExecDir name: '@ANDREMAR/@Filter/ExecDir' version: 5.006 - class: Dist::Zilla::Plugin::ShareDir name: '@ANDREMAR/@Filter/ShareDir' version: 5.006 - class: Dist::Zilla::Plugin::MakeMaker name: '@ANDREMAR/@Filter/MakeMaker' version: 5.006 - class: Dist::Zilla::Plugin::Manifest name: '@ANDREMAR/@Filter/Manifest' version: 5.006 - class: Dist::Zilla::Plugin::TestRelease name: '@ANDREMAR/@Filter/TestRelease' version: 5.006 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@ANDREMAR/@Filter/ConfirmRelease' version: 5.006 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@ANDREMAR/@Filter/UploadToCPAN' version: 5.006 - class: Dist::Zilla::Plugin::AutoPrereqs name: '@ANDREMAR/AutoPrereqs' version: 5.006 - class: Dist::Zilla::Plugin::MetaConfig name: '@ANDREMAR/MetaConfig' version: 5.006 - class: Dist::Zilla::Plugin::MetaJSON name: '@ANDREMAR/MetaJSON' version: 5.006 - class: Dist::Zilla::Plugin::NextRelease name: '@ANDREMAR/NextRelease' version: 5.006 - class: Dist::Zilla::Plugin::Repository name: '@ANDREMAR/Repository' version: 0.19 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@ANDREMAR/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: filename: t/00-compile.t module_finder: - ':InstallModules' script_finder: - ':ExecFiles' name: '@ANDREMAR/Test::Compile' version: 2.037 - class: Dist::Zilla::Plugin::Test::CPAN::Changes name: '@ANDREMAR/Test::CPAN::Changes' version: 0.008 - class: Dist::Zilla::Plugin::ReportVersions::Tiny name: '@ANDREMAR/ReportVersions::Tiny' version: 1.10 - class: Dist::Zilla::Plugin::ContributorsFromGit name: '@ANDREMAR/ContributorsFromGit' version: 0.006 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@ANDREMAR/PodSyntaxTests' version: 5.006 - class: Dist::Zilla::Plugin::PodCoverageTests name: '@ANDREMAR/PodCoverageTests' version: 5.006 - class: Dist::Zilla::Plugin::FileFinder::Filter name: '@ANDREMAR/OurFiles' version: 5.006 - class: Dist::Zilla::Plugin::PkgVersion name: '@ANDREMAR/PkgVersion' version: 5.006 - class: Dist::Zilla::Plugin::Test::Synopsis name: '@ANDREMAR/Test::Synopsis' version: 2.000004 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@ANDREMAR/TestMoreWithSubtests' version: 5.006 - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugin: '@ANDREMAR' finder: - '@ANDREMAR/OurFiles' plugins: - class: Pod::Weaver::Plugin::Encoding name: '@ANDREMAR/Encoding' version: 0.02 - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: 4.003 - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: 4.003 - class: Pod::Weaver::Section::Name name: '@RJBS/Name' version: 4.003 - class: Pod::Weaver::Section::Version name: '@RJBS/Version' version: 4.003 - class: Pod::Weaver::Section::Region name: '@RJBS/Prelude' version: 4.003 - class: Pod::Weaver::Section::Generic name: '@RJBS/Synopsis' version: 4.003 - class: Pod::Weaver::Section::Generic name: '@RJBS/Description' version: 4.003 - class: Pod::Weaver::Section::Generic name: '@RJBS/Overview' version: 4.003 - class: Pod::Weaver::Section::Generic name: '@RJBS/Stability' version: 4.003 - class: Pod::Weaver::Section::Collect name: Attributes version: 4.003 - class: Pod::Weaver::Section::Collect name: Methods version: 4.003 - class: Pod::Weaver::Section::Collect name: Functions version: 4.003 - class: Pod::Weaver::Section::Leftovers name: '@RJBS/Leftovers' version: 4.003 - class: Pod::Weaver::Section::Region name: '@RJBS/postlude' version: 4.003 - class: Pod::Weaver::Section::Authors name: '@RJBS/Authors' version: 4.003 - class: Pod::Weaver::Section::Contributors name: Contributors version: 0.006 - class: Pod::Weaver::Section::Legal name: '@RJBS/Legal' version: 4.003 - class: Pod::Weaver::Plugin::Transformer name: '@RJBS/List' version: 4.003 name: '@ANDREMAR/PodWeaver' version: 4.002 - class: Dist::Zilla::Plugin::Git::Check name: '@ANDREMAR/@Git/Check' version: 2.019 - class: Dist::Zilla::Plugin::Git::Commit name: '@ANDREMAR/@Git/Commit' version: 2.019 - class: Dist::Zilla::Plugin::Git::Tag name: '@ANDREMAR/@Git/Tag' version: 2.019 - class: Dist::Zilla::Plugin::Git::Push name: '@ANDREMAR/@Git/Push' version: 2.019 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@ANDREMAR/Git::NextVersion' version: 2.019 - class: Dist::Zilla::Plugin::GithubMeta name: '@ANDREMAR/GithubMeta' version: 0.42 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 5.006 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 5.006 x_contributors: - 'Bjørn-Olav Strand ' - 'Graham Knop ' - 'Marcus Ramberg ' - 'Neil Bowers ' - 'chromatic ' WWW-Curl-Simple-0.100191/README000644 000765 000024 00000000466 12252507161 016232 0ustar00andreasstaff000000 000000 This archive contains the distribution WWW-Curl-Simple, version 0.100191: A Simpler interface to WWW::Curl This software is copyright (c) 2013 by Andreas Marienborg. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. WWW-Curl-Simple-0.100191/t/000755 000765 000024 00000000000 12252507161 015607 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/TODO000644 000765 000024 00000000110 12252507161 016024 0ustar00andreasstaff000000 000000 - Add posibility for changing $req->agent to WWW::Curl::Simple somehow WWW-Curl-Simple-0.100191/xt/000755 000765 000024 00000000000 12252507161 015777 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/xt/benchmarks/000755 000765 000024 00000000000 12252507161 020114 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/xt/benchmarks/bench.pl000755 000765 000024 00000001761 12252507161 021540 0ustar00andreasstaff000000 000000 #!/usr/bin/perl use strict; use warnings; my $url = 'http://localhost/'; use Benchmark qw/cmpthese timethese/; use File::Basename qw(basename); use WWW::Curl::Easy; use LWP::Simple qw/get/; use WWW::Curl::Simple; sub curl { # Test with WWW::Curl::Easy # Setting the options my $curl = new WWW::Curl::Easy; $curl->setopt(CURLOPT_HEADER,1); $curl->setopt(CURLOPT_URL, $url); my $response_body; # NOTE - do not use a typeglob here. A reference to a typeglob is okay though. open (my $fileb, ">", \$response_body); $curl->setopt(CURLOPT_WRITEDATA,$fileb); # Starts the actual request my $retcode = $curl->perform; } sub curl_simple { # Test with WWW::Curl::Simple my $curl = WWW::Curl::Simple->new(); my $res = $curl->get($url); } sub lwp { # Test with LWP::Simple my $res = get($url); } my $results = timethese(shift || 100, { lwp => \&lwp, curl => \&curl, curl_simple => \&curl_simple, }); cmpthese($results); WWW-Curl-Simple-0.100191/xt/benchmarks/benchit.pl000755 000765 000024 00000000657 12252507161 022100 0ustar00andreasstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Benchmark::Apps; use File::Basename qw(basename); my $b = Benchmark::Apps->new( pretty_print => 1, iters => shift || 10 ); my $scripts = {}; my $folder = 'xt/benchmarks/i'; opendir(I, $folder) or die "Cannot opendir $folder: $!"; my @files = grep { !/^\./ } readdir(I); foreach (@files) { my $k = basename($_); $scripts->{$k} = $folder . "/" . $_; } $b->run(%$scripts); WWW-Curl-Simple-0.100191/xt/benchmarks/i/000755 000765 000024 00000000000 12252507161 020344 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/xt/benchmarks/n/000755 000765 000024 00000000000 12252507161 020351 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/xt/benchmarks/n/curl-simple.pl000644 000765 000024 00000000264 12252507161 023144 0ustar00andreasstaff000000 000000 #!/usr/bin/perl use WWW::Curl::Simple; my $n = shift || 10; while ($n) { my $curl = WWW::Curl::Simple->new(); my $res = $curl->get('http://localhost/'); $n--; } WWW-Curl-Simple-0.100191/xt/benchmarks/i/curl-simple.pl000755 000765 000024 00000000177 12252507161 023145 0ustar00andreasstaff000000 000000 #!/usr/bin/perl use WWW::Curl::Simple; my $curl = WWW::Curl::Simple->new(); my $res = $curl->get('http://www.google.com/'); WWW-Curl-Simple-0.100191/xt/benchmarks/i/curl.pl000755 000765 000024 00000000642 12252507161 021653 0ustar00andreasstaff000000 000000 #!/usr/bin/perl use WWW::Curl::Easy; # Setting the options my $curl = new WWW::Curl::Easy; $curl->setopt(CURLOPT_HEADER,1); $curl->setopt(CURLOPT_URL, 'http://www.google.com'); my $response_body; # NOTE - do not use a typeglob here. A reference to a typeglob is okay though. open (my $fileb, ">", \$response_body); $curl->setopt(CURLOPT_WRITEDATA,$fileb); # Starts the actual request my $retcode = $curl->perform;WWW-Curl-Simple-0.100191/xt/benchmarks/i/lwp.pl000755 000765 000024 00000000124 12252507161 021503 0ustar00andreasstaff000000 000000 #!/usr/bin/perl use LWP::Simple qw(get); my $res = get('http://www.google.com/'); WWW-Curl-Simple-0.100191/t/00-compile.t000644 000765 000024 00000001756 12252507161 017652 0ustar00andreasstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.037 use Test::More tests => 2 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'WWW/Curl/Simple.pm', 'WWW/Curl/Simple/Request.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; my @warnings; for my $lib (@module_files) { # see L open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; WWW-Curl-Simple-0.100191/t/00.load.t000644 000765 000024 00000000241 12252507161 017126 0ustar00andreasstaff000000 000000 #!perl -T use Test::More tests => 1; BEGIN { use_ok( 'WWW::Curl::Simple' ); } diag( "Testing WWW::Curl::Simple $WWW::Curl::Simple::VERSION, Perl $], $^X" ); WWW-Curl-Simple-0.100191/t/000-report-versions-tiny.t000644 000765 000024 00000005332 12252507161 022436 0ustar00andreasstaff000000 000000 use 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.10\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('Carp','any version') }; eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; eval { $v .= pmver('File::Spec','any version') }; eval { $v .= pmver('HTTP::Request','any version') }; eval { $v .= pmver('HTTP::Response','any version') }; eval { $v .= pmver('IO::Handle','any version') }; eval { $v .= pmver('IPC::Open3','any version') }; eval { $v .= pmver('Moose','any version') }; eval { $v .= pmver('Scalar::Util','any version') }; eval { $v .= pmver('Test::Exception','any version') }; eval { $v .= pmver('Test::More','0.96') }; eval { $v .= pmver('Time::HiRes','1.9705') }; eval { $v .= pmver('WWW::Curl::Easy','any version') }; eval { $v .= pmver('WWW::Curl::Multi','any version') }; eval { $v .= pmver('base','any version') }; eval { $v .= pmver('namespace::clean','any version') }; eval { $v .= pmver('strict','any version') }; 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; WWW-Curl-Simple-0.100191/t/10.simple.t000644 000765 000024 00000001401 12252507161 017500 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; use WWW::Curl::Simple; BEGIN { eval "use Net::Server::Single"; plan skip_all => 'Net::Server::Single is required for this test' if $@; } use t::Testserver; my $port = int(rand(1024) + 1024); my $pid = fork(); if (not defined $pid) { plan skip_all => "Fork not supported"; } elsif ($pid == 0) { ## In the child, do requests here? plan tests => 2; sleep(1); my $curl = WWW::Curl::Simple->new(timeout => 1); is($curl->timeout, 1); my $res = $curl->request(HTTP::Request->new(GET => 'http://localhost:' . $port)); is($res->content, "OK"); } else { ## in the parent my $serv = TestServer->new({ port => $port, log_level => 0 }); $serv->run; waitpid($pid, 0); } WWW-Curl-Simple-0.100191/t/20.timeout.t000644 000765 000024 00000002553 12252507161 017707 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w use strict; use Test::More; use Test::Exception; use WWW::Curl::Simple; BEGIN { eval "use Net::Server::Single"; plan skip_all => 'Net::Server::Single is required for this test' if $@; } my $port = int(rand(1024) + 1024); my @urls = ( 'http://localhost:' . $port, ); my $pid = fork(); if (not defined $pid) { plan skip_all => "Fork not supported"; } elsif ($pid == 0) { ## In the child, do requests here? plan tests => 3; sleep(1); { my $curl = WWW::Curl::Simple->new(timeout => 1); is($curl->timeout, 1); { $curl->add_request(HTTP::Request->new(GET => $_)) foreach (@urls); throws_ok { $curl->perform } qr/timeout was reached/i, "We throw proper timeout error"; } } { my $curl = WWW::Curl::Simple->new(timeout_ms => 1); { $curl->add_request(HTTP::Request->new(GET => $_)) foreach (@urls); throws_ok { $curl->perform } qr/(timeout was reached|use timeout_ms)/i, "We throw one of two proper exceptions"; } } } else { ## in the parent my $serv = TestServer->new({ port => $port, log_level => 0 }); $serv->run; waitpid($pid, 0); } package TestServer; use strict; use base qw(Net::Server::Single); sub process_request { my $self = shift; sleep 5; exit(0); } 1; WWW-Curl-Simple-0.100191/t/author-10.usage.multi.t000644 000765 000024 00000003630 12252507161 021752 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use Test::More; use WWW::Curl::Simple; my @urls = ( 'http://en.wikipedia.org/wiki/Main_Page', 'http://www.yahoo.com', 'http://www.startsiden.no', 'http://www.abcnyheter.no', 'http://www.cnn.com', 'http://www.bbc.co.uk', 'http://www.vg.no', 'http://www.perl.org', 'http://www.perl.com', ); plan tests => 11 + scalar(@urls) * 4; { my $curl = WWW::Curl::Simple->new(); $curl->add_request(HTTP::Request->new(GET => $_)) foreach (@urls); my @res = $curl->perform; foreach my $req (@res) { isa_ok($req, "WWW::Curl::Simple::Request"); my $res = $req->response; isa_ok($res, "HTTP::Response"); ok($res->is_success or $res->is_redirect, "we have success! " . $res->code); isa_ok($res->request, "HTTP::Request"); } } { my $curl = WWW::Curl::Simple->new(); my $req = $curl->add_request(HTTP::Request->new(GET => 'http://en.wikipedia.org/wiki/Main_Page')); ok($curl->has_request($req), "We can check for existance of a request"); isa_ok( $req, "WWW::Curl::Simple::Request", "We get the right index back from add_request", ); isa_ok( $curl->add_request(HTTP::Request->new(GET => 'http://www.yahoo.com')), "WWW::Curl::Simple::Request", "We get the right index back from our second add_request", ); my @res = $curl->perform; ok($curl->delete_request($req), "We can remove a request"); is($curl->_count_requests, 1, "We have removed one request"); foreach my $req (@res) { isa_ok($req, "WWW::Curl::Simple::Request"); my $res = $req->response; isa_ok($res, "HTTP::Response"); ok($res->is_success or $res->is_redirect, "we have success for " . $res->base . "! " . $res->status_line); } } WWW-Curl-Simple-0.100191/t/author-10.usage.single.t000644 000765 000024 00000002700 12252507161 022076 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use Test::More tests => 14; use WWW::Curl::Simple; my $curl = WWW::Curl::Simple->new(); { my $res = $curl->request(HTTP::Request->new(GET => 'http://en.wikipedia.org/wiki/Main_Page')); isa_ok($res, "HTTP::Response"); ok($res->is_success, "request suceeded"); like($res->content, qr/Wikipedia/); isa_ok($res->request, "HTTP::Request"); } { my $res = $curl->get('http://www.google.com/'); isa_ok($res, "HTTP::Response"); unlike($res->content, qr|^HTTP/1|); isa_ok($res->request, "HTTP::Request"); #like($res->content, qr|^|); is($res->content_type, "text/html"); } { # Test POST my $form = 's=jennifer+aniston'; my $res = $curl->post('http://wap.1881.no/?i=4854&showonly=1', $form); unless(ok($res->is_success, "request succeeded to 1881")) { diag($res->code . " " . $res->status_line); } isa_ok($res->request, "HTTP::Request"); } { my $res = $curl->request(HTTP::Request->new(GET => 'http://www.startsiden.no/sok/bilder/search/rss?rows=1&q=jens')); isa_ok($res, "HTTP::Response"); unless(ok($res->is_success, "request succeeded to bilder")) { diag($res->code . " " . $res->status_line); } like($res->content, qr/bilder/); isa_ok($res->request, "HTTP::Request"); } WWW-Curl-Simple-0.100191/t/author-20.non-fatal.t000644 000765 000024 00000001012 12252507161 021365 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use Test::More; use WWW::Curl::Simple; my @urls = ( 'http://en.wikipedia.org/wiki/Main_Page', 'http://www.yahoomypoo.com', ); plan tests => 1; my $curl = WWW::Curl::Simple->new(fatal => 0); { $curl->add_request(HTTP::Request->new(GET => $_)) foreach (@urls); my @res = $curl->perform; ok("we live! :p"); } WWW-Curl-Simple-0.100191/t/author-20.timeout-old.t000644 000765 000024 00000002710 12252507161 021756 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use lib qw(/Users/andremar/local/src/WWW-Curl-4.11/blib/lib); use Test::More; use Test::Exception; use WWW::Curl::Simple; my $port = int(rand(1024) + 1024); my @urls = ( 'http://localhost:' . $port, ); my $pid = fork(); if (not defined $pid) { plan skip_all => "Fork not supported"; } elsif ($pid == 0) { ## In the child, do requests here? plan tests => 3; sleep(1); { my $curl = WWW::Curl::Simple->new(timeout => 1); is($curl->timeout, 1); { $curl->add_request(HTTP::Request->new(GET => $_)) foreach (@urls); throws_ok { $curl->perform } qr/timeout was reached/i, "We throw proper timeout error"; } } { my $curl = WWW::Curl::Simple->new(timeout_ms => 1); { $curl->add_request(HTTP::Request->new(GET => $_)) foreach (@urls); throws_ok { $curl->perform } qr/(timeout was reached|use timeout_ms)/i, "We throw one of two proper exceptions"; } } } else { ## in the parent my $serv = TestServer->new({ port => $port, log_level => 0 }); $serv->run; waitpid($pid, 0); } package TestServer; use strict; use base qw(Net::Server::Single); sub process_request { my $self = shift; sleep 5; exit(0); } 1; WWW-Curl-Simple-0.100191/t/author-30.max-redirects.t000644 000765 000024 00000001435 12252507161 022267 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use Test::More tests => 3; use WWW::Curl::Simple; my $url = 'http://httpstat.us/302'; my $curl; my $response; { $curl = WWW::Curl::Simple->new(max_redirects => 0); $response = $curl->get($url); ok($response->code == 302); } # be nice to httpstat.us sleep(1); { $curl = WWW::Curl::Simple->new(max_redirects => 1); $response = $curl->get($url); ok($response->code == 200); } # be nice to httpstat.us sleep(1); { # default is 5 redirects, so this should work too $curl = WWW::Curl::Simple->new(); $response = $curl->get($url); ok($response->code == 200); } WWW-Curl-Simple-0.100191/t/author-31.check-ssl-certs.t000644 000765 000024 00000001561 12252507161 022513 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use Test::More tests => 3; use WWW::Curl::Simple; my $url = 'https://google.co.uk/robots.txt'; my $curl; my $response; { $curl = WWW::Curl::Simple->new( check_ssl_certs => 1, ssl_cert_bundle => 't/certs', ); eval { $response = $curl->get($url); }; ok($@ && !defined($response)); } { $curl = WWW::Curl::Simple->new(check_ssl_certs => 0); eval { $response = $curl->get($url); }; ok(!$@ && defined($response) && $response->code == 200); } { # default is 0 (i.e. don't check), so this should work too $curl = WWW::Curl::Simple->new(); $response = $curl->get($url); ok(!$@ && defined($response) && $response->code == 200); } WWW-Curl-Simple-0.100191/t/author-99.pua-compat.t000644 000765 000024 00000001420 12252507161 021577 0ustar00andreasstaff000000 000000 #!/usr/bin/perl -w BEGIN { unless ($ENV{AUTHOR_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for testing by the author'); } } use strict; use Test::More tests => 4; use WWW::Curl::Simple; my $pua = WWW::Curl::Simple->new(); #$pua->timeout(10); #$pua->in_order(1); { $pua->register(HTTP::Request->new(GET => 'http://en.wikipedia.org/wiki/Main_Page')); $pua->register(HTTP::Request->new(GET => 'http://www.yahoo.com')); my $results = $pua->wait; foreach (keys %$results) { my $req = $results->{$_}; isa_ok($req, "WWW::Curl::Simple::Request"); ok($req->response->is_success or $req->response->is_redirect, "we have success! " . $req->response->code ); } } WWW-Curl-Simple-0.100191/t/certs000644 000765 000024 00000000000 12252507161 016640 0ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/t/release-changes_has_content.t000644 000765 000024 00000002251 12252507161 023407 0ustar00andreasstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.100191'; 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; } WWW-Curl-Simple-0.100191/t/release-cpan-changes.t000644 000765 000024 00000000521 12252507161 021737 0ustar00andreasstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More 0.96 tests => 2; use_ok('Test::CPAN::Changes'); subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; done_testing(); WWW-Curl-Simple-0.100191/t/release-pod-coverage.t000644 000765 000024 00000000765 12252507161 021775 0ustar00andreasstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); WWW-Curl-Simple-0.100191/t/release-pod-syntax.t000644 000765 000024 00000000450 12252507161 021517 0ustar00andreasstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } 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(); WWW-Curl-Simple-0.100191/t/release-synopsis.t000644 000765 000024 00000000456 12252507161 021306 0ustar00andreasstaff000000 000000 #!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Synopsis"; plan skip_all => "Test::Synopsis required for testing synopses" if $@; all_synopsis_ok(); WWW-Curl-Simple-0.100191/t/Testserver.pm000644 000765 000024 00000000343 12252507161 020313 0ustar00andreasstaff000000 000000 package TestServer; use strict; use base qw(Net::Server::Single); sub process_request { my $self = shift; print "HTTP/1.0 200 OK\n"; print "Content-Length: 2\n"; print "\n"; print "OK"; exit(0); } 1; WWW-Curl-Simple-0.100191/lib/WWW/000755 000765 000024 00000000000 12252507161 016576 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/lib/WWW/Curl/000755 000765 000024 00000000000 12252507161 017503 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/lib/WWW/Curl/Simple/000755 000765 000024 00000000000 12252507161 020734 5ustar00andreasstaff000000 000000 WWW-Curl-Simple-0.100191/lib/WWW/Curl/Simple.pm000644 000765 000024 00000017063 12252507161 021301 0ustar00andreasstaff000000 000000 package WWW::Curl::Simple; { $WWW::Curl::Simple::VERSION = '0.100191'; } # ABSTRACT: A Simpler interface to WWW::Curl use Moose; use HTTP::Request; use HTTP::Response; use Carp qw/croak carp/; use WWW::Curl::Simple::Request; use WWW::Curl::Multi; use WWW::Curl::Easy; use Time::HiRes 1.9705 qw/nanosleep/; #use base 'LWP::Parallel::UserAgent'; use namespace::clean -except => 'meta'; sub request { my ($self, $req) = @_; my $curl = WWW::Curl::Simple::Request->new(simple_ua => $self, request => $req); # Starts the actual request return $curl->perform; } sub get { my ($self, $uri) = @_; return $self->request(HTTP::Request->new(GET => $uri)); } sub post { my ($self, $uri, $form) = @_; return $self->request(HTTP::Request->new(POST => $uri, undef, $form)); } has _requests => ( traits => ['Array'], is => 'ro', isa => 'ArrayRef[WWW::Curl::Simple::Request]', handles => { _add_request => 'push', requests => 'elements', _find_request => 'first', _count_requests => 'count', _get_request => 'get', _delete_request => 'delete', }, default => sub { [] }, ); sub add_request { my ($self, $req) = @_; $req = WWW::Curl::Simple::Request->new(simple_ua => $self, request => $req); $self->_add_request($req); return $req; } __PACKAGE__->meta->add_package_symbol('®ister', __PACKAGE__->meta->get_package_symbol('&add_request') ); sub has_request { my ($self, $req) = @_; $self->_find_request(sub { $_ == $req }); } sub delete_request { my ($self, $req) = @_; return unless $self->has_request($req); # need to find the index my $c = $self->_count_requests; while ($c--) { $self->_delete_request($c) if ($self->_get_request($c) == $req); } return 1; } sub perform { my ($self) = @_; my $curlm = WWW::Curl::Multi->new; my %reqs; my $i = 0; foreach my $req ($self->requests) { $i++; my $curl = $req->easy; # we set this so we have the ref later on $curl->setopt(CURLOPT_PRIVATE, $i); # here we also mangle all requests based on options # XXX: Should re-factor this to be a metaclass/trait on the attributes, # and a general method that takes all those and applies the proper setopt # calls if ($self->timeout_ms) { unless ($WWW::Curl::Easy::CURLOPT_TIMEOUT_MS) { croak( "Your trying to use timeout_ms, but your libcurl is apperantly older than 7.16.12."); } $curl->setopt($WWW::Curl::Easy::CURLOPT_TIMEOUT_MS, $self->timeout_ms) if $self->timeout_ms; $curl->setopt($WWW::Curl::Easy::CURLOPT_CONNECTTIMEOUT_MS, $self->connection_timeout_ms) if $self->connection_timeout_ms; } else { $curl->setopt(CURLOPT_TIMEOUT, $self->timeout) if $self->timeout; $curl->setopt(CURLOPT_CONNECTTIMEOUT, $self->connection_timeout) if $self->connection_timeout; } $curlm->add_handle($curl); $reqs{$i} = $req; } my @res; while ($i) { my $active_transfers = $curlm->perform; if ($active_transfers != $i) { while (my ($id,$retcode) = $curlm->info_read) { if ($id) { $i--; my $req = $reqs{$id}; unless ($retcode == 0) { my $err = "Error during handling of request: " .$req->easy->strerror($retcode)." ". $req->request->uri; croak($err) if $self->fatal; carp($err) unless $self->fatal; } push(@res, $req); delete($reqs{$id}); } } } # To prevent busy-looping nanosleep(1); } return @res; } sub wait { my $self = shift; my @res = $self->perform(@_); # convert to a hash my %res; while (my $r = pop @res) { #warn "adding $r at " . scalar(@res); $res{scalar(@res)} = $r; } return \%res; } has 'timeout' => (is => 'ro', isa => 'Int'); has 'timeout_ms' => (is => 'ro', isa => 'Int'); has 'max_redirects' => (is => 'ro', isa => 'Int', default => 5); has 'check_ssl_certs' => (is => 'ro', isa => 'Int', default => 1); has 'ssl_cert_bundle' => (is => 'ro', isa => 'Str', predicate => 'has_cacert'); has 'connection_timeout' => (is => 'ro', isa => 'Int'); has 'connection_timeout_ms' => (is => 'ro', isa => 'Int'); has 'fatal' => (is => 'ro', isa => 'Bool', default => 1); __PACKAGE__->meta->make_immutable; 1; # End of WWW::Curl::Simple __END__ =pod =encoding UTF-8 =head1 NAME WWW::Curl::Simple - A Simpler interface to WWW::Curl =head1 VERSION version 0.100191 =head1 SYNOPSIS my $curl = WWW::Curl::Simple->new(); my $res = $curl->get('http://www.google.com/'); =head1 ATTRIBUTES =head2 timeout / timeout_ms Sets the timeout of individual requests, in seconds or milliseconds. =head2 max_redirects Sets the maximum number of redirects that should be transparently followed. Set this to 0 if you don't want to follow redirects. Default: 5. =head2 check_ssl_certs Specifies whether the underlying Curl library should check SSL certificates when making https requests. Defaults to 1 (i.e. do check certs, to err on safe side). =head2 ssl_cert_bundle Specifies the bundle to look for CA certificates in. Leave blank for system default, which should work if your libcurl is properly compiled. =head2 connection_timeout /connection_timeout_ms Sets the timeout of the connect phase of requests, in seconds or milliseconds. =head2 fatal Defaults to true, but if set to false, it will make failure in multi-requests warn instead of die. =head1 METHODS =head2 request($req) C<$req> should be a L object. If you have a URI string or object, look at the C method instead. Returns a L object. =head2 get($uri || URI) Accepts one parameter, which should be a reference to a URI object or a string representing a URI. Returns a L object. =head2 post($uri || URI, $form) Creates a L of type POST to C<$uri>, which can be a string or a URI object, and sets the form of the request to C<$form>. See L for more information on the format of C<$form>. =head2 add_request($req) Adds C<$req> (a L object) to the list of URLs to fetch. Returns a L object. =head2 register($req) An alias for C. =head2 has_request $request Will return true if C<$request> is one of the object's requests. =head2 delete_request $req Removes C<$req> from the object's list of requests. =head2 perform Does all the requests added with C and returns a list of L objects. =head2 wait This method is here to provide an easier transition from L. It is by no means a drop in replacement, but using C instead of C makes the return value more like that of LWP::UA. =head1 AUTHOR Andreas Marienborg =head1 CONTRIBUTORS =over 4 =item * Bjørn-Olav Strand =item * Graham Knop =item * Marcus Ramberg =item * Neil Bowers =item * chromatic =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Andreas Marienborg. 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 WWW-Curl-Simple-0.100191/lib/WWW/Curl/Simple/Request.pm000644 000765 000024 00000011222 12252507161 022720 0ustar00andreasstaff000000 000000 package WWW::Curl::Simple::Request; { $WWW::Curl::Simple::Request::VERSION = '0.100191'; } # ABSTRACT: A small class representing request/response use Moose; use WWW::Curl::Easy; use Carp qw/croak/; use Scalar::Util qw/weaken/; use namespace::clean -except => 'meta'; has 'agent' => (is => 'rw', isa => 'Str', required => 0, lazy_build => 1); sub _build_agent { return "WWW::Curl::Simple/" . ($WWW::Curl::Simple::VERSION ? $WWW::Curl::Simple::VERSION : '0.00'); } has 'body' => (is => 'rw', isa => 'ScalarRef', required => 0); has 'head' => (is => 'rw', isa => 'ScalarRef', required => 0); has 'request' => (is => 'ro', isa => 'HTTP::Request'); has 'simple_ua' => (is => 'ro', isa => 'WWW::Curl::Simple', weak_ref => 1); has 'easy' => (is => 'rw', isa => 'WWW::Curl::Easy', required => 0, lazy_build => 1); sub _build_easy { my ($self) = @_; my $req = $self->request; # return ourselves as a WWW::Curl::Easy-object? my $curl = new WWW::Curl::Easy; $curl->setopt(CURLOPT_NOPROGRESS,1); $curl->setopt(CURLOPT_USERAGENT, $self->agent); my $url = $req->uri->as_string; $curl->setopt(CURLOPT_URL, $url); if ($req->method eq 'POST') { $curl->setopt(CURLOPT_POST, 1); $curl->setopt(CURLOPT_POSTFIELDS, $req->content); } my @headers; foreach my $h (+$req->headers->header_field_names) { #warn "h: $h"; push(@headers, "$h: " . $req->header($h)); } if (scalar(@headers)) { $curl->setopt(CURLOPT_HTTPHEADER, \@headers); } my ($body_ref, $head_ref) = ('', ''); $self->body(\$body_ref); $self->head(\$head_ref); open (my $fileb, ">", \$body_ref); $curl->setopt(CURLOPT_WRITEDATA,$fileb); my $h = $self->head; open (my $fileh, ">", \$head_ref); $curl->setopt(CURLOPT_WRITEHEADER,$fileh); my $max_redirects = $self->simple_ua->max_redirects; # follow redirects for up to 5 hops if ($WWW::Curl::Easy::CURLPROTO_HTTP) { # This option and the CURLPROTO_HTTP was both added in 7.19.4 $curl->setopt($WWW::Curl::Easy::CURLOPT_REDIR_PROTOCOLS, $WWW::Curl::Easy::CURLPROTO_HTTP); } $curl->setopt(CURLOPT_FOLLOWLOCATION, $max_redirects > 0); $curl->setopt(CURLOPT_MAXREDIRS, $max_redirects); $curl->setopt(CURLOPT_AUTOREFERER, 1); # don't require certificate data to make https requests $curl->setopt(CURLOPT_SSL_VERIFYPEER, $self->simple_ua->check_ssl_certs); if ($self->simple_ua->has_cacert) { $curl->setopt(CURLOPT_CAINFO, $self->simple_ua->ssl_cert_bundle); } return $curl; } sub perform { my ($self) = @_; my $retcode = $self->easy->perform; # Looking at the results... if ($retcode == 0) { return $self->response; } else { croak("An error happened: ".$self->easy->strerror($retcode)." ($retcode)\n"); } } sub response { my ($self) = @_; # If we handled redirects, we'll have multiple headers from CURLOPT_WRITEHEADER, # so we strip off all but the last one before parsing it ${ $self->head } =~ s!^HTTP.*\r?\n\r?\nHTTP!HTTP!s; my $res = HTTP::Response->parse(${$self->head} . "\r" . ${$self->body}); $res->request($self->request); $res->content(${$self->body}); return $res; } __PACKAGE__->meta->make_immutable; 1; __END__ =pod =encoding UTF-8 =head1 NAME WWW::Curl::Simple::Request - A small class representing request/response =head1 VERSION version 0.100191 =head1 DESCRIPTION Just a way to collect things used by both single and multi, and some WWW::Curl setup. You shouldn't need to use this class anywhere, although C<< $curl->perform >> returns objects of this class. =head1 ATTRIBUTES =head2 agent A String that will be sent as the user-agent string. Defaults to "WWW::Curl::Simple/" plus the current version number. =head2 body The body of the response. =head2 head The head of the response. =head2 request The L object used to create this response. =head2 simple_ua The WWW::Curl::Simple instance that generated this request. =head2 easy The L object which created this response. =head1 METHODS =head2 perform Performs the actual request through L. Used mostly in single request land. Will croak on errors. =head2 response Returns a L that represents the response of this object. Also sets request on the response object to the original request object. =head1 AUTHOR Andreas Marienborg =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Andreas Marienborg. 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