{
    "content": [
        {
            "type": "text",
            "text": "# HTTP::Response (perldoc)\n\n## NAME\n\nHTTP::Response - HTTP style response message\n\n## SYNOPSIS\n\nResponse objects are returned by the request() method of the \"LWP::UserAgent\":\n# ...\n$response = $ua->request($request);\nif ($response->issuccess) {\nprint $response->decodedcontent;\n}\nelse {\nprint STDERR $response->statusline, \"\\n\";\n}\n\n## DESCRIPTION\n\nThe \"HTTP::Response\" class encapsulates HTTP style responses. A response consists of a response\nline, some headers, and a content body. Note that the LWP library uses HTTP style responses even\nfor non-HTTP protocol schemes. Instances of this class are usually created and returned by the\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION** (1 subsections)\n- **SEE ALSO**\n- **AUTHOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "HTTP::Response",
        "section": "",
        "mode": "perldoc",
        "summary": "HTTP::Response - HTTP style response message",
        "synopsis": "Response objects are returned by the request() method of the \"LWP::UserAgent\":\n# ...\n$response = $ua->request($request);\nif ($response->issuccess) {\nprint $response->decodedcontent;\n}\nelse {\nprint STDERR $response->statusline, \"\\n\";\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": [
                    {
                        "name": "request",
                        "lines": 179
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "HTTP::Response - HTTP style response message\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 6.36\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "Response objects are returned by the request() method of the \"LWP::UserAgent\":\n\n# ...\n$response = $ua->request($request);\nif ($response->issuccess) {\nprint $response->decodedcontent;\n}\nelse {\nprint STDERR $response->statusline, \"\\n\";\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The \"HTTP::Response\" class encapsulates HTTP style responses. A response consists of a response\nline, some headers, and a content body. Note that the LWP library uses HTTP style responses even\nfor non-HTTP protocol schemes. Instances of this class are usually created and returned by the",
                "subsections": [
                    {
                        "name": "request",
                        "content": "\"HTTP::Response\" is a subclass of \"HTTP::Message\" and therefore inherits its methods. The\nfollowing additional methods are available:\n\n$r = HTTP::Response->new( $code )\n$r = HTTP::Response->new( $code, $msg )\n$r = HTTP::Response->new( $code, $msg, $header )\n$r = HTTP::Response->new( $code, $msg, $header, $content )\nConstructs a new \"HTTP::Response\" object describing a response with response code $code and\noptional message $msg. The optional $header argument should be a reference to an\n\"HTTP::Headers\" object or a plain array reference of key/value pairs. The optional $content\nargument should be a string of bytes. The meanings of these arguments are described below.\n\n$r = HTTP::Response->parse( $str )\nThis constructs a new response object by parsing the given string.\n\n$r->code\n$r->code( $code )\nThis is used to get/set the code attribute. The code is a 3 digit number that encode the\noverall outcome of an HTTP response. The \"HTTP::Status\" module provide constants that\nprovide mnemonic names for the code attribute.\n\n$r->message\n$r->message( $message )\nThis is used to get/set the message attribute. The message is a short human readable single\nline string that explains the response code.\n\n$r->header( $field )\n$r->header( $field => $value )\nThis is used to get/set header values and it is inherited from \"HTTP::Headers\" via\n\"HTTP::Message\". See HTTP::Headers for details and other similar methods that can be used to\naccess the headers.\n\n$r->content\n$r->content( $bytes )\nThis is used to get/set the raw content and it is inherited from the \"HTTP::Message\" base\nclass. See HTTP::Message for details and other methods that can be used to access the\ncontent.\n\n$r->decodedcontent( %options )\nThis will return the content after any \"Content-Encoding\" and charsets have been decoded.\nSee HTTP::Message for details.\n\n$r->request\n$r->request( $request )\nThis is used to get/set the request attribute. The request attribute is a reference to the\nrequest that caused this response. It does not have to be the same request passed to the\n$ua->request() method, because there might have been redirects and authorization retries in\nbetween.\n\n$r->previous\n$r->previous( $response )\nThis is used to get/set the previous attribute. The previous attribute is used to link\ntogether chains of responses. You get chains of responses if the first response is redirect\nor unauthorized. The value is \"undef\" if this is the first response in a chain.\n\nNote that the method $r->redirects is provided as a more convenient way to access the\nresponse chain.\n\n$r->statusline\nReturns the string \"<code> <message>\". If the message attribute is not set then the official\nname of <code> (see HTTP::Status) is substituted.\n\n$r->base\nReturns the base URI for this response. The return value will be a reference to a URI\nobject.\n\nThe base URI is obtained from one the following sources (in priority order):\n\n1.  Embedded in the document content, for instance <BASE HREF=\"...\"> in HTML documents.\n\n2.  A \"Content-Base:\" or a \"Content-Location:\" header in the response.\n\nFor backwards compatibility with older HTTP implementations we will also look for the\n\"Base:\" header.\n\n3.  The URI used to request this response. This might not be the original URI that was\npassed to $ua->request() method, because we might have received some redirect responses\nfirst.\n\nIf none of these sources provide an absolute URI, undef is returned.\n\nWhen the LWP protocol modules produce the HTTP::Response object, then any base URI embedded\nin the document (step 1) will already have initialized the \"Content-Base:\" header. (See\n\"parsehead\" in LWP::UserAgent). This means that this method only performs the last 2 steps\n(the content is not always available either).\n\n$r->filename\nReturns a filename for this response. Note that doing sanity checks on the returned filename\n(eg. removing characters that cannot be used on the target filesystem where the filename\nwould be used, and laundering it for security purposes) are the caller's responsibility; the\nonly related thing done by this method is that it makes a simple attempt to return a plain\nfilename with no preceding path segments.\n\nThe filename is obtained from one the following sources (in priority order):\n\n1.  A \"Content-Disposition:\" header in the response. Proper decoding of RFC 2047 encoded\nfilenames requires the \"MIME::QuotedPrint\" (for \"Q\" encoding), \"MIME::Base64\" (for \"B\"\nencoding), and \"Encode\" modules.\n\n2.  A \"Content-Location:\" header in the response.\n\n3.  The URI used to request this response. This might not be the original URI that was\npassed to $ua->request() method, because we might have received some redirect responses\nfirst.\n\nIf a filename cannot be derived from any of these sources, undef is returned.\n\n$r->asstring\n$r->asstring( $eol )\nReturns a textual representation of the response.\n\n$r->isinfo\n$r->issuccess\n$r->isredirect\n$r->iserror\n$r->isclienterror\n$r->isservererror\nThese methods indicate if the response was informational, successful, a redirection, or an\nerror. See HTTP::Status for the meaning of these.\n\n$r->errorasHTML\nReturns a string containing a complete HTML document indicating what error occurred. This\nmethod should only be called when $r->iserror is TRUE.\n\n$r->redirects\nReturns the list of redirect responses that lead up to this response by following the\n$r->previous chain. The list order is oldest first.\n\nIn scalar context return the number of redirect responses leading up to this one.\n\n$r->currentage\nCalculates the \"current age\" of the response as specified by RFC 2616 section 13.2.3. The\nage of a response is the time since it was sent by the origin server. The returned value is\na number representing the age in seconds.\n\n$r->freshnesslifetime( %opt )\nCalculates the \"freshness lifetime\" of the response as specified by RFC 2616 section 13.2.4.\nThe \"freshness lifetime\" is the length of time between the generation of a response and its\nexpiration time. The returned value is the number of seconds until expiry.\n\nIf the response does not contain an \"Expires\" or a \"Cache-Control\" header, then this\nfunction will apply some simple heuristic based on the \"Last-Modified\" header to determine a\nsuitable lifetime. The following options might be passed to control the heuristics:\n\nheuristicexpiry => $bool\nIf passed as a FALSE value, don't apply heuristics and just return \"undef\" when\n\"Expires\" or \"Cache-Control\" is lacking.\n\nhlastmodfraction => $num\nThis number represent the fraction of the difference since the \"Last-Modified\" timestamp\nto make the expiry time. The default is 0.10, the suggested typical setting of 10% in\nRFC 2616.\n\nhmin => $sec\nThis is the lower limit of the heuristic expiry age to use. The default is 60 (1\nminute).\n\nhmax => $sec\nThis is the upper limit of the heuristic expiry age to use. The default is 86400 (24\nhours).\n\nhdefault => $sec\nThis is the expiry age to use when nothing else applies. The default is 3600 (1 hour) or\n\"hmin\" if greater.\n\n$r->isfresh( %opt )\nReturns TRUE if the response is fresh, based on the values of freshnesslifetime() and\ncurrentage(). If the response is no longer fresh, then it has to be re-fetched or\nre-validated by the origin server.\n\nOptions might be passed to control expiry heuristics, see the description of\nfreshnesslifetime().\n\n$r->freshuntil( %opt )\nReturns the time (seconds since epoch) when this entity is no longer fresh.\n\nOptions might be passed to control expiry heuristics, see the description of\nfreshnesslifetime().\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "HTTP::Headers, HTTP::Message, HTTP::Status, HTTP::Request\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Gisle Aas <gisle@activestate.com>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 1994 by Gisle Aas.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
                "subsections": []
            }
        }
    }
}