{
    "content": [
        {
            "type": "text",
            "text": "# HTTP::Headers::Util (perldoc)\n\n## NAME\n\nHTTP::Headers::Util - Header value parsing utility functions\n\n## SYNOPSIS\n\nuse HTTP::Headers::Util qw(splitheaderwords);\n@values = splitheaderwords($h->header(\"Content-Type\"));\n\n## DESCRIPTION\n\nThis module provides a few functions that helps parsing and construction of valid HTTP header\nvalues. None of the functions are exported by default.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION** (2 subsections)\n- **AUTHOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "HTTP::Headers::Util",
        "section": "",
        "mode": "perldoc",
        "summary": "HTTP::Headers::Util - Header value parsing utility functions",
        "synopsis": "use HTTP::Headers::Util qw(splitheaderwords);\n@values = splitheaderwords($h->header(\"Content-Type\"));",
        "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": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 5,
                "subsections": [
                    {
                        "name": "split_header_words",
                        "lines": 47
                    },
                    {
                        "name": "join_header_words",
                        "lines": 13
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "HTTP::Headers::Util - Header value parsing utility functions\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 6.36\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use HTTP::Headers::Util qw(splitheaderwords);\n@values = splitheaderwords($h->header(\"Content-Type\"));\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module provides a few functions that helps parsing and construction of valid HTTP header\nvalues. None of the functions are exported by default.\n\nThe following functions are available:\n",
                "subsections": [
                    {
                        "name": "split_header_words",
                        "content": "This function will parse the header values given as argument into a list of anonymous arrays\ncontaining key/value pairs. The function knows how to deal with \",\", \";\" and \"=\" as well as\nquoted values after \"=\". A list of space separated tokens are parsed as if they were\nseparated by \";\".\n\nIf the @headervalues passed as argument contains multiple values, then they are treated as\nif they were a single value separated by comma \",\".\n\nThis means that this function is useful for parsing header fields that follow this syntax\n(BNF as from the HTTP/1.1 specification, but we relax the requirement for tokens).\n\nheaders           = #header\nheader            = (token | parameter) *( [\";\"] (token | parameter))\n\ntoken             = 1*<any CHAR except CTLs or separators>\nseparators        = \"(\" | \")\" | \"<\" | \">\" | \"@\"\n| \",\" | \";\" | \":\" | \"\\\" | <\">\n| \"/\" | \"[\" | \"]\" | \"?\" | \"=\"\n| \"{\" | \"}\" | SP | HT\n\nquoted-string     = ( <\"> *(qdtext | quoted-pair ) <\"> )\nqdtext            = <any TEXT except <\">>\nquoted-pair       = \"\\\" CHAR\n\nparameter         = attribute \"=\" value\nattribute         = token\nvalue             = token | quoted-string\n\nEach *header* is represented by an anonymous array of key/value pairs. The keys will be all\nbe forced to lower case. The value for a simple token (not part of a parameter) is \"undef\".\nSyntactically incorrect headers will not necessarily be parsed as you would want.\n\nThis is easier to describe with some examples:\n\nsplitheaderwords('foo=\"bar\"; port=\"80,81\"; DISCARD, BAR=baz');\nsplitheaderwords('text/html; charset=\"iso-8859-1\"');\nsplitheaderwords('Basic realm=\"\\\\\"foo\\\\\\\\bar\\\\\"\"');\n\nwill return\n\n[foo=>'bar', port=>'80,81', discard=> undef], [bar=>'baz' ]\n['text/html' => undef, charset => 'iso-8859-1']\n[basic => undef, realm => \"\\\"foo\\\\bar\\\"\"]\n\nIf you don't want the function to convert tokens and attribute keys to lower case you can\ncall it as \"splitheaderwords\" instead (with a leading underscore).\n"
                    },
                    {
                        "name": "join_header_words",
                        "content": "This will do the opposite of the conversion done by splitheaderwords(). It takes a list of\nanonymous arrays as arguments (or a list of key/value pairs) and produces a single header\nvalue. Attribute values are quoted if needed.\n\nExample:\n\njoinheaderwords([\"text/plain\" => undef, charset => \"iso-8859/1\"]);\njoinheaderwords(\"text/plain\" => undef, charset => \"iso-8859/1\");\n\nwill both return the string:\n\ntext/plain; charset=\"iso-8859/1\"\n"
                    }
                ]
            },
            "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": []
            }
        }
    }
}