=encoding euc-jp =head1 NAME =begin original HTTP::Response - HTTP style response message =end original HTTP::Response - HTTP 形式のレスポンスメッセージ =head1 SYNOPSIS =begin original Response objects are returned by the request() method of the C: =end original レスポンスオブジェクトは C の request() から返されます: # ... $response = $ua->request($request) if ($response->is_success) { print $response->content; } else { print STDERR $response->status_line, "\n"; } =head1 DESCRIPTION =begin original The C class encapsulates HTTP style responses. A response consists of a response line, some headers, and a content body. Note that the LWP library uses HTTP style responses even for non-HTTP protocol schemes. Instances of this class are usually created and returned by the request() method of an C object. =end original C クラスは HTTP 形式のレスポンスをカプセル化します。 レスポンスはレスポンス行、いくつかのヘッダ、そして内容の本体(content body)で 構成されます。 LWP ライブラリは HTTP プロトコルでないスキームにも、HTTP 形式のレスポンスを 使っていることに注意してください。 このクラスのインタンスは通常 C の request() メソッドで 作成されてかえされます。 =begin original C is a subclass of C and therefore inherits its methods. The following additional methods are available: =end original C は C のサブクラスなので、そのメソッドを 継承しています。 以下の追加のメソッドが利用できます: =over 4 =item $r = HTTP::Response->new( $code ) =item $r = HTTP::Response->new( $code, $msg ) =item $r = HTTP::Response->new( $code, $msg, $header ) =item $r = HTTP::Response->new( $code, $msg, $header, $content ) =begin original Constructs a new C object describing a response with response code $code and optional message $msg. The optional $header argument should be a reference to an C object or a plain array reference of key/value pairs. The optional $content argument should be a string of bytes. The meaning these arguments are described below. =end original 応答コード $code で、オプションのメッセージ $msg を記述する、新しい C オブジェクトを組みたてます。 オプションの $header 引数は C オブジェクトへのリファレンスか キー/値の組への通常の配列リファレンスです。 オプションの $content 引数はバイト並びです。 これらの引数の意味は以下に記述します。 =item $r = HTTP::Response->parse( $str ) =begin original This constructs a new response object by parsing the given string. =end original これは与えられた文字列をパースすることによって新しい レスポンスオブジェクトを構築します。 =item $r->code =item $r->code( $code ) =begin original This is used to get/set the code attribute. The code is a 3 digit number that encode the overall outcome of a HTTP response. The C module provide constants that provide mnemonic names for the code attribute. =end original これはコード属性を取得/設定するために使われます。 コードは、HTTP レスポンスの結果をエンコードした 3 桁の 10 進数です。 C モジュールは、コード属性に対する覚えやすい名前を示す 定数を提供します。 =item $r->message =item $r->message( $message ) =begin original This is used to get/set the message attribute. The message is a short human readable single line string that explains the response code. =end original これはメッセージ属性を取得/設定するために使われます。 メッセージは短く、人が読める、応答コードを説明する 1 行の文字列です。 =item $r->header( $field ) =item $r->header( $field => $value ) =begin original This is used to get/set header values and it is inherited from C via C. See L for details and other similar methods that can be used to access the headers. =end original これはヘッダの値を取得/設定するために使われるもので、 C から C 経由で継承されたものです。 詳細や、ヘッダにアクセスするために使えるその他の似たような メソッドについては L を参照してください。 =item $r->content =item $r->content( $bytes ) =begin original This is used to get/set the raw content and it is inherited from the C base class. See L for details and other methods that can be used to access the content. =end original これは生の内容を取得/設定するために使われます; これは C 基底クラスから継承しています。 詳細と、内容にアクセスするために使えるその他のメソッドについては L を参照してください。 =item $r->decoded_content( %options ) =begin original This will return the content after any C and charsets have been decoded. See L for details. =end original これは、C と文字集合をデコードした後の内容を 返します。 詳しくは L を参照してください。 =item $r->request =item $r->request( $request ) =begin original This is used to get/set the request attribute. The request attribute is a reference to the the request that caused this response. It does not have to be the same request passed to the $ua->request() method, because there might have been redirects and authorization retries in between. =end original これは request 属性を取得/設定するために使われます。 request 属性はこのレスポンスを発生したリクエストへのリファレンスです。 これは $ua->request() メソッドに渡されたものと同じ リクエストである必要はありません。 というのもその間にリダイレクトや認証のリトライがあったかもしれないからです。 =item $r->previous =item $r->previous( $response ) =begin original This is used to get/set the previous attribute. The previous attribute is used to link together chains of responses. You get chains of responses if the first response is redirect or unauthorized. The value is C if this is the first response in a chain. =end original これは previous 属性を取得/設定するために使われます。 previous 属性はレスポンスのチェーンをたどるために使われます。 最初のレスポンスがリダイレトクトまたは認証されていなければ、 レスポンスのチェーンを取得します。 もしこれがチェーンの中の最初のレスポンスの場合は値は C になります。 =item $r->status_line =begin original Returns the string "Ecode> Emessage>". If the message attribute is not set then the official name of Ecode> (see L) is substituted. =end original 文字列 "Ecode> Emessage>" を返します。 もし message 属性が設定されていなければ、Ecode>の公式の名前 (L を参照してください)に置き換えられます。 =item $r->base =begin original Returns the base URI for this response. The return value will be a reference to a URI object. =end original このレスポンスの基本 URI を返します。 戻り値は URI オブジェクトへのリファレンスになります。 =begin original The base URI is obtained from one the following sources (in priority order): =end original 基本 URI は以下のいずれかの情報源から(この優先順で)取得されます: =over 4 =item 1. =begin original Embedded in the document content, for instance in HTML documents. =end original ドキュメント内容に埋め込まれたもの; 例えば HTML ドキュメント内での 。 =item 2. =begin original A "Content-Base:" or a "Content-Location:" header in the response. =end original レスポンスでの "Content-Base:" または "Content-Locatin:" ヘッダ。 =begin original For backwards compatibility with older HTTP implementations we will also look for the "Base:" header. =end original 古い HTTP 実装との後方互換性のため、"Base:" ヘッダも探します。 =item 3. =begin original The URI used to request this response. This might not be the original URI that was passed to $ua->request() method, because we might have received some redirect responses first. =end original このレスポンスを要求した URI。 これは $ua->request() メソッドに渡された、元の URI でないかもしれません。 というのもレスポンスの前に、いくつかのリダイレクトを 受信しているかもしれないからです。 =back =begin original If none of these sources provide an absolute URI, undef is returned. =end original これらのソースのいずれも絶対 URI を提供していない場合、undef が返されます。 =begin original When the LWP protocol modules produce the HTTP::Response object, then any base URI embedded in the document (step 1) will already have initialized the "Content-Base:" header. This means that this method only performs the last 2 steps (the content is not always available either). =end original LWP プロトコルモジュールが HTTP::Response オブジェクトを作成すると、 ドキュメントに埋め込まれたなんらかの基 本URI(step 1)が、 "Content-Base:" ヘッダを初期化しているでしょう。 つまりこのメソッドは残り 2 つのステップだけを行います (どちらも内容は常に使えるわけではありません)。 =item $r->filename =begin original Returns a filename for this response. Note that doing sanity checks on the returned filename (eg. removing characters that cannot be used on the target filesystem where the filename would be used, and laundering it for security purposes) are the caller's responsibility; the only related thing done by this method is that it makes a simple attempt to return a plain filename with no preceding path segments. =end original このレスポンスのファイル名を返します。 返されたファイル名の妥当性チェック (つまり、ファイル名が使われる ファイルシステムで使えない文字の除去や、セキュリティ目的での サニタイズ) は呼び出し側の責任です; これに関してこのメソッドが行う 唯一のことは、先頭にパス区切り文字のない単純なファイル名を返そうと することだけです。 =begin original The filename is obtained from one the following sources (in priority order): =end original ファイル名は以下の情報源の一つから取得します (優先順): =over 4 =item 1. =begin original A "Content-Disposition:" header in the response. Proper decoding of RFC 2047 encoded filenames requires the C (for "Q" encoding), C (for "B" encoding), and C modules. =end original レスポンスの "Content-Disposition:" ヘッダ。 RFC 2047 のエンコードされたファイル名を適切にデコードするには、 ("Q" エンコーディング用の) C、 ("B" エンコーディング用の) C、 そして C モジュールが必要です。 =item 2. =begin original A "Content-Location:" header in the response. =end original レスポンスの "Content-Location:" ヘッダ。 =item 3. =begin original The URI used to request this response. This might not be the original URI that was passed to $ua->request() method, because we might have received some redirect responses first. =end original このレスポンスのリクエストに使われた URI。 これは $ua->request() メソッドに渡された元の URI ではないかもしれません; なぜなら先にリダイレクトレスポンスを受け取っているかもしれないからです。 =back =begin original If a filename cannot be derived from any of these sources, undef is returned. =end original これらの情報源のどれからもファイル名を得られなかった場合、undef が 返されます。 =item $r->as_string =item $r->as_string( $eol ) =begin original Returns a textual representation of the response. =end original レスポンスのテキストによる表現を返します。 =item $r->is_info =item $r->is_success =item $r->is_redirect =item $r->is_error =begin original These methods indicate if the response was informational, successful, a redirection, or an error. See L for the meaning of these. =end original これらのメソッドはレスポンスが情報的(informational)であるか、 成功したか、リダイレクトであるか、エラーであるかを示します。 これらの意味については L を参照してください。 =item $r->error_as_HTML =begin original Returns a string containing a complete HTML document indicating what error occurred. This method should only be called when $r->is_error is TRUE. =end original 何のエラーが発生したかを示す完全なHTMLドキュメントが入っている 文字列を返します。 このメソッドは $r->is_error が TRUE のときだけ呼ばれるべきです。 =item $r->current_age =begin original Calculates the "current age" of the response as specified by RFC 2616 section 13.2.3. The age of a response is the time since it was sent by the origin server. The returned value is a number representing the age in seconds. =end original RFC 2616 section 13.2.3 によって指定されたレスポンスの 「現在の年齢」("current age")を計算します。 レスポンスの年齢は元のサーバによって送信されてからの時間です。 返される値は、年齢を秒で表した数字です。 =item $r->freshness_lifetime =begin original Calculates the "freshness lifetime" of the response as specified by RFC 2616 section 13.2.4. The "freshness lifetime" is the length of time between the generation of a response and its expiration time. The returned value is a number representing the freshness lifetime in seconds. =end original RFC 2616 section 13.2.4 で指定された、そのレスポンスの「新鮮保持期間」 ("freshness lifetime")を計算します。 「新鮮保持期間」はレスポンスが生成されてから破棄されるまでの時間の長さです。 返される値は秒で新鮮保持期間を表した数字です。 =begin original If the response does not contain an "Expires" or a "Cache-Control" header, then this function will apply some simple heuristic based on 'Last-Modified' to determine a suitable lifetime. =end original もし "Expires" または"Cache-Control" ヘッダがレスポンスに入っていなければ、 適切な期間を決めるため、この関数は 'Last-Modified' をベースに単純な自分で 発見する方法を適用します。 =item $r->is_fresh =begin original Returns TRUE if the response is fresh, based on the values of freshness_lifetime() and current_age(). If the response is no longer fresh, then it has to be refetched or revalidated by the origin server. =end original freshness_lifetime() と current_age() の値をベースに、レスポンスが 新鮮であれば TRUE を返します。 レスポンスがもはや新鮮でなければ、もう一度取り出されるか、 元のサーバによって再評価されるべきです。 =item $r->fresh_until =begin original Returns the time when this entity is no longer fresh. =end original このエンティティがもはや新鮮ではなくなる刻を返します。 =back =head1 SEE ALSO L, L, L, L =head1 COPYRIGHT Copyright 1995-2004 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