{
    "content": [
        {
            "type": "text",
            "text": "# LWP::MediaTypes (perldoc)\n\n## NAME\n\nLWP::MediaTypes - guess media type for a file or a URL\n\n## SYNOPSIS\n\nuse LWP::MediaTypes qw(guessmediatype);\n$type = guessmediatype(\"/tmp/foo.gif\");\n\n## DESCRIPTION\n\nThis module provides functions for handling media (also known as MIME) types and encodings. The\nmapping from file extensions to media types is defined by the media.types file. If the\n~/.media.types file exists it is used instead. For backwards compatibility we will also look for\n~/.mime.types.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (7 subsections)\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "LWP::MediaTypes",
        "section": "",
        "mode": "perldoc",
        "summary": "LWP::MediaTypes - guess media type for a file or a URL",
        "synopsis": "use LWP::MediaTypes qw(guessmediatype);\n$type = guessmediatype(\"/tmp/foo.gif\");",
        "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": 7,
                "subsections": [
                    {
                        "name": "guess_media_type",
                        "lines": 1
                    },
                    {
                        "name": "guess_media_type",
                        "lines": 1
                    },
                    {
                        "name": "guess_media_type",
                        "lines": 16
                    },
                    {
                        "name": "media_suffix",
                        "lines": 9
                    },
                    {
                        "name": "add_type",
                        "lines": 4
                    },
                    {
                        "name": "add_encoding",
                        "lines": 4
                    },
                    {
                        "name": "read_media_types",
                        "lines": 4
                    }
                ]
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "LWP::MediaTypes - guess media type for a file or a URL\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use LWP::MediaTypes qw(guessmediatype);\n$type = guessmediatype(\"/tmp/foo.gif\");\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module provides functions for handling media (also known as MIME) types and encodings. The\nmapping from file extensions to media types is defined by the media.types file. If the\n~/.media.types file exists it is used instead. For backwards compatibility we will also look for\n~/.mime.types.\n\nThe following functions are exported by default:\n",
                "subsections": [
                    {
                        "name": "guess_media_type",
                        "content": ""
                    },
                    {
                        "name": "guess_media_type",
                        "content": ""
                    },
                    {
                        "name": "guess_media_type",
                        "content": "This function tries to guess media type and encoding for a file or objects that support the\na \"path\" or \"filename\" method, eg, URI or File::Temp objects. When an object does not\nsupport either method, it will be stringified to determine the filename. It returns the\ncontent type, which is a string like \"text/html\". In array context it also returns any\ncontent encodings applied (in the order used to encode the file). You can pass a URI object\nreference, instead of the file name.\n\nIf the type can not be deduced from looking at the file name, then guessmediatype() will\nlet the \"-T\" Perl operator take a look. If this works (and \"-T\" returns a TRUE value) then\nwe return *text/plain* as the type, otherwise we return *application/octet-stream* as the\ntype.\n\nThe optional second argument should be a reference to a HTTP::Headers object or any object\nthat implements the $obj->header method in a similar way. When it is present the values of\nthe 'Content-Type' and 'Content-Encoding' will be set for this header.\n"
                    },
                    {
                        "name": "media_suffix",
                        "content": "This function will return all suffixes that can be used to denote the specified media\ntype(s). Wildcard types can be used. In a scalar context it will return the first suffix\nfound. Examples:\n\n@suffixes = mediasuffix('image/*', 'audio/basic');\n$suffix = mediasuffix('text/html');\n\nThe following functions are only exported by explicit request:\n"
                    },
                    {
                        "name": "add_type",
                        "content": "Associate a list of file extensions with the given media type. Example:\n\naddtype(\"x-world/x-vrml\" => qw(wrl vrml));\n"
                    },
                    {
                        "name": "add_encoding",
                        "content": "Associate a list of file extensions with an encoding type. Example:\n\naddencoding(\"x-gzip\" => \"gz\");\n"
                    },
                    {
                        "name": "read_media_types",
                        "content": "Parse media types files and add the type mappings found there. Example:\n\nreadmediatypes(\"conf/mime.types\");\n"
                    }
                ]
            },
            "COPYRIGHT": {
                "content": "Copyright 1995-1999 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": []
            }
        }
    }
}