{
    "content": [
        {
            "type": "text",
            "text": "# LWP::Protocol (perldoc)\n\n## NAME\n\nLWP::Protocol - Base class for LWP protocols\n\n## SYNOPSIS\n\npackage LWP::Protocol::foo;\nuse parent qw(LWP::Protocol);\n\n## DESCRIPTION\n\nThis class is used as the base class for all protocol implementations supported by the LWP\nlibrary.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **SEE ALSO**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "LWP::Protocol",
        "section": "",
        "mode": "perldoc",
        "summary": "LWP::Protocol - Base class for LWP protocols",
        "synopsis": "package LWP::Protocol::foo;\nuse parent qw(LWP::Protocol);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 56,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "LWP::Protocol - Base class for LWP protocols\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "package LWP::Protocol::foo;\nuse parent qw(LWP::Protocol);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This class is used as the base class for all protocol implementations supported by the LWP\nlibrary.\n\nWhen creating an instance of this class using \"LWP::Protocol::create($url)\", and you get an\ninitialized subclass appropriate for that access method. In other words, the \"create\" in\nLWP::Protocol function calls the constructor for one of its subclasses.\n\nAll derived \"LWP::Protocol\" classes need to override the \"request()\" method which is used to\nservice a request. The overridden method can make use of the \"collect()\" method to collect\ntogether chunks of data as it is received.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "The following methods and functions are provided:\n\nnew\nmy $prot = LWP::Protocol->new();\n\nThe LWP::Protocol constructor is inherited by subclasses. As this is a virtual base class this\nmethod should not be called directly.\n\ncreate\nmy $prot = LWP::Protocol::create($scheme)\n\nCreate an object of the class implementing the protocol to handle the given scheme. This is a\nfunction, not a method. It is more an object factory than a constructor. This is the function\nuser agents should use to access protocols.\n\nimplementor\nmy $class = LWP::Protocol::implementor($scheme, [$class])\n\nGet and/or set implementor class for a scheme. Returns '' if the specified scheme is not\nsupported.\n\nrequest\n$response = $protocol->request($request, $proxy, undef);\n$response = $protocol->request($request, $proxy, '/tmp/sss');\n$response = $protocol->request($request, $proxy, \\&callback, 1024);\n\nDispatches a request over the protocol, and returns a response object. This method needs to be\noverridden in subclasses. Refer to LWP::UserAgent for description of the arguments.\n\ncollect\nmy $res = $prot->collect(undef, $response, $collector); # stored in $response\nmy $res = $prot->collect($filename, $response, $collector);\nmy $res = $prot->collect(sub { ... }, $response, $collector);\n\nCollect the content of a request, and process it appropriately into a scalar, file, or by\ncalling a callback. If the first parameter is undefined, then the content is stored within the\n$response. If it's a simple scalar, then it's interpreted as a file name and the content is\nwritten to this file. If it's a code reference, then content is passed to this routine.\n\nThe collector is a routine that will be called and which is responsible for returning pieces (as\nref to scalar) of the content to process. The $collector signals \"EOF\" by returning a reference\nto an empty string.\n\nThe return value is the HTTP::Response object reference.\n\nNote: We will only use the callback or file argument if \"$response->issuccess()\". This avoids\nsending content data for redirects and authentication responses to the callback which would be\nconfusing.\n\ncollectonce\n$prot->collectonce($arg, $response, $content)\n\nCan be called when the whole response content is available as content. This will invoke\n\"collect\" in LWP::Protocol with a collector callback that returns a reference to $content the\nfirst time and an empty string the next.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Inspect the LWP/Protocol/file.pm and LWP/Protocol/http.pm files for examples of usage.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 1995-2001 Gisle Aas.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            }
        }
    }
}