libwww-perl-5.813 > LWP::Protocol
libwww-perl-5.813

名前

LWP::Protocol - Base class for LWP protocols

LWP::Protocol - LWP プロトコルの基底クラス

概要

 package LWP::Protocol::foo;
 require LWP::Protocol;
 @ISA=qw(LWP::Protocol);

説明

This class is used a the base class for all protocol implementations supported by the LWP library.

このクラスは LWP ライブラリによりサポートされるすべてのプロトコル実装のための 基底クラスとして使われます。

When creating an instance of this class using LWP::Protocol::create($url), and you get an initialised subclass appropriate for that access method. In other words, the LWP::Protocol::create() function calls the constructor for one of its subclasses.

LWP::Protocol::create($url) を使ってこのクラスのインスタンスを作成すると、 そのアクセス方法にて記述した、初期化されたサブクラスを取得します。 言い換えると、LWP::Protocol::create() はそのサブクラスの一つのための コンストラクタを呼び出します。

All derived LWP::Protocol classes need to override the request() method which is used to service a request. The overridden method can make use of the collect() function to collect together chunks of data as it is received.

LWP::Protocol から派生したすべてのクラスは、リクエストをサービスするために 使われる request() メソッドをオーバーライドする必要があります。 オーバーライドされたメソッドは、それが受信したときにデータのチャンクを まとめるために collect() 関数を使うことが出来ます。

The following methods and functions are provided:

以下の関数が提供されます:

$prot = LWP::Protocol->new()

The LWP::Protocol constructor is inherited by subclasses. As this is a virtual base class this method should not be called directly.

LWP::Protocol コンストラクタはサブクラスにより継承されます。 これは仮想基底クラスなので、このメソッドは 直接呼ばれるべきではありません

$prot = LWP::Protocol::create($scheme)

Create an object of the class implementing the protocol to handle the given scheme. This is a function, not a method. It is more an object factory than a constructor. This is the function user agents should use to access protocols.

与えられた機能を取り扱うプロトコルを実装しているクラスの オブジェクトを作成します。 これは関数であり、メソッドではありません。 これはコンストラクタというより、オブジェクトファクトリです。 これはユーザーエージェントがプロトコルにアクセスするために使うべき 関数です。

$class = LWP::Protocol::implementor($scheme, [$class])

Get and/or set implementor class for a scheme. Returns '' if the specified scheme is not supported.

スキームのための実装クラスを取得/設定します。 指定されたスキームがサポートされていなければ、'' を返します。

$prot->request(...)
 $response = $protocol->request($request, $proxy, undef);
 $response = $protocol->request($request, $proxy, '/tmp/sss');
 $response = $protocol->request($request, $proxy, \&callback, 1024);

Dispatches a request over the protocol, and returns a response object. This method needs to be overridden in subclasses. Refer to LWP::UserAgent for description of the arguments.

プロトコルにリクエストを発行し、レスポンスオブジェクトを返します。 このメソッドはサブクラスでオーバーライドされる必要があります。 引数の説明については LWP::UserAgent を参照してください。

$prot->collect($arg, $response, $collector)

Called to collect the content of a request, and process it appropriately into a scalar, file, or by calling a callback. If $arg is undefined, then the content is stored within the $response. If $arg is a simple scalar, then $arg is interpreted as a file name and the content is written to this file. If $arg is a reference to a routine, then content is passed to this routine.

リクエストの内容を集め、スカラやファイルへの格納、もしくは コールバックの呼び出しによって適切に処理するために使われます。 $arg が未定義であれば、内容は $response に格納されます。 $arg が単なるスカラであれば、$arg はファイル名と解釈され、内容はこの ファイルに書きこまれます。 $arg がルーチンへのリファレンスであれば、内容はこの関数に渡されます。

The $collector is a routine that will be called and which is responsible for returning pieces (as ref to scalar) of the content to process. The $collector signals EOF by returning a reference to an empty sting.

$collectoer は呼ばれるルーチンです。 そしてそれは処理する内容のカケラを (スカラへのリファレンスとして) 返すことに 責任を持ちます。 $collector は空文字列へのリファレンスを返すことで EOF を知らせます。

The return value from collect() is the $response object reference.

collect() からの返り値は $response オブジェクトリファレンスです。

Note: We will only use the callback or file argument if $response->is_success(). This avoids sending content data for redirects and authentication responses to the callback which would be confusing.

注意: $response->is_success() であったときだけ、コールバックや ファイル引数を使います。 これによりリダイレクトのためのコンテント・データと混乱をまねくであろう コールバックへの認証レスポンスを送信することを避けています。

$prot->collect_once($arg, $response, $content)

Can be called when the whole response content is available as $content. This will invoke collect() with a collector callback that returns a reference to $content the first time and an empty string the next.

レスポンスの内容の全体が $content として利用できるときに呼ばれます。 これは最初に $content へのリファレンスを、次に空文字列を返す collector コールバックで collect() を起動します。

SEE ALSO

Inspect the LWP/Protocol/file.pm and LWP/Protocol/http.pm files for examples of usage.

使用例として LWP/Protocol/file.pmLWP/Protocol/http.pm ファイルを ご覧下さい。

コピーライト

Copyright 1995-2001 Gisle Aas.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.