=encoding euc-jp =head1 NAME =begin original HTTP::Headers - Class encapsulating HTTP Message headers =end original HTTP::Headers - HTTPメッセージヘッダをカプセル化するクラス =head1 SYNOPSIS require HTTP::Headers; $h = HTTP::Headers->new; $h->header('Content-Type' => 'text/plain'); # set $ct = $h->header('Content-Type'); # get $h->remove_header('Content-Type'); # delete =head1 DESCRIPTION =begin original The C class encapsulates HTTP-style message headers. The headers consist of attribute-value pairs also called fields, which may be repeated, and which are printed in a particular order. The field names are cases insensitive. =end original HTTP::HeadersクラスはHTTP形式メッセージヘッダをカプセル化します。 ヘッダはフィールドとも呼ばれる属性-値の組み合わせで構成され、それは 繰り返しがあるかも知れず、特定の順序で出力されます。 フィールド名は大文字小文字を無視します。 =begin original Instances of this class are usually created as member variables of the C and C classes, internal to the library. =end original このクラスのインスタンスは通常、C や C クラスのメンバ変数として、ライブラリ内部用に 作成されます。 =begin original The following methods are available: =end original 以下のメソッドが利用できます: =over 4 =item $h = HTTP::Headers->new =begin original Constructs a new C object. You might pass some initial attribute-value pairs as parameters to the constructor. I: =end original 新しい C オブジェクトを組み立てます。 コンストラクタのパラメータを通して初期の属性-値の組を渡すことが出来ます。 I<例えば>: $h = HTTP::Headers->new( Date => 'Thu, 03 Feb 1994 00:00:00 GMT', Content_Type => 'text/html; version=3.2', Content_Base => 'http://www.perl.org/'); =begin original The constructor arguments are passed to the C
method which is described below. =end original コンストラクタの引数は、後述する C
メソッドに渡されます。 =item $h->clone =begin original Returns a copy of this C object. =end original C オブジェクトのコピーを返します。 =item $h->header( $field ) =item $h->header( $field => $value, ... ) =begin original Get or set the value of one or more header fields. The header field name ($field) is not case sensitive. To make the life easier for perl users who wants to avoid quoting before the => operator, you can use '_' as a replacement for '-' in header names. =end original ひとつまたは複数のヘッダフィールドの値を取得あるいは設定します。 ヘッダフィールド名($field)は大文字小文字を区別しません。 => 演算子の前にクォートしたくない Perl ユーザに簡単なように、ヘッダ名での '-' の代わりとして '_' を使うことが出来ます。 =begin original The header() method accepts multiple ($field => $value) pairs, which means that you can update several fields with a single invocation. =end original header()メソッドは複数の($field => $values) の組をうけとるので、 1 回の呼び出しでたくさんのフィールドを更新することが出来ます。 =begin original The $value argument may be a plain string or a reference to an array of strings for a multi-valued field. If the $value is provided as C then the field is removed. If the $value is not given, then that header field will remain unchanged. =end original $value 引数は普通の文字列または複数の値を持つフィールドのための 文字列のリストへのリファレンスにすることができます。 $value 引数が C の場合、フィールドは削除されます。 $value が指定されなければヘッダは変更されません。 =begin original The old value (or values) of the last of the header fields is returned. If no such field exists C will be returned. =end original 最後のヘッダフィールドの古い値 (または値) が返されます。 そのようなフィールドがない場合は、C が返されます。 =begin original A multi-valued field will be returned as separate values in list context and will be concatenated with ", " as separator in scalar context. The HTTP spec (RFC 2616) promise that joining multiple values in this way will not change the semantic of a header field, but in practice there are cases like old-style Netscape cookies (see L) where "," is used as part of the syntax of a single field value. =end original 複数の値を持つフィールドは、 リストコンテキストでは別々の値として返され、 スカラコンテキストでは ", " を区切り文字としてつなげられます。 HTTP 仕様 (RFC 2616) では、この方法で複数の値を結合してもヘッダ フィールドの意味は変わらないことを約束していますが、実際には 旧式の Netscape クッキー(L 参照)のように、一つの フィールドの値の文法の一部として "," を使っている場合があります。 =begin original Examples: =end original 例: $header->header(MIME_Version => '1.0', User_Agent => 'My-Web-Client/0.01'); $header->header(Accept => "text/html, text/plain, image/*"); $header->header(Accept => [qw(text/html text/plain image/*)]); @accepts = $header->header('Accept'); # get multiple values $accepts = $header->header('Accept'); # get values as a single string =item $h->push_header( $field => $value ) =begin original Add a new field value for the specified header field. Previous values for the same field are retained. =end original 指定されたヘッダに新しいフィールドの値を追加します。 同じフィールドの以前の値は残ります。 =begin original As for the header() method, the field name ($field) is not case sensitive and '_' can be used as a replacement for '-'. =end original header() メソッドに関しては、フィールド名 ($field) は大文字小文字は 関係なく、'-' の代わりとして '_' が使えます。 =begin original The $value argument may be a scalar or a reference to a list of scalars. =end original $value 引数にはスカラやスカラのリストへのリファレンスを指定することが 出来ます。 $header->push_header(Accept => 'image/jpeg'); $header->push_header(Accept => [map "image/$_", qw(gif png tiff)]); =item $h->init_header( $field => $value ) =begin original Set the specified header to the given value, but only if no previous value for that field is set. =end original 指定されたヘッダにすでに値がセットされていない場合のみ、与えられた値を セットします。 =begin original The header field name ($field) is not case sensitive and '_' can be used as a replacement for '-'. =end original ヘッダフィールド名 ($field) は大文字小文字は関係なく、'-' の代わりとして '_' が使えます。 =begin original The $value argument may be a scalar or a reference to a list of scalars. =end original $value 引数は、スカラか、スカラのリストへのリファレンスが取れます。 =item $h->remove_header( $field, ... ) =begin original This function removes the header fields with the specified names. =end original この関数は指定された名前を持つヘッダフィールドを削除します。 =begin original The header field names ($field) are not case sensitive and '_' can be used as a replacement for '-'. =end original ヘッダフィールド名 ($field) は大文字小文字は関係なく、'-' の代わりとして '_' が使えます。 =begin original The return value is the values of the fields removed. In scalar context the number of fields removed is returned. =end original 返り値は、削除されたフィールドの値です。 スカラ古今テキストでは、削除されたフィールドの数が返されます。 =begin original Note that if you pass in multiple field names then it is generally not possible to tell which of the returned values belonged to which field. =end original 複数のフィールド名を渡した場合、返り値の内どれがどのフィールドの 値であったかを知ることは一般的にはできないことに注意してください。 =item $h->remove_content_headers =begin original This will remove all the header fields used to describe the content of a message. All header field names prefixed with C falls into this category, as well as C, C and C. RFC 2616 denote these fields as I. =end original これは、メッセージの内容を記述するために使われている全ての ヘッダフィールドを削除します。 フィールド名の頭に C が付く全てのフィールドと、 C, C, C フィールドが対象となります。 RFC 2616 ではこれらのフィールドは I と 名付けられています。 =begin original The return value is a new C object that contains the removed headers only. =end original 返り値は、削除されたヘッダのみを含む新しい C オブジェクトです。 =item $h->clear =begin original This will remove all header fields. =end original これは全てのヘッダフィールドを削除します。 =item $h->header_field_names =begin original Returns the list of distinct names for the fields present in the header. The field names have case as suggested by HTTP spec, and the names are returned in the recommended "Good Practice" order. =end original ヘッダにあるフィールド名の重複を除いたリストを返します。 フィールド名は HTTP 仕様で推奨されているように大文字小文字を保持していて、 推薦されている "Good Practice" 順で返されます。 =begin original In scalar context return the number of distinct field names. =end original スカラコンテキストでは重複を除いたフィールド名の数を返します。 =item $h->scan( \&process_header_field ) =begin original Apply a subroutine to each header field in turn. The callback routine is called with two parameters; the name of the field and a single value (a string). If a header field is multi-valued, then the routine is called once for each value. The field name passed to the callback routine has case as suggested by HTTP spec, and the headers will be visited in the recommended "Good Practice" order. =end original 各ヘッダフィールドそれぞれにサブルーチンを適用します。 コールバックルーチンは 2 引数で呼び出されます:フィールド名と 1 つの値(文字列)です。 ヘッダフィールドが複数の値を持っていれば、ルーチンはそれぞれの値につき 1 回呼ばれます。 コールバックルーチンに渡されるフィールド名は HTTP 仕様で提案されている大文字/小文字をもち、推奨されている "Good Practice" の順でやってきます。 =begin original Any return values of the callback routine are ignored. The loop can be broken by raising an exception (C), but the caller of scan() would have to trap the exception itself. =end original コールバックルーチンからの返り値は全て無視されます。 ループは例外 (C) の発生によって終了する場合がありますが、 scan() の呼び出し元は例外を自分自身でトラップする必要があります。 =item $h->as_string =item $h->as_string( $eol ) =begin original Return the header fields as a formatted MIME header. Since it internally uses the C method to build the string, the result will use case as suggested by HTTP spec, and it will follow recommended "Good Practice" of ordering the header fields. Long header values are not folded. =end original フォーマットされた MIME ヘッダとしてヘッダフィールドを返します。 文字列を組み立てるために内部で C メソッドを使っているので、結果は HTTP 仕様で提案されている大文字小文字で、ヘッダ・フィールドの順序の 推奨されている "Good Practice" に従います。 長いヘッダの値はたたまれません。 =begin original The optional $eol parameter specifies the line ending sequence to use. The default is "\n". Embedded "\n" characters in header field values will be substituted with this line ending sequence. =end original オプションの $eol パラメータは使用する行末シーケンスを指定します。 デフォルトは "\n" です。 ヘッダフィールドの値に埋め込まれた "\n" 文字は、この行末シーケンスで 置きかえられます。 =back =head1 CONVENIENCE METHODS =begin original The most frequently used headers can also be accessed through the following convenience Methods. These methods can both be used to read and to set the value of a header. The header value is set if you pass an argument to the method. The old header value is always returned. If the given header did not exist then C is returned. =end original よく利用されるヘッダは以下の便宜メソッドを通してもアクセスすることが出来ます。 これらのメソッドはヘッダの値を読むこと設定することの両方に使うことできます。 メソッドに引数を渡せばヘッダの値が設定されます。 ヘッダの古い値は常に返されます。 与えられたヘッダが存在しない場合は、C が返されます。 =begin original Methods that deal with dates/times always convert their value to system time (seconds since Jan 1, 1970) and they also expect this kind of value when the header value is set. =end original 日付/時刻を扱うメソッドは常にその値をシステム時刻(1970 年 1 月 1 日からの 秒数)に変換し、ヘッダの値が設定される場合には、値がそうした種類であることを 期待します。 =over 4 =item $h->date =begin original This header represents the date and time at which the message was originated. I: =end original このヘッダはメッセージが発行された日付と時刻を表します。 I<例えば>: $h->date(time); # set current date =item $h->expires =begin original This header gives the date and time after which the entity should be considered stale. =end original このヘッダは、それ以降はそのエントリが新鮮でない(stale)であると考えられる 日付と時刻を示します。 =item $h->if_modified_since =item $h->if_unmodified_since =begin original These header fields are used to make a request conditional. If the requested resource has (or has not) been modified since the time specified in this field, then the server will return a C<304 Not Modified> response instead of the document itself. =end original これらヘッダフィールドはリクエストを条件付きにします。 もしリクエストされたリソースがこのフィールドで指定された時刻から変更された (あるいは変更されていない)なら、、サーバはドキュメント自身の代りに C<304 Not Modified> レスポンスを返します。 =item $h->last_modified =begin original This header indicates the date and time at which the resource was last modified. I: =end original このヘッダはそのリソースが最後に変更された日付と時刻を返します。 I<例えば>: # check if document is more than 1 hour old if (my $last_mod = $h->last_modified) { if ($last_mod < time - 60*60) { ... } } =item $h->content_type =begin original The Content-Type header field indicates the media type of the message content. I: =end original Content-Type ヘッダフィールドはメッセージ内容のメディアタイプを示します。 I<例えば>: $h->content_type('text/html'); =begin original The value returned will be converted to lower case, and potential parameters will be chopped off and returned as a separate value if in an array context. If there is no such header field, then the empty string is returned. This makes it safe to do the following: =end original 返される値は小文字に変換され、潜在的なパラメータが切り落とされ、 配列コンテキストであれば、分けられた値として返されます。 そのようなヘッダフィールドがない場合、空文字列が返されます。 これは以下のようにすることを安全にします: if ($h->content_type eq 'text/html') { # we enter this place even if the real header value happens to # be 'TEXT/HTML; version=3.0' ... } =item $h->content_encoding =begin original The Content-Encoding header field is used as a modifier to the media type. When present, its value indicates what additional encoding mechanism has been applied to the resource. =end original Content-Encoding ヘッダフィールドはメディアタイプの修飾子として 使われます。 もしあれば、その値はどんな追加のエンコーディング機能がそのリソースに 適用されたのかを示します。 =item $h->content_length =begin original A decimal number indicating the size in bytes of the message content. =end original メッセージ内容の大きさをバイト数で示す 10 進数。 =item $h->content_language =begin original The natural language(s) of the intended audience for the message content. The value is one or more language tags as defined by RFC 1766. Eg. "no" for some kind of Norwegian and "en-US" for English the way it is written in the US. =end original メッセージ内容が対象としている聞き手の自然言語。 この値は RFC1766 で定義されている 1 つまたは複数の言語タグです。 例えば "no" は何らかのノルウェー語、"en-US" は アメリカで使われている英語です。 =item $h->title =begin original The title of the document. In libwww-perl this header will be initialized automatically from the ETITLE>...E/TITLE> element of HTML documents. I =end original ドキュメントのタイトル。 libwww-perl では、このヘッダは自動的に HTML ドキュメントの ETITLE>...E/TITLE> 要素から初期化されます。 I<このヘッダはもはや HTTP 標準の一部ではありません。> =item $h->user_agent =begin original This header field is used in request messages and contains information about the user agent originating the request. I: =end original このヘッダはリクエストメッセージで使われ、そのリクエストを発行した ユーザエージェントについての情報が入っています。 I<例えば>: $h->user_agent('Mozilla/1.2'); =item $h->server =begin original The server header field contains information about the software being used by the originating server program handling the request. =end original server ヘッダフィールドには、そのリクエストを取り扱う サーバプログラムによって使われたソフトウェアについての情報が入っています。 =item $h->from =begin original This header should contain an Internet e-mail address for the human user who controls the requesting user agent. The address should be machine-usable, as defined by RFC822. E.g.: =end original このヘッダにはリクエストしているユーザエージェントを制御している人のための インターネット e-mail アドレスが入っていなければなりません。 そのアドレスは、RFC822 によって定義されているように、機械で 使えなければなりません。 I<例えば>: $h->from('King Kong '); =begin original I =end original I<このヘッダはもはや HTTP 標準の一部ではありません。> =item $h->referer =begin original Used to specify the address (URI) of the document from which the requested resource address was obtained. =end original そこからリクエストされたリソースアドレスが取得された、ドキュメントの アドレス (URI) を指定するために使われます。 =begin original The "Free On-line Dictionary of Computing" as this to say about the word I: =end original "Free On-line Dictionary of Computing" では、I について 以下のように書かれています: A misspelling of "referrer" which somehow made it into the {HTTP} standard. A given {web page}'s referer (sic) is the {URL} of whatever web page contains the link that the user followed to the current page. Most browsers pass this information as part of a request. (1998-10-19) =begin original By popular demand C exists as an alias for this method so you can avoid this misspelling in your programs and still send the right thing on the wire. =end original 一般的な需要により、C もこのメソッドへの別名として 存在しているので、プログラム内にスペルミスをすることなく、正しく 通信させることができます。 =begin original When setting the referrer, this method removes the fragment from the given URI if it is present, as mandated by RFC2616. Note that the removal does I happen automatically if using the header(), push_header() or init_header() methods to set the referrer. =end original リファラを設定するときに、このメソッドは RFC2616 で指示されているように URI 中にフラグメントがあった場合はこれを除去します。 リファラを設定するときに header(), push_header(), init_header() を使うと、この除去作業は 自動的には I<行われない> ことに注意してください。 =item $h->www_authenticate =begin original This header must be included as part of a C<401 Unauthorized> response. The field value consist of a challenge that indicates the authentication scheme and parameters applicable to the requested URI. =end original このヘッダは C<401 Unauthorized> レスポンスの一部として 入らなければなりません。 フィールドの値は、リクエストされた URI へ適用できる 認証スキームとパラメータを示すチャレンジにより構成されます。 =item $h->proxy_authenticate =begin original This header must be included in a C<407 Proxy Authentication Required> response. =end original このヘッダは C<407 Proxy Authentication Required> レスポンスに 入らなければなりません。 =item $h->authorization =item $h->proxy_authorization =begin original A user agent that wishes to authenticate itself with a server or a proxy, may do so by including these headers. =end original サーバまたはプロキシでそれ自身を認証して欲しいユーザエージェントは、 これらのヘッダを入れることによりそうなるかもしれません。 =item $h->authorization_basic =begin original This method is used to get or set an authorization header that use the "Basic Authentication Scheme". In array context it will return two values; the user name and the password. In scalar context it will return I<"uname:password"> as a single string value. =end original このヘッダは「基本認証機能」を使う認証ヘッダを取得および設定するために 使われます。 配列コンテキストでは 2 つの値を返します; ユーザ名とパスワードです。 スカラコンテキストでは 1 つの文字列として I<"uname:password"> を返します。 =begin original When used to set the header value, it expects two arguments. I: =end original ヘッダの値を設定するために使われるときは、2つの引数が期待されます。 I<例えば>: $h->authorization_basic($uname, $password); =begin original The method will croak if the $uname contains a colon ':'. =end original もし $uname にコロン ':' が入っていれば croak します。 =item $h->proxy_authorization_basic =begin original Same as authorization_basic() but will set the "Proxy-Authorization" header instead. =end original authorization_basic() と同様ですが、 しかし代わりに "Proxy-Authorization" ヘッダを設定します。 =back =head1 NON-CANONICALIZED FIELD NAMES =begin original The header field name spelling is normally canonicalized including the '_' to '-' translation. There are some application where this is not appropriate. Prefixing field names with ':' allow you to force a specific spelling. For example if you really want a header field name to show up as C instead of "Foo-Bar", you might set it like this: =end original ヘッダフィールド名は、通常('_' から '-' への変換を含めて)正規化されます。 これが適切でないアプリケーションもあります。 フィールド名の先頭に ':' を付けることで、正規化しないようにすることができます。 例えば、もし "Foo-Bar" ではなく本当に C というフィールド名の ヘッダにしたい場合は、以下のようにします: $h->header(":foo_bar" => 1); =begin original These field names are returned with the ':' intact for $h->header_field_names and the $h->scan callback, but the colons do not show in $h->as_string. =end original これらのフィールド名は、$h->header_field_names と $h->scan の コールバックではそのまま ':' 付きで返されますが、 $h->as_string ではコロンは表示されません。 =head1 COPYRIGHT Copyright 1995-2005 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