{
    "mode": "perldoc",
    "parameter": "WWW::Curl",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/WWW%3A%3ACurl/json",
    "generated": "2026-06-12T13:49:56Z",
    "synopsis": "use WWW::Curl;\nprint $WWW::Curl::VERSION;",
    "sections": {
        "NAME": {
            "content": "WWW::Curl - Perl extension interface for libcurl\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use WWW::Curl;\nprint $WWW::Curl::VERSION;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "WWW::Curl is a Perl extension interface for libcurl.\n",
            "subsections": []
        },
        "DOCUMENTATION": {
            "content": "This module provides a Perl interface to libcurl. It is not intended to be a standalone module\nand because of this, the main libcurl documentation should be consulted for API details at\n<http://curl.haxx.se>. The documentation you're reading right now only contains the Perl\nspecific details, some sample code and the differences between the C API and the Perl one.\n\nWWW::Curl::Easy\nThe name might be confusing, it originates from libcurl. This is not an ::Easy module in the\nsense normally used on CPAN.\n\nHere is a small snippet of making a request with WWW::Curl::Easy.\n\nuse strict;\nuse warnings;\nuse WWW::Curl::Easy;\n\nmy $curl = WWW::Curl::Easy->new;\n\n$curl->setopt(CURLOPTHEADER,1);\n$curl->setopt(CURLOPTURL, 'http://example.com');\n\n# A filehandle, reference to a scalar or reference to a typeglob can be used here.\nmy $responsebody;\n$curl->setopt(CURLOPTWRITEDATA,\\$responsebody);\n\n# Starts the actual request\nmy $retcode = $curl->perform;\n\n# Looking at the results...\nif ($retcode == 0) {\nprint(\"Transfer went ok\\n\");\nmy $responsecode = $curl->getinfo(CURLINFOHTTPCODE);\n# judge result and next action based on $responsecode\nprint(\"Received response: $responsebody\\n\");\n} else {\n# Error code, type of error, error message\nprint(\"An error happened: $retcode \".$curl->strerror($retcode).\" \".$curl->errbuf.\"\\n\");\n}\n\nSee curleasysetopt(3) for details of \"setopt()\".\n\nWWW::Curl::Multi\nuse strict;\nuse warnings;\nuse WWW::Curl::Easy;\nuse WWW::Curl::Multi;\n\nmy %easy;\nmy $curl = WWW::Curl::Easy->new;\nmy $curlid = '13'; # This should be a handle unique id.\n$easy{$curlid} = $curl;\nmy $activehandles = 0;\n\n$curl->setopt(CURLOPTPRIVATE,$curlid);\n# do the usual configuration on the handle\n...\n\nmy $curlm = WWW::Curl::Multi->new;\n\n# Add some easy handles\n$curlm->addhandle($curl);\n$activehandles++;\n\nwhile ($activehandles) {\nmy $activetransfers = $curlm->perform;\nif ($activetransfers != $activehandles) {\nwhile (my ($id,$returnvalue) = $curlm->inforead) {\nif ($id) {\n$activehandles--;\nmy $actualeasyhandle = $easy{$id};\n# do the usual result/error checking routine here\n...\n# letting the curl handle get garbage collected, or we leak memory.\ndelete $easy{$id};\n}\n}\n}\n}\n\nThis interface is different than what the C API does. $curlm->perform is non-blocking and\nperforms requests in parallel. The method does a little work and then returns control, therefor\nit has to be called periodically to get the job done. It's return value is the number of\nunfinished requests.\n\nWhen the number of unfinished requests changes compared to the number of active handles,\n$curlm->inforead should be checked for finished requests. It returns one handle and it's return\nvalue at a time, or an empty list if there are no more finished requests. $curlm->inforead\ncalls removehandle on the given easy handle automatically, internally. The easy handle will\nstill remain available until it goes out of scope, this action just detaches it from multi.\n\nPlease make sure that the easy handle does not get garbage collected until after the multi\nhandle finishes processing it, or bad things happen.\n\nThe multi handle does not need to be cleaned up, when it goes out of scope it calls the required\ncleanup methods automatically.\n\nIt is possible to use $curlm->addhandle to add further requests to be processed after\n$curlm->perform has been called. WWW::Curl::Multi doesn't care about the order. It is possible\nto process all requests for a multi handle and then add a new batch of easy handles for\nprocessing.\n\nWWW::Curl::Share\nuse WWW::Curl::Share;\nmy $curlsh = new WWW::Curl::Share;\n$curlsh->setopt(CURLSHOPTSHARE, CURLLOCKDATACOOKIE);\n$curlsh->setopt(CURLSHOPTSHARE, CURLLOCKDATADNS);\n$curl->setopt(CURLOPTSHARE, $curlsh);\n$curlsh->setopt(CURLSHOPTUNSHARE, CURLLOCKDATACOOKIE);\n$curlsh->setopt(CURLSHOPTUNSHARE, CURLLOCKDATADNS);\n\nWWW::Curl::Share is an extension to WWW::Curl::Easy which makes it possible to use a single\ncookies/dns cache for several Easy handles.\n\nIt's usable methods are:\n\n$curlsh = new WWW::Curl::Share\nThis method constructs a new WWW::Curl::Share object.\n\n$curlsh->setopt(CURLSHOPTSHARE, $value );\nEnables share for:\nCURLLOCKDATACOOKIE   use single cookies database\nCURLLOCKDATADNS      use single DNS cache\n$curlsh->setopt(CURLSHOPTUNSHARE, $value );\nDisable share for given $value (see CURLSHOPTSHARE)\n\n$curlsh->strerror( ErrNo )\nThis method returns a string describing the CURLSHcode error\ncode passed in the argument errornum.\n\nThis is how you enable sharing for a specific WWW::Curl::Easy handle:\n\n$curl->setopt(CURLOPTSHARE, $curlsh)\nAttach share object to WWW::Curl::Easy instance\n\nWWW::Curl::Form\nuse WWW::Curl::Form;\nmy $curlf = WWW::Curl::Form->new;\n$curlf->formaddfile($filename, 'attachment', \"multipart/form-data\");\n$curlf->formadd(\"FIELDNAME\", \"VALUE\");\n\n$curl->setopt(CURLOPTHTTPPOST, $curlf);\n\nIts usable methods are:\n\n$curlf = new WWW::Curl::Form\nThis method constructs a new WWW::Curl::Form object.\n\n$curlf->formadd(FIELDNAME, VALUE)\nThis method adds a field with a given value, to the form that is being submitted.\n\n$curlf->formaddfile(FILENAME, DESCRIPTION, TYPE)\nThis method will add a file to the form. The description is the name of the field\nthat you form expects the data to be submitted in.\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "curleasysetopt\nMost of the options should work, however some might not. Please send reports, tests and\npatches to fix those.\n\ncurleasyescape\nNot implemented. Since equivalent Perl code is easily produced, this method will only made\navailable for interface completeness, if ever.\n\ncurleasyinit\nUsed only internally. The standard Perl way of initializing an object should be used, \"my\n$curl = WWW::Curl::Easy->new;\".\n\ncurleasycleanup\nUsed only internally. Curl object cleanup happens when the handle goes out of scope.\n\ncurleasyduphandle\nShould be working for most cases, however do not change the value of options which accept a\nlist/arrayref value on a duped handle, otherwise memory leaks or crashes will happen. This\nbehaviour will be fixed in the future.\n\ncurleasypause\nNot implemented.\n\ncurleasyreset\nNot implemented.\n\ncurleasyunescape\nNot implemented. Trivial Perl replacements are available.\n\ncurlescape\nNot implemented and won't be as this method is considered deprecated.\n\ncurlformadd\nSeems to be working.\n\ncurlformaddfile\nSeems to be working.\n\ncurlformfree\nUsed internally. Not exposed through the public API, as this call has no relevance to Perl\ncode.\n\ncurlfree\nUsed internally. Not exposed through the public API, as this call has no relevance to Perl\ncode.\n\ncurlgetdate\nNot implemented. This function is easily replaced by Perl code and as such, most likely it\nwon't be implemented.\n\ncurlglobalcleanup\nOnly used internally, not exposed through the public API.\n\ncurlglobalinit\nOnly used internally, not exposed through the public API.\n\ncurlglobalinitmem\nNot implemented.\n\ncurlglobalcleanup\nOnly used internally and called automatically upon exit.\n\ncurlslistappend\nOnly used internally, not exposed through the public API.\n\ncurlslistfreeall\nOnly used internally, not exposed through the public API.\n\ncurlunescape\nNot implemented and won't be, as this method is considered deprecated.\n\ncurlversion\nSeems to work.\n\ncurlversioninfo\nNot yet implemented.\n\ncurlmulti*\nMost methods are either not exposed through the WWW::Curl::Multi API or they behave\ndifferently than it's C counterpart. Please see the section about WWW::Curl::Multi above.\n\ncurlmultifdset\nThis method returns three arrayrefs: the read, write and exception fds libcurl knows about.\nIn the case of no file descriptors in the given set, an empty array is returned.\n",
            "subsections": []
        },
        "NUANCES": {
            "content": "",
            "subsections": [
                {
                    "name": "Header output for redirects",
                    "content": "It might be surprising that if \"CURLOPTFOLLOWLOCATION\" is set and header output was enabled,\nheaders show up for all http responses. The reasoning behind that and possible code adjustments\nare outlined here: <https://rt.cpan.org/Ticket/Display.html?id=61569>.\n\nCURLOPTPRIVATE\nDespite what the libcurl manual says, in Perl land, only string values are suitable for this\noption.\n"
                }
            ]
        },
        "ADDITIONAL METHODS": {
            "content": "",
            "subsections": [
                {
                    "name": "On WWW::Curl::Easy objects",
                    "content": "pushopt\nLike \"setopt\" but instead of overriding any previously set values it adds it to the end. Can\nbe used with \"CURLOPTHTTPHEADER\", \"CURLOPTQUOTE\" and \"CURLOPTPOSTQUOTE\".\n"
                }
            ]
        },
        "USAGE CASES": {
            "content": "WWW::Curl is a thin binding on top of libcurl, to make using libcurl possible from Perl land.\nBecause of this, the module is less like Perl and more like C in coding style.\n\nThere is a new module, <http://search.cpan.org/perldoc?WWW::Curl::Simple>, which wraps this\nmodule into a more Perlish and userfriendly package.\n\nThe standard Perl WWW module, LWP should probably be used in most cases to work with HTTP or FTP\nfrom Perl. However, there are some cases where LWP doesn't perform well. One is speed and the\nother is parallelism. WWW::Curl is much faster, uses much less CPU cycles and it's capable of\nnon-blocking parallel requests.\n\nIn some cases, for example when building a web crawler, cpu usage and parallel downloads are\nimportant considerations. It can be desirable to use WWW::Curl to do the heavy-lifting of a\nlarge number of downloads and wrap the resulting data into a Perl-friendly structure by\nHTTP::Response or use WWW::Curl::Simple to do that for you.\n",
            "subsections": []
        },
        "CHANGES": {
            "content": "Version 4.01 - 4.07 adds several bugfixes and extends functionality coverage. See Changes file.\n\nVersion 4.00 added new documentation, the build system changed to Module::Install, the test\nsuite was rewritten to use Test::More, a new calling syntax for WWW::Curl::Multi was added,\nmemory leak and other bugfixes added, Perl 5.6 and libcurl 7.10.8 as minimum requirements for\nthis module were set.\n\nVersion 3.12 is a bugfix for a missing Share.pm.in file in the release.\n\nVersion 3.11 added WWW::Curl::Share.\n\nVersion 3.10 adds the WWW::Curl::Share interface by Anton Federov and large file options after a\ncontribution from Mark Hindley.\n\nVersion 3.02 adds some backwards compatibility for scripts still using 'WWW::Curl::easy' names.\n\nVersion 3.01 added some support for pre-multi versions of libcurl.\n\nVersion 3.00 adds WWW::Curl::Multi interface, and new module names following perl conventions\n(WWW::Curl::Easy rather than WWW::Curl::easy), by Sebastian Riedel <sri at cpan.org>.\n\nVersion 2.00 of WWW::Curl::easy is a renaming of the previous version (named Curl::easy), to\nfollow CPAN naming guidelines, by Cris Bailiff.\n\nVersions 1.30, a (hopefully) threadable, object-oriented, multiple-callback compatible version\nof Curl::easy was substantially reworked from the previous Curl::easy release (1.21) by Cris\nBailiff.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Currently maintained by Cris Bailiff <c.bailiff+curl at devsecure.com> and Balint Szilakszi\n<szbalint at cpan.org>.\n\nOriginal Author Georg Horn <horn@koblenz-net.de>, with additional callback, pod and test work by\nCris Bailiff <c.bailiff+curl@devsecure.com> and Forrest Cahoon <forrest.cahoon@merrillcorp.com>.\nSebastian Riedel added ::Multi and Anton Fedorov (datacompboy <at> mail.ru) added ::Share.\nBalint Szilakszi repackaged the module into a more modern form.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 2000-2005,2008-2014 Daniel Stenberg, Cris Bailiff, Sebastian Riedel, Balint\nSzilakszi et al.\n\nYou may opt to use, copy, modify, merge, publish, distribute and/or sell copies of the Software,\nand permit persons to whom the Software is furnished to do so, under the terms of the MIT\nlicense.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "<http://curl.haxx.se>\n\n<http://search.cpan.org/perldoc?WWW::Curl::Simple>\n",
            "subsections": [
                {
                    "name": "libcurl",
                    "content": "The development source code is also available:\n<http://github.com/szbalint/WWW--Curl/tree/master>\n"
                }
            ]
        }
    },
    "summary": "WWW::Curl - Perl extension interface for libcurl",
    "flags": [],
    "examples": [],
    "see_also": []
}