=encoding euc-jp =head1 NAME =begin original HTTP::Headers::Util - Header value parsing utility functions =end original HTTP::Headers::Util - ヘッダの値を解析するユーティリティ関数 =head1 SYNOPSIS use HTTP::Headers::Util qw(split_header_words); @values = split_header_words($h->header("Content-Type")); =head1 DESCRIPTION =begin original This module provides a few functions that helps parsing and construction of valid HTTP header values. None of the functions are exported by default. =end original このモジュールは正しい HTTP ヘッダ値の解析と組みたてを助けるいくつかの関数を 提供します。 デフォルトでは何も関数をエクスポートしません。 =begin original The following functions are available: =end original 以下の関数がつかえます: =over 4 =item split_header_words( @header_values ) =begin original This function will parse the header values given as argument into a list of anonymous arrays containing key/value pairs. The function knows how to deal with ",", ";" and "=" as well as quoted values after "=". A list of space separated tokens are parsed as if they were separated by ";". =end original この関数は引数で与えられたヘッダの値をキー/値の組が入った無名配列の リストに解析します。 この関数は ",", ";", "=" を、"=" の後のクォートされた値と同じくらい 扱い方をよく知っています。 空白で区切られたトークンは ";" で区切られているように解析されます。 =begin original If the @header_values passed as argument contains multiple values, then they are treated as if they were a single value separated by comma ",". =end original もし複数の値が入った @header_values が引数として渡されると、カンマ "," で区切られた一つの値であるかのように扱われます。 =begin original This means that this function is useful for parsing header fields that follow this syntax (BNF as from the HTTP/1.1 specification, but we relax the requirement for tokens). =end original つまりこの関数は以下の文法に従ったヘッダフィールドを解析するのに便利です。 (HTTP/1.1 仕様をからの BNF、しかしトークンへの要求は緩めています) 。 headers = #header header = (token | parameter) *( [";"] (token | parameter)) token = 1* separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext = > quoted-pair = "\" CHAR parameter = attribute "=" value attribute = token value = token | quoted-string =begin original Each I
is represented by an anonymous array of key/value pairs. The value for a simple token (not part of a parameter) is C. Syntactically incorrect headers will not necessary be parsed as you would want. =end original 各 I
はキー/値の組の無名配列で表されます。 単純なトークンの値は (パラメータの一部ではなく) は C です。 文法的に正しくないヘッダは、必らずしもあなたの要求通りには解析されません。 =begin original This is easier to describe with some examples: =end original 幾つかの例で説明するとより簡単です: split_header_words('foo="bar"; port="80,81"; discard, bar=baz'); split_header_words('text/html; charset="iso-8859-1"'); split_header_words('Basic realm="\\"foo\\\\bar\\""'); =begin original will return =end original これは以下のように返します。 [foo=>'bar', port=>'80,81', discard=> undef], [bar=>'baz' ] ['text/html' => undef, charset => 'iso-8859-1'] [Basic => undef, realm => "\"foo\\bar\""] =item join_header_words( @arrays ) =begin original This will do the opposite of the conversion done by split_header_words(). It takes a list of anonymous arrays as arguments (or a list of key/value pairs) and produces a single header value. Attribute values are quoted if needed. =end original これは split_header_words() によって行われる変換の反対をやります。 これは無名配列のリスト (あるいはキー/値の組のリスト) を引数として取ります。 そして一つのヘッダ値を作成します。 必要であれば属性値はクォートされます。 =begin original Example: =end original 例: join_header_words(["text/plain" => undef, charset => "iso-8859/1"]); join_header_words("text/plain" => undef, charset => "iso-8859/1"); =begin original will both return the string: =end original 両方とも以下のような文字列を返します。 text/plain; charset="iso-8859/1" =back =head1 COPYRIGHT Copyright 1997-1998, Gisle Aas This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =begin meta Translated: Hippo2000 (5.48) Updated: Kentaro SHIRAKATA (5.813) =end meta