{
    "content": [
        {
            "type": "text",
            "text": "# HTTP::Message (perldoc)\n\n## NAME\n\nHTTP::Message - HTTP style message (base class)\n\n## SYNOPSIS\n\nuse base 'HTTP::Message';\n\n## DESCRIPTION\n\nAn \"HTTP::Message\" object contains some headers and a content body. The following methods are\navailable:\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **AUTHOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "HTTP::Message",
        "section": "",
        "mode": "perldoc",
        "summary": "HTTP::Message - HTTP style message (base class)",
        "synopsis": "use base 'HTTP::Message';",
        "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": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 252,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "HTTP::Message - HTTP style message (base class)\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 6.36\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use base 'HTTP::Message';\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "An \"HTTP::Message\" object contains some headers and a content body. The following methods are\navailable:\n\n$mess = HTTP::Message->new\n$mess = HTTP::Message->new( $headers )\n$mess = HTTP::Message->new( $headers, $content )\nThis constructs a new message object. Normally you would want construct \"HTTP::Request\" or\n\"HTTP::Response\" objects instead.\n\nThe optional $header argument should be a reference to an \"HTTP::Headers\" object or a plain\narray reference of key/value pairs. If an \"HTTP::Headers\" object is provided then a copy of\nit will be embedded into the constructed message, i.e. it will not be owned and can be\nmodified afterwards without affecting the message.\n\nThe optional $content argument should be a string of bytes.\n\n$mess = HTTP::Message->parse( $str )\nThis constructs a new message object by parsing the given string.\n\n$mess->headers\nReturns the embedded \"HTTP::Headers\" object.\n\n$mess->headersasstring\n$mess->headersasstring( $eol )\nCall the asstring() method for the headers in the message. This will be the same as\n\n$mess->headers->asstring\n\nbut it will make your program a whole character shorter :-)\n\n$mess->content\n$mess->content( $bytes )\nThe content() method sets the raw content if an argument is given. If no argument is given\nthe content is not touched. In either case the original raw content is returned.\n\nIf the \"undef\" argument is given, the content is reset to its default value, which is an\nempty string.\n\nNote that the content should be a string of bytes. Strings in perl can contain characters\noutside the range of a byte. The \"Encode\" module can be used to turn such strings into a\nstring of bytes.\n\n$mess->addcontent( $bytes )\nThe addcontent() methods appends more data bytes to the end of the current content buffer.\n\n$mess->addcontentutf8( $string )\nThe addcontentutf8() method appends the UTF-8 bytes representing the string to the end of\nthe current content buffer.\n\n$mess->contentref\n$mess->contentref( \\$bytes )\nThe contentref() method will return a reference to content buffer string. It can be more\nefficient to access the content this way if the content is huge, and it can even be used for\ndirect manipulation of the content, for instance:\n\n${$res->contentref} =~ s/\\bfoo\\b/bar/g;\n\nThis example would modify the content buffer in-place.\n\nIf an argument is passed it will setup the content to reference some external source. The\ncontent() and addcontent() methods will automatically dereference scalar references passed\nthis way. For other references content() will return the reference itself and addcontent()\nwill refuse to do anything.\n\n$mess->contentcharset\nThis returns the charset used by the content in the message. The charset is either found as\nthe charset attribute of the \"Content-Type\" header or by guessing.\n\nSee <http://www.w3.org/TR/REC-html40/charset.html#spec-char-encoding> for details about how\ncharset is determined.\n\n$mess->decodedcontent( %options )\nReturns the content with any \"Content-Encoding\" undone and, for textual content\n(\"Content-Type\" values starting with \"text/\", exactly matching \"application/xml\", or ending\nwith \"+xml\"), the raw content's character set decoded into Perl's Unicode string format.\nNote that this does not currently <https://github.com/libwww-perl/HTTP-Message/pull/99>\nattempt to decode declared character sets for any other content types like\n\"application/json\" or \"application/javascript\". If the \"Content-Encoding\" or \"charset\" of\nthe message is unknown, this method will fail by returning \"undef\".\n\nThe following options can be specified.\n\n\"charset\"\nThis override the charset parameter for text content. The value \"none\" can used to\nsuppress decoding of the charset.\n\n\"defaultcharset\"\nThis override the default charset guessed by contentcharset() or if that fails\n\"ISO-8859-1\".\n\n\"altcharset\"\nIf decoding fails because the charset specified in the Content-Type header isn't\nrecognized by Perl's Encode module, then try decoding using this charset instead of\nfailing. The \"altcharset\" might be specified as \"none\" to simply return the string\nwithout any decoding of charset as alternative.\n\n\"charsetstrict\"\nAbort decoding if malformed characters is found in the content. By default you get the\nsubstitution character (\"\\x{FFFD}\") in place of malformed characters.\n\n\"raiseerror\"\nIf TRUE then raise an exception if not able to decode content. Reason might be that the\nspecified \"Content-Encoding\" or \"charset\" is not supported. If this option is FALSE,\nthen decodedcontent() will return \"undef\" on errors, but will still set $@.\n\n\"ref\"\nIf TRUE then a reference to decoded content is returned. This might be more efficient in\ncases where the decoded content is identical to the raw content as no data copying is\nrequired in this case.\n\n$mess->decodable\nHTTP::Message::decodable()\nThis returns the encoding identifiers that decodedcontent() can process. In scalar context\nreturns a comma separated string of identifiers.\n\nThis value is suitable for initializing the \"Accept-Encoding\" request header field.\n\n$mess->decode\nThis method tries to replace the content of the message with the decoded version and removes\nthe \"Content-Encoding\" header. Returns TRUE if successful and FALSE if not.\n\nIf the message does not have a \"Content-Encoding\" header this method does nothing and\nreturns TRUE.\n\nNote that the content of the message is still bytes after this method has been called and\nyou still need to call decodedcontent() if you want to process its content as a string.\n\n$mess->encode( $encoding, ... )\nApply the given encodings to the content of the message. Returns TRUE if successful. The\n\"identity\" (non-)encoding is always supported; other currently supported encodings, subject\nto availability of required additional modules, are \"gzip\", \"deflate\", \"x-bzip2\" and\n\"base64\".\n\nA successful call to this function will set the \"Content-Encoding\" header.\n\nNote that \"multipart/*\" or \"message/*\" messages can't be encoded and this method will croak\nif you try.\n\n$mess->parts\n$mess->parts( @parts )\n$mess->parts( \\@parts )\nMessages can be composite, i.e. contain other messages. The composite messages have a\ncontent type of \"multipart/*\" or \"message/*\". This method give access to the contained\nmessages.\n\nThe argumentless form will return a list of \"HTTP::Message\" objects. If the content type of\n$msg is not \"multipart/*\" or \"message/*\" then this will return the empty list. In scalar\ncontext only the first object is returned. The returned message parts should be regarded as\nread-only (future versions of this library might make it possible to modify the parent by\nmodifying the parts).\n\nIf the content type of $msg is \"message/*\" then there will only be one part returned.\n\nIf the content type is \"message/http\", then the return value will be either an\n\"HTTP::Request\" or an \"HTTP::Response\" object.\n\nIf a @parts argument is given, then the content of the message will be modified. The array\nreference form is provided so that an empty list can be provided. The @parts array should\ncontain \"HTTP::Message\" objects. The @parts objects are owned by $mess after this call and\nshould not be modified or made part of other messages.\n\nWhen updating the message with this method and the old content type of $mess is not\n\"multipart/*\" or \"message/*\", then the content type is set to \"multipart/mixed\" and all\nother content headers are cleared.\n\nThis method will croak if the content type is \"message/*\" and more than one part is\nprovided.\n\n$mess->addpart( $part )\nThis will add a part to a message. The $part argument should be another \"HTTP::Message\"\nobject. If the previous content type of $mess is not \"multipart/*\" then the old content\n(together with all content headers) will be made part #1 and the content type made\n\"multipart/mixed\" before the new part is added. The $part object is owned by $mess after\nthis call and should not be modified or made part of other messages.\n\nThere is no return value.\n\n$mess->clear\nWill clear the headers and set the content to the empty string. There is no return value\n\n$mess->protocol\n$mess->protocol( $proto )\nSets the HTTP protocol used for the message. The protocol() is a string like \"HTTP/1.0\" or\n\"HTTP/1.1\".\n\n$mess->clone\nReturns a copy of the message object.\n\n$mess->asstring\n$mess->asstring( $eol )\nReturns the message formatted as a single string.\n\nThe optional $eol parameter specifies the line ending sequence to use. The default is \"\\n\".\nIf no $eol is given then asstring will ensure that the returned string is newline\nterminated (even when the message content is not). No extra newline is appended if an\nexplicit $eol is passed.\n\n$mess->dump( %opt )\nReturns the message formatted as a string. In void context print the string.\n\nThis differs from \"$mess->asstring\" in that it escapes the bytes of the content so that\nit's safe to print them and it limits how much content to print. The escapes syntax used is\nthe same as for Perl's double quoted strings. If there is no content the string \"(no\ncontent)\" is shown in its place.\n\nOptions to influence the output can be passed as key/value pairs. The following options are\nrecognized:\n\nmaxlength => $num\nHow much of the content to show. The default is 512. Set this to 0 for unlimited.\n\nIf the content is longer then the string is chopped at the limit and the string\n\"...\\n(### more bytes not shown)\" appended.\n\nnocontent => $str\nReplaces the \"(no content)\" marker.\n\nprefix => $str\nA string that will be prefixed to each line of the dump.\n\nAll methods unknown to \"HTTP::Message\" itself are delegated to the \"HTTP::Headers\" object that\nis part of every message. This allows convenient access to these methods. Refer to HTTP::Headers\nfor details of these methods:\n\n$mess->header( $field => $val )\n$mess->pushheader( $field => $val )\n$mess->initheader( $field => $val )\n$mess->removeheader( $field )\n$mess->removecontentheaders\n$mess->headerfieldnames\n$mess->scan( \\&doit )\n\n$mess->date\n$mess->expires\n$mess->ifmodifiedsince\n$mess->ifunmodifiedsince\n$mess->lastmodified\n$mess->contenttype\n$mess->contentencoding\n$mess->contentlength\n$mess->contentlanguage\n$mess->title\n$mess->useragent\n$mess->server\n$mess->from\n$mess->referer\n$mess->wwwauthenticate\n$mess->authorization\n$mess->proxyauthorization\n$mess->authorizationbasic\n$mess->proxyauthorizationbasic\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": []
            }
        }
    }
}