libwww-perl-5.813 > HTTP::Request
libwww-perl-5.813

名前

HTTP::Request - HTTP style request message

HTTP::Request - HTTP 形式のリクエストメッセージ

概要

 require HTTP::Request;
 $request = HTTP::Request->new(GET => 'http://www.example.com/');

and usually used like this:

そして通常は以下のようにして使います:

 $ua = LWP::UserAgent->new;
 $response = $ua->request($request);

説明

HTTP::Request is a class encapsulating HTTP style requests, consisting of a request line, some headers, and a content body. Note that the LWP library uses HTTP style requests even for non-HTTP protocols. Instances of this class are usually passed to the request() method of an LWP::UserAgent object.

HTTP::Request クラスは HTTP 形式のリクエストをカプセル化します。 レスポンスはリクエスト行、いくつかのヘッダ、そして内容の本体(content body)で 構成されます。 LWP ライブラリは HTTP プロトコルでないスキームにも、HTTP 形式のリクエストを 使っていることに注意してください。 このクラスのインスタンスは普通は LWP::UserAgent オブジェクトの request() メソッドに渡されます。

HTTP::Request is a subclass of HTTP::Message and therefore inherits its methods. The following additional methods are available:

HTTP::RequestHTTP::Message のサブクラスなので、そのメソッドを 継承しています。 以下の追加のメソッドが利用できます:

$r = HTTP::Request->new( $method, $uri )
$r = HTTP::Request->new( $method, $uri, $header )
$r = HTTP::Request->new( $method, $uri, $header, $content )

Constructs a new HTTP::Request object describing a request on the object $uri using method $method. The $method argument must be a string. The $uri argument can be either a string, or a reference to a URI object. The optional $header argument should be a reference to an HTTP::Headers object or a plain array reference of key/value pairs. The optional $content argument should be a string of bytes.

オブジェクト $uri へメソッド $method を使ったリクエストについて記述する HTTP::Request オブジェクトを組みたてます。 $method 引数は文字列でなければなりません。 $uri 引数は文字列か URI オブジェクトへのリファレンスが指定できます。 オプションの $header 引数は HTTP::Headers オブジェクトへの リファレンスか、キー/値のペアの配列へのリファレンスでなければなりません。 オプションの $content 引数はバイト列の文字列です。

$r = HTTP::Request->parse( $str )

This constructs a new request object by parsing the given string.

これは、与えられた文字列をパースすることによって新しいリクエスト オブジェクトを構築します。

$r->method
$r->method( $val )

This is used to get/set the method attribute. The method should be a short string like "GET", "HEAD", "PUT" or "POST".

これはメソッド属性を取得/設定するために使われます。 メソッドは "GET", "HEAD", "PUT", "POST" のような短い文字列であるべきです。

$r->uri
$r->uri( $val )

This is used to get/set the uri attribute. The $val can be a reference to a URI object or a plain string. If a string is given, then it should be parseable as an absolute URI.

これは uri 属性を取得/設定するために使います。 $val は URI オブジェクトか普通の文字列のどちらかです。 文字列が与えられた場合、絶対 URI として解析できるものでなければなりません。

$r->header( $field )
$r->header( $field => $value )

This is used to get/set header values and it is inherited from HTTP::Headers via HTTP::Message. See HTTP::Headers for details and other similar methods that can be used to access the headers.

これはヘッダの値を取得/設定するために使い、これは HTTP::Headers から HTTP::Message 経由で継承されます。 詳細と、ヘッダにアクセスするために使われる同様のメソッドについては HTTP::Headers を参照してください。

$r->content
$r->content( $bytes )

This is used to get/set the content and it is inherited from the HTTP::Message base class. See HTTP::Message for details and other methods that can be used to access the content.

これは内容を取得/設定するために使い、これは HTTP::Message 基底クラスから 継承されます。 詳細と、内容にアクセスするために使われるその他のメソッドについては HTTP::Message を参照してください。

Note that the content should be a string of bytes. Strings in perl can contain characters outside the range of a byte. The Encode module can be used to turn such strings into a string of bytes.

内容はバイト列であることに注意してください。 perl での文字列はバイトの範囲外の文字を含むことができます。 Encode モジュールはそのような文字列をバイト列に変換できます。

$r->as_string
$r->as_string( $eol )

Method returning a textual representation of the request.

リクエストのテキスト形式表現を返します。

SEE ALSO

HTTP::Headers, HTTP::Message, HTTP::Request::Common, HTTP::Response

コピーライト

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.