libwww-perl-5.813 >
6.04
との差分
LWP::UserAgent 6.04 と 5.813 の差分
1 | 1 | |
2 | 2 | =encoding euc-jp |
3 | 3 | |
4 | 4 | =head1 NAME |
5 | 5 | |
6 | 6 | =begin original |
7 | 7 | |
8 | 8 | LWP::UserAgent - Web user agent class |
9 | 9 | |
10 | 10 | =end original |
11 | 11 | |
12 | 12 | LWP::UserAgent - Web ユーザエージェントクラス |
13 | 13 | |
14 | 14 | =head1 SYNOPSIS |
15 | 15 | |
16 | 16 | require LWP::UserAgent; |
17 | 17 | |
18 | 18 | my $ua = LWP::UserAgent->new; |
19 | 19 | $ua->timeout(10); |
20 | 20 | $ua->env_proxy; |
21 | 21 | |
22 | 22 | my $response = $ua->get('http://search.cpan.org/'); |
23 | 23 | |
24 | 24 | if ($response->is_success) { |
25 | print $response-> | |
25 | print $response->content; # or whatever | |
26 | 26 | } |
27 | 27 | else { |
28 | 28 | die $response->status_line; |
29 | 29 | } |
30 | 30 | |
31 | 31 | =head1 DESCRIPTION |
32 | 32 | |
33 | 33 | =begin original |
34 | 34 | |
35 | 35 | The C<LWP::UserAgent> is a class implementing a web user agent. |
36 | 36 | C<LWP::UserAgent> objects can be used to dispatch web requests. |
37 | 37 | |
38 | 38 | =end original |
39 | 39 | |
40 | 40 | C<LWP::UserAgent> は web ユーザエージェントを実装するクラスです。 |
41 | 41 | C<LWP::UserAgent> オブジェクトは web リクエストを発行(dispatch)するために |
42 | 42 | 使えます。 |
43 | 43 | |
44 | 44 | =begin original |
45 | 45 | |
46 | 46 | In normal use the application creates an C<LWP::UserAgent> object, and |
47 | 47 | then configures it with values for timeouts, proxies, name, etc. It |
48 | 48 | then creates an instance of C<HTTP::Request> for the request that |
49 | 49 | needs to be performed. This request is then passed to one of the |
50 | 50 | request method the UserAgent, which dispatches it using the relevant |
51 | 51 | protocol, and returns a C<HTTP::Response> object. There are |
52 | 52 | convenience methods for sending the most common request types: get(), |
53 | head() | |
53 | head() and post(). When using these methods then the creation of the | |
54 | ||
54 | request object is hidden as shown in the synopsis above. | |
55 | 55 | |
56 | 56 | =end original |
57 | 57 | |
58 | 58 | 通常の使用では、アプリケーションは C<LWP::UserAgent> クラスを作成し、 |
59 | 59 | タイムアウト、プロキシ、名前などのための値でそれを設定します。 |
60 | 60 | それから実行される必要があるリクエストのために C<HTTP::Request> の |
61 | 61 | インスタンスを作成します。 |
62 | 62 | そしてこのリクエストは UserAgent のリクエストメソッドの一つに渡されます; |
63 | 63 | これは対応するプロトコルを使ってそれを発行し、 |
64 | 64 | C<HTTP::Response> オブジェクトを返します。 |
65 | もっとも一般的なリクエスト型のための便利メソッド get(), head(), post() | |
65 | もっとも一般的なリクエスト型のための便利メソッド get(), head(), post() | |
66 | ||
66 | があります。 | |
67 | 67 | これらのメソッドを使うときは、上述の用例の通り、 |
68 | 68 | リクエストオブジェクトの作成は隠蔽されます。 |
69 | 69 | |
70 | 70 | =begin original |
71 | 71 | |
72 | 72 | The basic approach of the library is to use HTTP style communication |
73 | 73 | for all protocol schemes. This means that you will construct |
74 | 74 | C<HTTP::Request> objects and receive C<HTTP::Response> objects even |
75 | 75 | for non-HTTP resources like I<gopher> and I<ftp>. In order to achieve |
76 | 76 | even more similarity to HTTP style communications, gopher menus and |
77 | 77 | file directories are converted to HTML documents. |
78 | 78 | |
79 | 79 | =end original |
80 | 80 | |
81 | 81 | このライブラリの基本的なアプローチは、HTTP 式通信をすべての |
82 | 82 | プロトコルスキームに使うことです。 |
83 | 83 | つまり I<gopher> や I<ftp> のような非 HTTP リソースでも |
84 | 84 | C<HTTP::Request> オブジェクトを構築して |
85 | 85 | C<HTTP::Response> オブジェクトを受け取るということです。 |
86 | 86 | より HTTP 式通信に似せるため、gopher メニューとファイルディレクトリは |
87 | 87 | HTML ドキュメントに変換されます。 |
88 | 88 | |
89 | 89 | =head1 CONSTRUCTOR METHODS |
90 | 90 | |
91 | 91 | (コンストラクタメソッド) |
92 | 92 | |
93 | 93 | =begin original |
94 | 94 | |
95 | 95 | The following constructor methods are available: |
96 | 96 | |
97 | 97 | =end original |
98 | 98 | |
99 | 99 | 以下のコンストラクタメソッドが利用可能です: |
100 | 100 | |
101 | 101 | =over 4 |
102 | 102 | |
103 | 103 | =item $ua = LWP::UserAgent->new( %options ) |
104 | 104 | |
105 | 105 | =begin original |
106 | 106 | |
107 | 107 | This method constructs a new C<LWP::UserAgent> object and returns it. |
108 | 108 | Key/value pair arguments may be provided to set up the initial state. |
109 | 109 | The following options correspond to attribute methods described below: |
110 | 110 | |
111 | 111 | =end original |
112 | 112 | |
113 | 113 | このメソッドは新しい C<LWP::UserAgent> オブジェクトを構成して、それを |
114 | 114 | 返します。 |
115 | 115 | 初期状態を設定するためにキー-値のペアの引数を指定できます。 |
116 | 116 | 以下のオプションは後述する属性メソッドに対応します: |
117 | 117 | |
118 | 118 | KEY DEFAULT |
119 | 119 | ----------- -------------------- |
120 | agent "libwww-perl/#.#<#del>#" | |
120 | agent "libwww-perl/#.##" | |
121 | 121 | from undef |
122 | 122 | conn_cache undef |
123 | 123 | cookie_jar undef |
124 | 124 | default_headers HTTP::Headers->new |
125 | local_address undef | |
126 | ssl_opts { verify_hostname => 1 } | |
127 | 125 | max_size undef |
128 | 126 | max_redirect 7 |
129 | 127 | parse_head 1 |
130 | 128 | protocols_allowed undef |
131 | 129 | protocols_forbidden undef |
132 | 130 | requests_redirectable ['GET', 'HEAD'] |
133 | 131 | timeout 180 |
134 | 132 | |
135 | 133 | =begin original |
136 | 134 | |
137 | The following additional options are also accepted: If the | |
135 | The following additional options are also accepted: If the | |
138 | is passed in with a TRUE value, then proxy | |
136 | C<env_proxy> option is passed in with a TRUE value, then proxy | |
139 | variables (see env_proxy() method | |
137 | settings are read from environment variables (see env_proxy() method | |
140 | ||
138 | below). If the C<keep_alive> option is passed in, then a | |
141 | ||
139 | C<LWP::ConnCache> is set up (see conn_cache() method below). The | |
142 | C< | |
140 | C<keep_alive> value is passed on as the C<total_capacity> for the | |
143 | ||
141 | connection cache. | |
144 | 142 | |
145 | 143 | =end original |
146 | 144 | |
147 | 145 | 以下の追加のオプションも指定できます: |
148 | 146 | C<env_proxy> オプションが真の値とともに渡されると、プロキシセッティングは |
149 | 147 | 環境変数から読み込まれます(後述する env_proxy() メソッドを参照してください)。 |
150 | C<env_proxy> が提供されない場合、C<PERL_LWP_ENV_PROXY> 環境変数は、 | |
151 | 初期化中に env_proxy() が呼び出されるかを制御します。 | |
152 | 148 | C<keep_alive> オプションが渡されると、 |
153 | 149 | C<LWP::ConnCache> が設定されます(後述する conn_cache() メソッドを |
154 | 150 | 参照してください)。 |
155 | 151 | C<keep_alive> の値は接続キャッシュのための C<total_capacity> として |
156 | 152 | 渡されます。 |
157 | 153 | |
158 | 154 | =item $ua->clone |
159 | 155 | |
160 | 156 | =begin original |
161 | 157 | |
162 | 158 | Returns a copy of the LWP::UserAgent object. |
163 | 159 | |
164 | 160 | =end original |
165 | 161 | |
166 | 162 | LWP::UserAgent オブジェクトのコピーを返します。 |
167 | 163 | |
168 | 164 | =back |
169 | 165 | |
170 | 166 | =head1 ATTRIBUTES |
171 | 167 | |
172 | 168 | (属性) |
173 | 169 | |
174 | 170 | =begin original |
175 | 171 | |
176 | 172 | The settings of the configuration attributes modify the behaviour of the |
177 | 173 | C<LWP::UserAgent> when it dispatches requests. Most of these can also |
178 | 174 | be initialized by options passed to the constructor method. |
179 | 175 | |
180 | 176 | =end original |
181 | 177 | |
182 | 178 | 設定属性は、C<LWP::UserAgent> がリクエストを発行するときの振る舞いを |
183 | 179 | 変更します。 |
184 | 180 | これらのほとんどはコンストラクタメソッドに渡されたオプションによっても |
185 | 181 | 初期化できます。 |
186 | 182 | |
187 | 183 | =begin original |
188 | 184 | |
189 | The following attribute methods are provided. The attribute value is | |
185 | The following attributes methods are provided. The attribute value is | |
190 | 186 | left unchanged if no argument is given. The return value from each |
191 | 187 | method is the old attribute value. |
192 | 188 | |
193 | 189 | =end original |
194 | 190 | |
195 | 191 | 以下の属性メソッドが提供されています。 |
196 | 192 | 引数がない場合は属性値は変更されません。 |
197 | 193 | それぞれのメソッドの返り値は古い属性値です。 |
198 | 194 | |
199 | 195 | =over |
200 | 196 | |
201 | 197 | =item $ua->agent |
202 | 198 | |
203 | 199 | =item $ua->agent( $product_id ) |
204 | 200 | |
205 | 201 | =begin original |
206 | 202 | |
207 | 203 | Get/set the product token that is used to identify the user agent on |
208 | 204 | the network. The agent value is sent as the "User-Agent" header in |
209 | 205 | the requests. The default is the string returned by the _agent() |
210 | 206 | method (see below). |
211 | 207 | |
212 | 208 | =end original |
213 | 209 | |
214 | 210 | ネットワーク上でユーザエージェントを識別するために使われる |
215 | 211 | 製品トークン(product token)を取得または設定します。 |
216 | 212 | エージェントの値はリクエストの "User-Agent" ヘッダとして送信されます。 |
217 | 213 | デフォルトは _agent() メソッド(後述)で返される文字列です。 |
218 | 214 | |
219 | 215 | =begin original |
220 | 216 | |
221 | 217 | If the $product_id ends with space then the _agent() string is |
222 | 218 | appended to it. |
223 | 219 | |
224 | 220 | =end original |
225 | 221 | |
226 | 222 | $product_id が空白で終わっている場合は、その値に _agent() の文字列が |
227 | 223 | 追加されます。 |
228 | 224 | |
229 | 225 | =begin original |
230 | 226 | |
231 | 227 | The user agent string should be one or more simple product identifiers |
232 | 228 | with an optional version number separated by the "/" character. |
233 | 229 | Examples are: |
234 | 230 | |
235 | 231 | =end original |
236 | 232 | |
237 | 233 | ユーザエージェント文字列は、オプションで "/" 文字で |
238 | 234 | 区切られたバージョン番号がついた、一つもしくはそれ以上の単純な |
239 | 235 | 製品トークンです。 |
240 | 236 | 例を以下に示します: |
241 | 237 | |
242 | 238 | $ua->agent('Checkbot/0.4 ' . $ua->_agent); |
243 | 239 | $ua->agent('Checkbot/0.4 '); # same as above |
244 | 240 | $ua->agent('Mozilla/5.0'); |
245 | 241 | $ua->agent(""); # don't identify |
246 | 242 | |
247 | 243 | =item $ua->_agent |
248 | 244 | |
249 | 245 | =begin original |
250 | 246 | |
251 | 247 | Returns the default agent identifier. This is a string of the form |
252 | "libwww-perl/#.#<#del>#", where "#. | |
248 | "libwww-perl/#.##", where "#.##" is substituted with the version number | |
253 | 249 | of this library. |
254 | 250 | |
255 | 251 | =end original |
256 | 252 | |
257 | 253 | デフォルトのエージェント識別子を返します。 |
258 | これは "libwww-perl/#.#<#del>#" 形式の文字列で、"#. | |
254 | これは "libwww-perl/#.##" 形式の文字列で、"#.##" はこのライブラリの | |
259 | 255 | バージョン番号で置き換えられます。 |
260 | 256 | |
261 | 257 | =item $ua->from |
262 | 258 | |
263 | 259 | =item $ua->from( $email_address ) |
264 | 260 | |
265 | 261 | =begin original |
266 | 262 | |
267 | 263 | Get/set the e-mail address for the human user who controls |
268 | 264 | the requesting user agent. The address should be machine-usable, as |
269 | 265 | defined in RFC 822. The C<from> value is send as the "From" header in |
270 | 266 | the requests. Example: |
271 | 267 | |
272 | 268 | =end original |
273 | 269 | |
274 | 270 | リクエストしているユーザエージェントを制御している人間であるユーザの |
275 | 271 | e-mail アドレスを取得または設定します。 |
276 | 272 | アドレスは RFC で定義されているように、機械で利用できなければなりません。 |
277 | 273 | C<from> の値はリクエストでの "From" ヘッダとして送信されます。 |
278 | 274 | 例: |
279 | 275 | |
280 | 276 | $ua->from('gaas@cpan.org'); |
281 | 277 | |
282 | 278 | =begin original |
283 | 279 | |
284 | 280 | The default is to not send a "From" header. See the default_headers() |
285 | 281 | method for the more general interface that allow any header to be defaulted. |
286 | 282 | |
287 | 283 | =end original |
288 | 284 | |
289 | 285 | デフォルトでは、"From" ヘッダを送信しません。 |
290 | 286 | 任意のヘッダをデフォルトで指定できる、より一般的なインターフェースについては |
291 | 287 | default_headers() メソッドを参照してください。 |
292 | 288 | |
293 | 289 | =item $ua->cookie_jar |
294 | 290 | |
295 | 291 | =item $ua->cookie_jar( $cookie_jar_obj ) |
296 | 292 | |
297 | 293 | =begin original |
298 | 294 | |
299 | 295 | Get/set the cookie jar object to use. The only requirement is that |
300 | 296 | the cookie jar object must implement the extract_cookies($request) and |
301 | 297 | add_cookie_header($response) methods. These methods will then be |
302 | 298 | invoked by the user agent as requests are sent and responses are |
303 | 299 | received. Normally this will be a C<HTTP::Cookies> object or some |
304 | 300 | subclass. |
305 | 301 | |
306 | 302 | =end original |
307 | 303 | |
308 | 304 | 使用するクッキー瓶(cookie jar)オブジェクトを取得または設定します。 |
309 | 305 | 唯一の必要条件は、クッキー瓶オブジェクトは |
310 | 306 | extract_cookies($request) メソッドと add_cookie_header($response) メソッドを |
311 | 307 | 実装している必要があると言うことです。 |
312 | 308 | これらのメソッドは、リクエストが送信されるときとレスポンスが受信されたときに |
313 | 309 | ユーザエージェントによって起動されます。 |
314 | 310 | 通常これは C<HTTP::Cookies> オブジェクトかそのサブクラスです。 |
315 | 311 | |
316 | 312 | =begin original |
317 | 313 | |
318 | 314 | The default is to have no cookie_jar, i.e. never automatically add |
319 | 315 | "Cookie" headers to the requests. |
320 | 316 | |
321 | 317 | =end original |
322 | 318 | |
323 | 319 | デフォルトではクッキー瓶を使いません; |
324 | 320 | つまり自動的には "Cookie" ヘッダをリクエストに追加しません。 |
325 | 321 | |
326 | 322 | =begin original |
327 | 323 | |
328 | 324 | Shortcut: If a reference to a plain hash is passed in as the |
329 | 325 | $cookie_jar_object, then it is replaced with an instance of |
330 | 326 | C<HTTP::Cookies> that is initialized based on the hash. This form also |
331 | 327 | automatically loads the C<HTTP::Cookies> module. It means that: |
332 | 328 | |
333 | 329 | =end original |
334 | 330 | |
335 | 331 | 短縮形: もし単純なハッシュへのリファレンスが |
336 | 332 | $cookie_jar_object として渡されると、このハッシュを基にして初期化された |
337 | 333 | C<HTTP::Cookies> のインスタンスで置き換えられます。 |
338 | 334 | この形式はまた、自動的に C<HTTP::Cookies> モジュールを読み込みます。 |
339 | 335 | つまり、以下のようにすると: |
340 | 336 | |
341 | 337 | $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" }); |
342 | 338 | |
343 | 339 | =begin original |
344 | 340 | |
345 | 341 | is really just a shortcut for: |
346 | 342 | |
347 | 343 | =end original |
348 | 344 | |
349 | 345 | これは実際には以下の省略形です: |
350 | 346 | |
351 | 347 | require HTTP::Cookies; |
352 | 348 | $ua->cookie_jar(HTTP::Cookies->new(file => "$ENV{HOME}/.cookies.txt")); |
353 | 349 | |
354 | 350 | =item $ua->default_headers |
355 | 351 | |
356 | 352 | =item $ua->default_headers( $headers_obj ) |
357 | 353 | |
358 | 354 | =begin original |
359 | 355 | |
360 | 356 | Get/set the headers object that will provide default header values for |
361 | 357 | any requests sent. By default this will be an empty C<HTTP::Headers> |
362 | object. | |
358 | object. Example: | |
363 | 359 | |
364 | 360 | =end original |
365 | 361 | |
366 | 362 | 任意のレスポンスが送信されるときのデフォルトのヘッダ値を提供する |
367 | 363 | ヘッダオブジェクトを取得または設定します。 |
368 | 364 | デフォルトではこれは空の C<HTTP::Headers> オブジェクトです。 |
365 | 例: | |
369 | 366 | |
367 | $ua->default_headers->push_header('Accept-Language' => "no, en"); | |
368 | ||
370 | 369 | =item $ua->default_header( $field ) |
371 | 370 | |
372 | 371 | =item $ua->default_header( $field => $value ) |
373 | 372 | |
374 | 373 | =begin original |
375 | 374 | |
376 | 375 | This is just a short-cut for $ua->default_headers->header( $field => |
377 | 376 | $value ). Example: |
378 | 377 | |
379 | 378 | =end original |
380 | 379 | |
381 | 380 | これは単に $ua->default_headers->header( $field => $value ) の |
382 | 381 | 短縮形です。 |
383 | 382 | 例: |
384 | 383 | |
385 | $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable()); | |
386 | 384 | $ua->default_header('Accept-Language' => "no, en"); |
387 | 385 | |
388 | 386 | =item $ua->conn_cache |
389 | 387 | |
390 | 388 | =item $ua->conn_cache( $cache_obj ) |
391 | 389 | |
392 | 390 | =begin original |
393 | 391 | |
394 | 392 | Get/set the C<LWP::ConnCache> object to use. See L<LWP::ConnCache> |
395 | 393 | for details. |
396 | 394 | |
397 | 395 | =end original |
398 | 396 | |
399 | 397 | 使用する C<LWP::ConnCache> オブジェクトを取得または設定します。 |
400 | 398 | 詳しくは L<LWP::ConnCache> を参照してください。 |
401 | 399 | |
402 | =item $ua->credentials( $netloc, $realm ) | |
403 | ||
404 | 400 | =item $ua->credentials( $netloc, $realm, $uname, $pass ) |
405 | 401 | |
406 | 402 | =begin original |
407 | 403 | |
408 | ||
404 | Set the user name and password to be used for a realm. It is often more | |
405 | useful to specialize the get_basic_credentials() method instead. | |
409 | 406 | |
410 | 407 | =end original |
411 | 408 | |
412 | あるレルムのために使われるユーザ名、パスワードを | |
409 | あるレルムのために使われるユーザ名、パスワードを設定します。 | |
410 | しばしば get_basic_credentials() メソッドを特殊化するよりも便利です。 | |
413 | 411 | |
414 | 412 | =begin original |
415 | 413 | |
416 | The $netloc | |
414 | The $netloc a string of the form "<host>:<port>". The username and | |
417 | 415 | password will only be passed to this server. Example: |
418 | 416 | |
419 | 417 | =end original |
420 | 418 | |
421 | 419 | $netloc は "<host>:<port>" の形式の文字列です。 |
422 | 420 | ユーザ名とパスワードはこのサーバにのみ渡されます。 |
423 | 421 | 例: |
424 | 422 | |
425 | 423 | $ua->credentials("www.example.com:80", "Some Realm", "foo", "secret"); |
426 | 424 | |
427 | =item $ua->local_address | |
428 | ||
429 | =item $ua->local_address( $address ) | |
430 | ||
431 | =begin original | |
432 | ||
433 | Get/set the local interface to bind to for network connections. The interface | |
434 | can be specified as a hostname or an IP address. This value is passed as the | |
435 | C<LocalAddr> argument to L<IO::Socket::INET>. | |
436 | ||
437 | =end original | |
438 | ||
439 | ネットワーク接続のために bind するローカルインターフェースを取得/設定します。 | |
440 | インターフェースはホスト名または IP アドレスとして指定できます。 | |
441 | この値は L<IO::Socket::INET> に C<LocalAddr> 引数として渡されます。 | |
442 | ||
443 | 425 | =item $ua->max_size |
444 | 426 | |
445 | 427 | =item $ua->max_size( $bytes ) |
446 | 428 | |
447 | 429 | =begin original |
448 | 430 | |
449 | 431 | Get/set the size limit for response content. The default is C<undef>, |
450 | 432 | which means that there is no limit. If the returned response content |
451 | 433 | is only partial, because the size limit was exceeded, then a |
452 | 434 | "Client-Aborted" header will be added to the response. The content |
453 | 435 | might end up longer than C<max_size> as we abort once appending a |
454 | 436 | chunk of data makes the length exceed the limit. The "Content-Length" |
455 | 437 | header, if present, will indicate the length of the full content and |
456 | 438 | will normally not be the same as C<< length($res->content) >>. |
457 | 439 | |
458 | 440 | =end original |
459 | 441 | |
460 | 442 | レスポンスの内容(content)の大きさの制限を取得または設定します。 |
461 | 443 | デフォルトは C<undef> で、これは制限なしを意味します。 |
462 | 444 | 長さの制限を越えているために、戻されたレスポンスの内容が |
463 | 445 | 一部だけであれば、"Client-Aborted" ヘッダがレスポンスに追加されます。 |
464 | 446 | 内容の長さが制限を超えることになるデータの固まりに追加するのを |
465 | 447 | 中断するので、内容の長さは結局 C<max_size> を |
466 | 448 | 超えることになることがあります。 |
467 | 449 | もし "Content-Length" ヘッダがあれば、内容全体の長さを示していて、 |
468 | 450 | これは通常は C<< length($res->content) >> と同じではありません。 |
469 | 451 | |
470 | 452 | =item $ua->max_redirect |
471 | 453 | |
472 | 454 | =item $ua->max_redirect( $n ) |
473 | 455 | |
474 | 456 | =begin original |
475 | 457 | |
476 | 458 | This reads or sets the object's limit of how many times it will obey |
477 | 459 | redirection responses in a given request cycle. |
478 | 460 | |
479 | 461 | =end original |
480 | 462 | |
481 | 463 | これは、1 回のリクエストで従うリダイレクトレスポンスの |
482 | 464 | 回数の制限を読み込みまたは設定します。 |
483 | 465 | |
484 | 466 | =begin original |
485 | 467 | |
486 | 468 | By default, the value is 7. This means that if you call request() |
487 | 469 | method and the response is a redirect elsewhere which is in turn a |
488 | 470 | redirect, and so on seven times, then LWP gives up after that seventh |
489 | 471 | request. |
490 | 472 | |
491 | 473 | =end original |
492 | 474 | |
493 | 475 | デフォルトでは、この値は 7 です。 |
494 | 476 | これは、request() を呼び出して、リダイレクトされた先でさらに |
495 | 477 | リダイレクトされて、というのを 7 回繰り返すと、LWP は 7 回目の |
496 | 478 | リクエストの後に諦めます。 |
497 | 479 | |
498 | 480 | =item $ua->parse_head |
499 | 481 | |
500 | 482 | =item $ua->parse_head( $boolean ) |
501 | 483 | |
502 | 484 | =begin original |
503 | 485 | |
504 | 486 | Get/set a value indicating whether we should initialize response |
505 | 487 | headers from the E<lt>head> section of HTML documents. The default is |
506 | 488 | TRUE. Do not turn this off, unless you know what you are doing. |
507 | 489 | |
508 | 490 | =end original |
509 | 491 | |
510 | 492 | HTML ドキュメントの E<lt>head> セクションからレスポンスヘッダを |
511 | 493 | 初期化すべきかどうかを示す値を取得または設定します。 |
512 | 494 | デフォルトは TRUE です。 |
513 | 495 | 何をしているのかわからなければ、これをオフにしないで下さい。 |
514 | 496 | |
515 | 497 | =item $ua->protocols_allowed |
516 | 498 | |
517 | 499 | =item $ua->protocols_allowed( \@protocols ) |
518 | 500 | |
519 | 501 | =begin original |
520 | 502 | |
521 | 503 | This reads (or sets) this user agent's list of protocols that the |
522 | 504 | request methods will exclusively allow. The protocol names are case |
523 | 505 | insensitive. |
524 | 506 | |
525 | 507 | =end original |
526 | 508 | |
527 | 509 | これはこのユーザエージェントが排他的に許可されているプロトコルのリストを |
528 | 510 | 読み込み(または設定)します。 |
529 | 511 | プロトコル名は大文字小文字を無視します。 |
530 | 512 | |
531 | 513 | =begin original |
532 | 514 | |
533 | 515 | For example: C<$ua-E<gt>protocols_allowed( [ 'http', 'https'] );> |
534 | 516 | means that this user agent will I<allow only> those protocols, |
535 | 517 | and attempts to use this user agent to access URLs with any other |
536 | 518 | schemes (like "ftp://...") will result in a 500 error. |
537 | 519 | |
538 | 520 | =end original |
539 | 521 | |
540 | 522 | 例: C<$ua-E<gt>protocols_allowed( [ 'http', 'https'] );> というのは、 |
541 | 523 | このユーザエージェントはこれらのプロトコル I<のみ許可されている> ことを |
542 | 524 | 意味していて、このユーザエージェントが ("ftp://..." のような) その他の |
543 | 525 | スキームの URL にアクセスしようとすると 500 エラーとなります。 |
544 | 526 | |
545 | 527 | =begin original |
546 | 528 | |
547 | 529 | To delete the list, call: C<$ua-E<gt>protocols_allowed(undef)> |
548 | 530 | |
549 | 531 | =end original |
550 | 532 | |
551 | 533 | リストを削除するには、以下のように呼び出します: C<$ua-E<gt>protocols_allowed(undef)> |
552 | 534 | |
553 | 535 | =begin original |
554 | 536 | |
555 | 537 | By default, an object has neither a C<protocols_allowed> list, nor a |
556 | 538 | C<protocols_forbidden> list. |
557 | 539 | |
558 | 540 | =end original |
559 | 541 | |
560 | 542 | デフォルトでは、オブジェクトは C<protocols_allowed> リストと |
561 | 543 | C<protocols_forbidden> リストのどちらも持ちません。 |
562 | 544 | |
563 | 545 | =begin original |
564 | 546 | |
565 | 547 | Note that having a C<protocols_allowed> list causes any |
566 | 548 | C<protocols_forbidden> list to be ignored. |
567 | 549 | |
568 | 550 | =end original |
569 | 551 | |
570 | 552 | C<protocols_allowed> リストがあると C<protocols_forbidden> リストは |
571 | 553 | 無視されることに注意してください。 |
572 | 554 | |
573 | 555 | =item $ua->protocols_forbidden |
574 | 556 | |
575 | 557 | =item $ua->protocols_forbidden( \@protocols ) |
576 | 558 | |
577 | 559 | =begin original |
578 | 560 | |
579 | 561 | This reads (or sets) this user agent's list of protocols that the |
580 | 562 | request method will I<not> allow. The protocol names are case |
581 | 563 | insensitive. |
582 | 564 | |
583 | 565 | =end original |
584 | 566 | |
585 | 567 | これはこのユーザエージェントが I<許可されていない> プロトコルのリストを |
586 | 568 | 読み込み(または設定)します。 |
587 | 569 | プロトコル名は大文字小文字を無視します。 |
588 | 570 | |
589 | 571 | =begin original |
590 | 572 | |
591 | 573 | For example: C<$ua-E<gt>protocols_forbidden( [ 'file', 'mailto'] );> |
592 | 574 | means that this user agent will I<not> allow those protocols, and |
593 | 575 | attempts to use this user agent to access URLs with those schemes |
594 | 576 | will result in a 500 error. |
595 | 577 | |
596 | 578 | =end original |
597 | 579 | |
598 | 580 | 例: C<$ua-E<gt>protocols_forbidden( [ 'file', 'mailto'] );> は |
599 | 581 | このユーザエージェントはこれらのプロトコルを I<許可せず>、 |
600 | 582 | このユーザエージェントを使ってこれらのスキーマで URL に |
601 | 583 | アクセスしようとすると 500 エラーになります。 |
602 | 584 | |
603 | 585 | =begin original |
604 | 586 | |
605 | 587 | To delete the list, call: C<$ua-E<gt>protocols_forbidden(undef)> |
606 | 588 | |
607 | 589 | =end original |
608 | 590 | |
609 | 591 | リストを削除するには、このように呼び出します: C<$ua-E<gt>protocols_forbidden(undef)> |
610 | 592 | |
611 | 593 | =item $ua->requests_redirectable |
612 | 594 | |
613 | 595 | =item $ua->requests_redirectable( \@requests ) |
614 | 596 | |
615 | 597 | =begin original |
616 | 598 | |
617 | 599 | This reads or sets the object's list of request names that |
618 | 600 | C<$ua-E<gt>redirect_ok(...)> will allow redirection for. By |
619 | 601 | default, this is C<['GET', 'HEAD']>, as per RFC 2616. To |
620 | 602 | change to include 'POST', consider: |
621 | 603 | |
622 | 604 | =end original |
623 | 605 | |
624 | 606 | これは C<$ua-E<gt>redirect_ok(...)> がリダイレクトを許可する |
625 | 607 | リクエスト名のリストを読み込みまたは設定します。 |
626 | 608 | デフォルトでは、これは RFC 2616 に従って C<['GET', 'HEAD']> になっています。 |
627 | 609 | 'POST' を含むようにするには、以下のようにします: |
628 | 610 | |
629 | 611 | push @{ $ua->requests_redirectable }, 'POST'; |
630 | 612 | |
631 | =item $ua->show_progress | |
632 | ||
633 | =item $ua->show_progress( $boolean ) | |
634 | ||
635 | =begin original | |
636 | ||
637 | Get/set a value indicating whether a progress bar should be displayed | |
638 | on on the terminal as requests are processed. The default is FALSE. | |
639 | ||
640 | =end original | |
641 | ||
642 | リクエストの処理時に端末にプログレスバーを表示するかどうかを示す | |
643 | 値を取得/設定します。 | |
644 | デフォルトは偽です。 | |
645 | ||
646 | 613 | =item $ua->timeout |
647 | 614 | |
648 | 615 | =item $ua->timeout( $secs ) |
649 | 616 | |
650 | 617 | =begin original |
651 | 618 | |
652 | 619 | Get/set the timeout value in seconds. The default timeout() value is |
653 | 620 | 180 seconds, i.e. 3 minutes. |
654 | 621 | |
655 | 622 | =end original |
656 | 623 | |
657 | 624 | 秒単位のタイムアウト値を取得または設定します。 |
658 | 625 | デフォルトの timeout() の値は 180 秒、つまり 3 分です。 |
659 | 626 | |
660 | 627 | =begin original |
661 | 628 | |
662 | 629 | The requests is aborted if no activity on the connection to the server |
663 | 630 | is observed for C<timeout> seconds. This means that the time it takes |
664 | 631 | for the complete transaction and the request() method to actually |
665 | 632 | return might be longer. |
666 | 633 | |
667 | 634 | =end original |
668 | 635 | |
669 | 636 | サーバへの接続において C<timeout> 秒反応がないと、リクエストは中断します。 |
670 | 637 | つまり、トランザクションが完了して request() メソッドが実際に返るまでの |
671 | 638 | 時間を意味します。 |
672 | 639 | |
673 | =item $ua->ssl_opts | |
674 | ||
675 | =item $ua->ssl_opts( $key ) | |
676 | ||
677 | =item $ua->ssl_opts( $key => $value ) | |
678 | ||
679 | =begin original | |
680 | ||
681 | Get/set the options for SSL connections. Without argument return the list | |
682 | of options keys currently set. With a single argument return the current | |
683 | value for the given option. With 2 arguments set the option value and return | |
684 | the old. Setting an option to the value C<undef> removes this option. | |
685 | ||
686 | =end original | |
687 | ||
688 | SSL 接続のオプションを取得/設定します。 | |
689 | 引数なしの場合、現在設定されているオプションキーの一覧を返します。 | |
690 | 1 引数の場合、与えられたオプションの現在の値を返します。 | |
691 | 2 引数の場合、オプションの値を設定して、古いものを返します。 | |
692 | オプションとして C<undef> 値を設定すると、このオプションを削除します。 | |
693 | ||
694 | =begin original | |
695 | ||
696 | The options that LWP relates to are: | |
697 | ||
698 | =end original | |
699 | ||
700 | LWP に関するオプションは: | |
701 | ||
702 | =over | |
703 | ||
704 | =item C<verify_hostname> => $bool | |
705 | ||
706 | =begin original | |
707 | ||
708 | When TRUE LWP will for secure protocol schemes ensure it connects to servers | |
709 | that have a valid certificate matching the expected hostname. If FALSE no | |
710 | checks are made and you can't be sure that you communicate with the expected peer. | |
711 | The no checks behaviour was the default for libwww-perl-5.837 and earlier releases. | |
712 | ||
713 | =end original | |
714 | ||
715 | 真の場合、LWP は、セキュアなプロトコルスキームで、 | |
716 | 妥当な証明書が想定されるホスト名に一致しているサーバに | |
717 | 接続していることを確認します。 | |
718 | 偽の場合、チェックは行われず、想定している接続先と通信しているかを | |
719 | 確認できません。 | |
720 | チェックしない振る舞いは、libwww-perl-5.837 以前のリリースのデフォルトでした。 | |
721 | ||
722 | =begin original | |
723 | ||
724 | This option is initialized from the L<PERL_LWP_SSL_VERIFY_HOSTNAME> environment | |
725 | variable. If this environment variable isn't set; then C<verify_hostname> | |
726 | defaults to 1. | |
727 | ||
728 | =end original | |
729 | ||
730 | このオプションは L<PERL_LWP_SSL_VERIFY_HOSTNAME> 環境変数で初期化されます。 | |
731 | 環境変数が設定されていない場合、C<verify_hostname> のデフォルトは 1 です。 | |
732 | ||
733 | =item C<SSL_ca_file> => $path | |
734 | ||
735 | =begin original | |
736 | ||
737 | The path to a file containing Certificate Authority certificates. | |
738 | A default setting for this option is provided by checking the environment | |
739 | variables C<PERL_LWP_SSL_CA_FILE> and C<HTTPS_CA_FILE> in order. | |
740 | ||
741 | =end original | |
742 | ||
743 | Certificate Authority 証明書があるファイルのパス。 | |
744 | このオプションのデフォルト設定は、環境変数 C<PERL_LWP_SSL_CA_FILE> と | |
745 | C<HTTPS_CA_FILE> をこの順序でチェックすることで提供されます。 | |
746 | ||
747 | =item C<SSL_ca_path> => $path | |
748 | ||
749 | =begin original | |
750 | ||
751 | The path to a directory containing files containing Certificate Authority | |
752 | certificates. | |
753 | A default setting for this option is provided by checking the environment | |
754 | variables C<PERL_LWP_SSL_CA_PATH> and C<HTTPS_CA_DIR> in order. | |
755 | ||
756 | =end original | |
757 | ||
758 | Certificate Authority 証明書があるファイルのあるディレクトリへのパス。 | |
759 | このオプションのデフォルト設定は、環境変数 C<PERL_LWP_SSL_CA_PATH> と | |
760 | C<HTTPS_CA_DIR> をこの順序でチェックすることで提供されます。 | |
761 | ||
762 | 640 | =back |
763 | 641 | |
764 | =begin original | |
765 | ||
766 | Other options can be set and are processed directly by the SSL Socket implementation | |
767 | in use. See L<IO::Socket::SSL> or L<Net::SSL> for details. | |
768 | ||
769 | =end original | |
770 | ||
771 | その他のオプションは、使っている SSL Socket 実装によって直接設定および | |
772 | 処理されます。 | |
773 | 詳しくは L<IO::Socket::SSL> や L<Net::SSL> を参照してください。 | |
774 | ||
775 | =begin original | |
776 | ||
777 | The libwww-perl core no longer bundles protocol plugins for SSL. You will need | |
778 | to install L<LWP::Protocol::https> separately to enable support for processing | |
779 | https-URLs. | |
780 | ||
781 | =end original | |
782 | ||
783 | libwww-perl コアはもはや SSL のためのプロトコルプラグインを同梱しません。 | |
784 | https-URL の処理の対応を有効にするために、個別に | |
785 | L<LWP::Protocol::https> をインストールする必要があります。 | |
786 | ||
787 | =back | |
788 | ||
789 | 642 | =head2 Proxy attributes |
790 | 643 | |
791 | 644 | (プロキシ属性) |
792 | 645 | |
793 | 646 | =begin original |
794 | 647 | |
795 | 648 | The following methods set up when requests should be passed via a |
796 | 649 | proxy server. |
797 | 650 | |
798 | 651 | =end original |
799 | 652 | |
800 | 653 | 以下のメソッドはプロキシサーバー経由で渡されるべきリクエストを設定します。 |
801 | 654 | |
802 | 655 | =over |
803 | 656 | |
804 | 657 | =item $ua->proxy(\@schemes, $proxy_url) |
805 | 658 | |
806 | 659 | =item $ua->proxy($scheme, $proxy_url) |
807 | 660 | |
808 | 661 | =begin original |
809 | 662 | |
810 | 663 | Set/retrieve proxy URL for a scheme: |
811 | 664 | |
812 | 665 | =end original |
813 | 666 | |
814 | 667 | あるスキームのためのプロキシ URL を設定または取得します: |
815 | 668 | |
816 | 669 | $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/'); |
817 | 670 | $ua->proxy('gopher', 'http://proxy.sn.no:8001/'); |
818 | 671 | |
819 | 672 | =begin original |
820 | 673 | |
821 | 674 | The first form specifies that the URL is to be used for proxying of |
822 | 675 | access methods listed in the list in the first method argument, |
823 | 676 | i.e. 'http' and 'ftp'. |
824 | 677 | |
825 | 678 | =end original |
826 | 679 | |
827 | 680 | 最初の形式はその URL がメソッドの最初に引数のリストに入っている |
828 | 681 | アクセスメソッド、つまり 'http' と 'ftp' のプロキシのために |
829 | 682 | 使われることを指定します。 |
830 | 683 | |
831 | 684 | =begin original |
832 | 685 | |
833 | 686 | The second form shows a shorthand form for specifying |
834 | 687 | proxy URL for a single access scheme. |
835 | 688 | |
836 | 689 | =end original |
837 | 690 | |
838 | 691 | 2 番目の形式は一つのアクセス機能のためのプロキシ URL を |
839 | 692 | 指定するための短縮した形式を示しています。 |
840 | 693 | |
841 | 694 | =item $ua->no_proxy( $domain, ... ) |
842 | 695 | |
843 | 696 | =begin original |
844 | 697 | |
845 | 698 | Do not proxy requests to the given domains. Calling no_proxy without |
846 | 699 | any domains clears the list of domains. Eg: |
847 | 700 | |
848 | 701 | =end original |
849 | 702 | |
850 | 703 | 与えられたドメインへのリクエストをプロキシしません。 |
851 | 704 | 何もドメインを指定しないで no_proxy を呼ぶと、ドメインのリストを |
852 | 705 | クリアします。 |
853 | 706 | 例: |
854 | 707 | |
855 | $ua->no_proxy('localhost', ' | |
708 | $ua->no_proxy('localhost', 'no', ...); | |
856 | 709 | |
857 | 710 | =item $ua->env_proxy |
858 | 711 | |
859 | 712 | =begin original |
860 | 713 | |
861 | 714 | Load proxy settings from *_proxy environment variables. You might |
862 | 715 | specify proxies like this (sh-syntax): |
863 | 716 | |
864 | 717 | =end original |
865 | 718 | |
866 | 719 | *_proxy 環境変数からプロキシ設定をロードします。 |
867 | 720 | 以下のように指定できるでしょう(sh での書き方): |
868 | 721 | |
869 | 722 | gopher_proxy=http://proxy.my.place/ |
870 | 723 | wais_proxy=http://proxy.my.place/ |
871 | no_proxy="localhost, | |
724 | no_proxy="localhost,my.domain" | |
872 | 725 | export gopher_proxy wais_proxy no_proxy |
873 | 726 | |
874 | 727 | =begin original |
875 | 728 | |
876 | 729 | csh or tcsh users should use the C<setenv> command to define these |
877 | 730 | environment variables. |
878 | 731 | |
879 | 732 | =end original |
880 | 733 | |
881 | 734 | csh または tcsh のユーザは、これらの環境変数を定義するために |
882 | 735 | C<setenv> コマンドを使わなければなりません。 |
883 | 736 | |
884 | 737 | =begin original |
885 | 738 | |
886 | 739 | On systems with case insensitive environment variables there exists a |
887 | 740 | name clash between the CGI environment variables and the C<HTTP_PROXY> |
888 | 741 | environment variable normally picked up by env_proxy(). Because of |
889 | 742 | this C<HTTP_PROXY> is not honored for CGI scripts. The |
890 | 743 | C<CGI_HTTP_PROXY> environment variable can be used instead. |
891 | 744 | |
892 | 745 | =end original |
893 | 746 | |
894 | 747 | 環境変数名に大文字小文字の区別がないシステムでは、 |
895 | 748 | CGI 環境変数と、通常 env_proxy() によって読み込まれる C<HTTP_PROXY> |
896 | 749 | 環境変数の間で名前の衝突があります。 |
897 | 750 | この理由により、C<HTTP_PROXY> は CGI スクリプトのためのものではありません。 |
898 | 751 | 代わりに C<CGI_HTTP_PROXY> 環境変数を使えます。 |
899 | 752 | |
900 | 753 | =back |
901 | 754 | |
902 | =head2 Handlers | |
903 | ||
904 | (ハンドラ) | |
905 | ||
906 | =begin original | |
907 | ||
908 | Handlers are code that injected at various phases during the | |
909 | processing of requests. The following methods are provided to manage | |
910 | the active handlers: | |
911 | ||
912 | =end original | |
913 | ||
914 | ハンドラは、リクエストの処理中の様々なフェーズに注入されるコードです。 | |
915 | アクティブなハンドラを管理するために次のメソッドが提供されています: | |
916 | ||
917 | =over | |
918 | ||
919 | =item $ua->add_handler( $phase => \&cb, %matchspec ) | |
920 | ||
921 | =begin original | |
922 | ||
923 | Add handler to be invoked in the given processing phase. For how to | |
924 | specify %matchspec see L<HTTP::Config/"Matching">. | |
925 | ||
926 | =end original | |
927 | ||
928 | 指定された処理フェーズで起動されるハンドラを追加します。 | |
929 | %matchspec の指定方法については L<HTTP::Config/"Matching"> を | |
930 | 参照してください。 | |
931 | ||
932 | =begin original | |
933 | ||
934 | The possible values $phase and the corresponding callback signatures are: | |
935 | ||
936 | =end original | |
937 | ||
938 | 取り得る $phase の値と、対応するコールバックのシグネチャは: | |
939 | ||
940 | =over | |
941 | ||
942 | =item request_preprepare => sub { my($request, $ua, $h) = @_; ... } | |
943 | ||
944 | =begin original | |
945 | ||
946 | The handler is called before the C<request_prepare> and other standard | |
947 | initialization of of the request. This can be used to set up headers | |
948 | and attributes that the C<request_prepare> handler depends on. Proxy | |
949 | initialization should take place here; but in general don't register | |
950 | handlers for this phase. | |
951 | ||
952 | =end original | |
953 | ||
954 | ハンドラは、C<request_prepare> とその他のリクエストの標準的な初期化の | |
955 | 前に呼び出されます。 | |
956 | これは C<request_prepare> ハンドラが依存するヘッダと属性を | |
957 | 設定するのに使えます。 | |
958 | プロキシ初期化はここに置く必要があります; | |
959 | しかし一般的にはこのフェーズにハンドルを登録しないでください。 | |
960 | ||
961 | =item request_prepare => sub { my($request, $ua, $h) = @_; ... } | |
962 | ||
963 | =begin original | |
964 | ||
965 | The handler is called before the request is sent and can modify the | |
966 | request any way it see fit. This can for instance be used to add | |
967 | certain headers to specific requests. | |
968 | ||
969 | =end original | |
970 | ||
971 | ハンドラは、リクエストを送信する前に呼び出され、 | |
972 | 適合するならどのような形でもリクエストを変更できます。 | |
973 | これは例えば特定のリクエストにある種のヘッダを追加するのに使えます。 | |
974 | ||
975 | =begin original | |
976 | ||
977 | The method can assign a new request object to $_[0] to replace the | |
978 | request that is sent fully. | |
979 | ||
980 | =end original | |
981 | ||
982 | メソッドは、送られるリクエストを完全に置き換えるために、 | |
983 | $_[0] に新しいリクエストオブジェクトを代入できます。 | |
984 | ||
985 | =begin original | |
986 | ||
987 | The return value from the callback is ignored. If an exception is | |
988 | raised it will abort the request and make the request method return a | |
989 | "400 Bad request" response. | |
990 | ||
991 | =end original | |
992 | ||
993 | コールバックからの返り値は無視されます。 | |
994 | 例外が発生すると、リクエストを中止して、 | |
995 | リクエストメソッドは "400 Bad request" レスポンスを返します。 | |
996 | ||
997 | =item request_send => sub { my($request, $ua, $h) = @_; ... } | |
998 | ||
999 | =begin original | |
1000 | ||
1001 | This handler gets a chance of handling requests before they're sent to the | |
1002 | protocol handlers. It should return an HTTP::Response object if it | |
1003 | wishes to terminate the processing; otherwise it should return nothing. | |
1004 | ||
1005 | =end original | |
1006 | ||
1007 | このハンドラは、プロトコルハンドラに送られる前に | |
1008 | リクエストを扱う機会を与えます。 | |
1009 | 処理を終わらせることを望むなら HTTP::Response オブジェクトを返す | |
1010 | 必要があります; さもなければ何も返さない必要があります。 | |
1011 | ||
1012 | =begin original | |
1013 | ||
1014 | The C<response_header> and C<response_data> handlers will not be | |
1015 | invoked for this response, but the C<response_done> will be. | |
1016 | ||
1017 | =end original | |
1018 | ||
1019 | C<response_header> と C<response_data> のハンドラは | |
1020 | このレスポンスでは起動されませんが、 | |
1021 | C<response_done> は起動されます。 | |
1022 | ||
1023 | =item response_header => sub { my($response, $ua, $h) = @_; ... } | |
1024 | ||
1025 | =begin original | |
1026 | ||
1027 | This handler is called right after the response headers have been | |
1028 | received, but before any content data. The handler might set up | |
1029 | handlers for data and might croak to abort the request. | |
1030 | ||
1031 | =end original | |
1032 | ||
1033 | このハンドラは、レスポンスヘッダを受信した直後、本体データを | |
1034 | 受信する前に呼び出されます。 | |
1035 | ハンドラはデータのためにハンドラを設定したりリクエストを中止するために | |
1036 | croak したりできます。 | |
1037 | ||
1038 | =begin original | |
1039 | ||
1040 | The handler might set the $response->{default_add_content} value to | |
1041 | control if any received data should be added to the response object | |
1042 | directly. This will initially be false if the $ua->request() method | |
1043 | was called with a $content_file or $content_cb argument; otherwise true. | |
1044 | ||
1045 | =end original | |
1046 | ||
1047 | ハンドラは、受信データが直接レスポンスオブジェクトに追加されるかどうかを | |
1048 | 制御するために $response->{default_add_content} の値を設定できます。 | |
1049 | これは、 $content_file または $content_cb 引数付きで $ua->request() | |
1050 | メソッドが呼び出されたときは偽です; さもなければ真です。 | |
1051 | ||
1052 | =item response_data => sub { my($response, $ua, $h, $data) = @_; ... } | |
1053 | ||
1054 | =begin original | |
1055 | ||
1056 | This handler is called for each chunk of data received for the | |
1057 | response. The handler might croak to abort the request. | |
1058 | ||
1059 | =end original | |
1060 | ||
1061 | このハンドラは、レスポンスとしてデータの塊を受信する毎に呼び出されます。 | |
1062 | このハンドラはリクエストを中止するために croak できます。 | |
1063 | ||
1064 | =begin original | |
1065 | ||
1066 | This handler needs to return a TRUE value to be called again for | |
1067 | subsequent chunks for the same request. | |
1068 | ||
1069 | =end original | |
1070 | ||
1071 | このハンドラは、同じリクエストの引き続く塊のために再び呼び出されるために、 | |
1072 | 真の値を返す必要があります。 | |
1073 | ||
1074 | =item response_done => sub { my($response, $ua, $h) = @_; ... } | |
1075 | ||
1076 | =begin original | |
1077 | ||
1078 | The handler is called after the response has been fully received, but | |
1079 | before any redirect handling is attempted. The handler can be used to | |
1080 | extract information or modify the response. | |
1081 | ||
1082 | =end original | |
1083 | ||
1084 | このハンドルは、レスポンスが完全に受信された後、リダイレクト処理を | |
1085 | 試みる前に呼び出されます。 | |
1086 | ハンドラは、情報を取り出したりレスポンスを修正したりするのに使えます。 | |
1087 | ||
1088 | =item response_redirect => sub { my($response, $ua, $h) = @_; ... } | |
1089 | ||
1090 | =begin original | |
1091 | ||
1092 | The handler is called in $ua->request after C<response_done>. If the | |
1093 | handler returns an HTTP::Request object we'll start over with processing | |
1094 | this request instead. | |
1095 | ||
1096 | =end original | |
1097 | ||
1098 | このハンドルは $ua->request で、C<response_done> の後に呼び出されます。 | |
1099 | ハンドラが HTTP::Request オブジェクトを返すと、代わりにこのリクエストを | |
1100 | 処理してやり直します。 | |
1101 | ||
1102 | =back | |
1103 | ||
1104 | =item $ua->remove_handler( undef, %matchspec ) | |
1105 | ||
1106 | =item $ua->remove_handler( $phase, %matchspec ) | |
1107 | ||
1108 | =begin original | |
1109 | ||
1110 | Remove handlers that match the given %matchspec. If $phase is not | |
1111 | provided remove handlers from all phases. | |
1112 | ||
1113 | =end original | |
1114 | ||
1115 | %matchspec に一致するハンドラを削除します。 | |
1116 | $phase が指定されないと、全てのフェーズからハンドラを削除します。 | |
1117 | ||
1118 | =begin original | |
1119 | ||
1120 | Be careful as calling this function with %matchspec that is not not | |
1121 | specific enough can remove handlers not owned by you. It's probably | |
1122 | better to use the set_my_handler() method instead. | |
1123 | ||
1124 | =end original | |
1125 | ||
1126 | 自分が所有していないハンドラを削除しないのに十分な %matchspec で | |
1127 | この関数を呼び出すように注意してください。 | |
1128 | おそらく代わりに set_my_handler() メソッドを使った方が良いです。 | |
1129 | ||
1130 | =begin original | |
1131 | ||
1132 | The removed handlers are returned. | |
1133 | ||
1134 | =end original | |
1135 | ||
1136 | 削除されたハンドラが返されます。 | |
1137 | ||
1138 | =item $ua->set_my_handler( $phase, $cb, %matchspec ) | |
1139 | ||
1140 | =begin original | |
1141 | ||
1142 | Set handlers private to the executing subroutine. Works by defaulting | |
1143 | an C<owner> field to the %matchspec that holds the name of the called | |
1144 | subroutine. You might pass an explicit C<owner> to override this. | |
1145 | ||
1146 | =end original | |
1147 | ||
1148 | サブルーチンを実行するのにプライベートなハンドラを設定します。 | |
1149 | C<owner> フィールドに、呼び出したサブルーチン名を保持した %matchspec を | |
1150 | デフォルトで設定することで動作します。 | |
1151 | これを上書きするために明示的な C<owner> を渡すことができます。 | |
1152 | ||
1153 | =begin original | |
1154 | ||
1155 | If $cb is passed as C<undef>, remove the handler. | |
1156 | ||
1157 | =end original | |
1158 | ||
1159 | $cb が C<undef> として渡されると、ハンドラを削除します。 | |
1160 | ||
1161 | =item $ua->get_my_handler( $phase, %matchspec ) | |
1162 | ||
1163 | =item $ua->get_my_handler( $phase, %matchspec, $init ) | |
1164 | ||
1165 | =begin original | |
1166 | ||
1167 | Will retrieve the matching handler as hash ref. | |
1168 | ||
1169 | =end original | |
1170 | ||
1171 | 一致するハンドラをハッシュリファレンスとして受け取ります。 | |
1172 | ||
1173 | =begin original | |
1174 | ||
1175 | If C<$init> is passed passed as a TRUE value, create and add the | |
1176 | handler if it's not found. If $init is a subroutine reference, then | |
1177 | it's called with the created handler hash as argument. This sub might | |
1178 | populate the hash with extra fields; especially the callback. If | |
1179 | $init is a hash reference, merge the hashes. | |
1180 | ||
1181 | =end original | |
1182 | ||
1183 | C<$init> に真の値が渡されると、見つからない場合に | |
1184 | 新しくハンドラを作って追加します。 | |
1185 | $init がサブルーチンリファレンスの場合、 | |
1186 | 作成されたハンドラハッシュを引数としてこれが呼び出されます。 | |
1187 | このサブルーチンは、ハッシュに追加のフィールド、特にコールバックを | |
1188 | 追加できます。 | |
1189 | $init がハッシュリファレンスなら、ハッシュをマージします。 | |
1190 | ||
1191 | =item $ua->handlers( $phase, $request ) | |
1192 | ||
1193 | =item $ua->handlers( $phase, $response ) | |
1194 | ||
1195 | =begin original | |
1196 | ||
1197 | Returns the handlers that apply to the given request or response at | |
1198 | the given processing phase. | |
1199 | ||
1200 | =end original | |
1201 | ||
1202 | 指定された処理フェーズで指定されたリクエストまたはレスポンスに | |
1203 | 適用されるハンドラを返します。 | |
1204 | ||
1205 | =back | |
1206 | ||
1207 | 755 | =head1 REQUEST METHODS |
1208 | 756 | |
1209 | 757 | (リクエストメソッド) |
1210 | 758 | |
1211 | 759 | =begin original |
1212 | 760 | |
1213 | 761 | The methods described in this section are used to dispatch requests |
1214 | 762 | via the user agent. The following request methods are provided: |
1215 | 763 | |
1216 | 764 | =end original |
1217 | 765 | |
1218 | 766 | この章で記述されているメソッドはユーザエージェント経由でリクエストを |
1219 | 767 | 発行するために使われます。 |
1220 | 768 | 以下のリクエストメソッドが提供されています: |
1221 | 769 | |
1222 | 770 | =over |
1223 | 771 | |
1224 | 772 | =item $ua->get( $url ) |
1225 | 773 | |
1226 | 774 | =item $ua->get( $url , $field_name => $value, ... ) |
1227 | 775 | |
1228 | 776 | =begin original |
1229 | 777 | |
1230 | 778 | This method will dispatch a C<GET> request on the given $url. Further |
1231 | 779 | arguments can be given to initialize the headers of the request. These |
1232 | 780 | are given as separate name/value pairs. The return value is a |
1233 | 781 | response object. See L<HTTP::Response> for a description of the |
1234 | 782 | interface it provides. |
1235 | 783 | |
1236 | 784 | =end original |
1237 | 785 | |
1238 | 786 | このメソッドは、与えられた $url に C<GET> リクエストを発行します。 |
1239 | 787 | リクエストのヘッダを初期化するために追加の引数を与えることもできます。 |
1240 | 788 | これらは別々の名前/値の組で与えられます。 |
1241 | 789 | 返り値はレスポンスオブジェクトです。 |
1242 | 790 | これが提供するインターフェースの説明については L<HTTP::Response> を |
1243 | 791 | 参照してください。 |
1244 | 792 | |
1245 | 793 | =begin original |
1246 | 794 | |
1247 | There will still be a response object returned when LWP can't connect to the | |
1248 | server specified in the URL or when other failures in protocol handlers occur. | |
1249 | These internal responses use the standard HTTP status codes, so the responses | |
1250 | can't be differentiated by testing the response status code alone. Error | |
1251 | responses that LWP generates internally will have the "Client-Warning" header | |
1252 | set to the value "Internal response". If you need to differentiate these | |
1253 | internal responses from responses that a remote server actually generates, you | |
1254 | need to test this header value. | |
1255 | ||
1256 | =end original | |
1257 | ||
1258 | LWP が URL で指定されたサーバに接続できない場合や、プロトコルハンドラ内で | |
1259 | その他のエラーが発生した場合でも、レスポンスオブジェクトが返されます。 | |
1260 | これらの内部レスポンスは標準の HTTP ステータスコードを使うので、 | |
1261 | レスポンスステータスコードだけをテストしても、レスポンスを | |
1262 | 区別することはできません。 | |
1263 | LWP が内部で生成したエラーレスポンスは、"Client-Warning" ヘッダに | |
1264 | "Internal response" という値が設定されます。 | |
1265 | これらの内部レスポンスを実際にリモートサーバが生成したレスポンスと | |
1266 | 区別する必要がある場合は、このヘッダの値をテストする必要があります。 | |
1267 | ||
1268 | =begin original | |
1269 | ||
1270 | 795 | Fields names that start with ":" are special. These will not |
1271 | 796 | initialize headers of the request but will determine how the response |
1272 | 797 | content is treated. The following special field names are recognized: |
1273 | 798 | |
1274 | 799 | =end original |
1275 | 800 | |
1276 | 801 | ":" で始まるフィールド名は特殊です。 |
1277 | 802 | これらはリクエストのヘッダの初期化はせず、レスポンスオブジェクトが |
1278 | 803 | どのように扱われるかを決定します。 |
1279 | 804 | 以下の特殊フィールド名を認識します: |
1280 | 805 | |
1281 | 806 | :content_file => $filename |
1282 | 807 | :content_cb => \&callback |
1283 | 808 | :read_size_hint => $bytes |
1284 | 809 | |
1285 | 810 | =begin original |
1286 | 811 | |
1287 | 812 | If a $filename is provided with the C<:content_file> option, then the |
1288 | 813 | response content will be saved here instead of in the response |
1289 | 814 | object. If a callback is provided with the C<:content_cb> option then |
1290 | 815 | this function will be called for each chunk of the response content as |
1291 | 816 | it is received from the server. If neither of these options are |
1292 | 817 | given, then the response content will accumulate in the response |
1293 | 818 | object itself. This might not be suitable for very large response |
1294 | 819 | bodies. Only one of C<:content_file> or C<:content_cb> can be |
1295 | 820 | specified. The content of unsuccessful responses will always |
1296 | 821 | accumulate in the response object itself, regardless of the |
1297 | 822 | C<:content_file> or C<:content_cb> options passed in. |
1298 | 823 | |
1299 | 824 | =end original |
1300 | 825 | |
1301 | 826 | C<:content_file> オプションで $filename が指定されると、レスポンスの内容は |
1302 | 827 | レスポンスオブジェクトの代わりにこのファイルに保存されます。 |
1303 | 828 | C<:content_cb> オプションでコールバック関数が指定されると、 |
1304 | 829 | レスポンスの内容の塊ををサーバから受信する毎にこの関数が呼び出されます。 |
1305 | 830 | これらのオプションのどちらも指定されなかった場合、レスポンスの内容は |
1306 | 831 | レスポンスオブジェクト自身に蓄積されます。 |
1307 | 832 | これはレスポンスボディがとても大きい場合には向いていません。 |
1308 | 833 | C<:content_file> と C<:content_cb> のどちらか一つのみが指定できます。 |
1309 | 834 | 失敗したレスポンスの内容は、C<:content_file> や C<:content_cb> の |
1310 | 835 | オプションが指定されているかどうかに関わらず |
1311 | 836 | 常にレスポンスオブジェクト自身に蓄積されます。 |
1312 | 837 | |
1313 | 838 | =begin original |
1314 | 839 | |
1315 | 840 | The C<:read_size_hint> option is passed to the protocol module which |
1316 | 841 | will try to read data from the server in chunks of this size. A |
1317 | 842 | smaller value for the C<:read_size_hint> will result in a higher |
1318 | 843 | number of callback invocations. |
1319 | 844 | |
1320 | 845 | =end original |
1321 | 846 | |
1322 | 847 | C<:read_size_hint> オプションは、このサイズの塊でサーバからデータを |
1323 | 848 | 読み込もうとするようにプロトコルモジュールに渡されます。 |
1324 | 849 | C<:read_size_hint> の値を小さくすると、コールバックの起動回数は |
1325 | 850 | 多くなります。 |
1326 | 851 | |
1327 | 852 | =begin original |
1328 | 853 | |
1329 | 854 | The callback function is called with 3 arguments: a chunk of data, a |
1330 | 855 | reference to the response object, and a reference to the protocol |
1331 | 856 | object. The callback can abort the request by invoking die(). The |
1332 | 857 | exception message will show up as the "X-Died" header field in the |
1333 | 858 | response returned by the get() function. |
1334 | 859 | |
1335 | 860 | =end original |
1336 | 861 | |
1337 | 862 | コールバック関数は 3 引数で呼び出されます: データの塊、 |
1338 | 863 | レスポンスオブジェクトへのリファレンス、プロトコルオブジェクトへの |
1339 | 864 | リファレンス、です。 |
1340 | 865 | コールバックは die() を起動することでリクエストを中断できます。 |
1341 | 866 | 例外メッセージは、get() 関数で返されるレスポンスの中の |
1342 | 867 | "X-Died" ヘッダフィールドで得られます。 |
1343 | 868 | |
1344 | 869 | =item $ua->head( $url ) |
1345 | 870 | |
1346 | 871 | =item $ua->head( $url , $field_name => $value, ... ) |
1347 | 872 | |
1348 | 873 | =begin original |
1349 | 874 | |
1350 | 875 | This method will dispatch a C<HEAD> request on the given $url. |
1351 | 876 | Otherwise it works like the get() method described above. |
1352 | 877 | |
1353 | 878 | =end original |
1354 | 879 | |
1355 | 880 | このメソッドは、与えられた $url に C<HEAD> リクエストを発行します。 |
1356 | 881 | その他は上述の get() メソッドと同様に動作します。 |
1357 | 882 | |
1358 | 883 | =item $ua->post( $url, \%form ) |
1359 | 884 | |
1360 | 885 | =item $ua->post( $url, \@form ) |
1361 | 886 | |
1362 | 887 | =item $ua->post( $url, \%form, $field_name => $value, ... ) |
1363 | 888 | |
1364 | 889 | =item $ua->post( $url, $field_name => $value,... Content => \%form ) |
1365 | 890 | |
1366 | 891 | =item $ua->post( $url, $field_name => $value,... Content => \@form ) |
1367 | 892 | |
1368 | 893 | =item $ua->post( $url, $field_name => $value,... Content => $content ) |
1369 | 894 | |
1370 | 895 | =begin original |
1371 | 896 | |
1372 | 897 | This method will dispatch a C<POST> request on the given $url, with |
1373 | 898 | %form or @form providing the key/value pairs for the fill-in form |
1374 | 899 | content. Additional headers and content options are the same as for |
1375 | 900 | the get() method. |
1376 | 901 | |
1377 | 902 | =end original |
1378 | 903 | |
1379 | 904 | このメソッドは、与えられた $url に、フォームの内容として |
1380 | 905 | %form または @form で与えられるキー/値の組を使って |
1381 | 906 | C<POST> リクエストを発行します。 |
1382 | 907 | 追加のヘッダと内容のオプションは get() メソッドと同じです。 |
1383 | 908 | |
1384 | 909 | =begin original |
1385 | 910 | |
1386 | 911 | This method will use the POST() function from C<HTTP::Request::Common> |
1387 | 912 | to build the request. See L<HTTP::Request::Common> for a details on |
1388 | 913 | how to pass form content and other advanced features. |
1389 | 914 | |
1390 | 915 | =end original |
1391 | 916 | |
1392 | 917 | このメソッドは、リクエストを構築するために |
1393 | 918 | C<HTTP::Request::Common> の POST() 関数を使います。 |
1394 | 919 | フォームの内容の渡し方とその他の高度な機能に関する詳細については |
1395 | 920 | L<HTTP::Request::Common> を参照してください。 |
1396 | 921 | |
1397 | =item $ua->put( $url, \%form ) | |
1398 | ||
1399 | =item $ua->put( $url, \@form ) | |
1400 | ||
1401 | =item $ua->put( $url, \%form, $field_name => $value, ... ) | |
1402 | ||
1403 | =item $ua->put( $url, $field_name => $value,... Content => \%form ) | |
1404 | ||
1405 | =item $ua->put( $url, $field_name => $value,... Content => \@form ) | |
1406 | ||
1407 | =item $ua->put( $url, $field_name => $value,... Content => $content ) | |
1408 | ||
1409 | =begin original | |
1410 | ||
1411 | This method will dispatch a C<PUT> request on the given $url, with | |
1412 | %form or @form providing the key/value pairs for the fill-in form | |
1413 | content. Additional headers and content options are the same as for | |
1414 | the get() method. | |
1415 | ||
1416 | =end original | |
1417 | ||
1418 | このメソッドは、与えられた $url に C<PUT> リクエストを発行します; | |
1419 | %form または @form でフォームの内容のためのキー/値の組を提供します。 | |
1420 | 追加のヘッダと本体オプションは get() メソッドと同様です。 | |
1421 | ||
1422 | =begin original | |
1423 | ||
1424 | This method will use the PUT() function from C<HTTP::Request::Common> | |
1425 | to build the request. See L<HTTP::Request::Common> for a details on | |
1426 | how to pass form content and other advanced features. | |
1427 | ||
1428 | =end original | |
1429 | ||
1430 | このメソッドは、リクエストを構築するのに C<HTTP::Request::Common> の | |
1431 | PUT() 関数を使います。 | |
1432 | フォームの内容の渡し方とその他の高度な機能に関する詳細については | |
1433 | L<HTTP::Request::Common> を参照してください。 | |
1434 | ||
1435 | =item $ua->delete( $url ) | |
1436 | ||
1437 | =item $ua->delete( $url, $field_name => $value, ... ) | |
1438 | ||
1439 | =begin original | |
1440 | ||
1441 | This method will dispatch a C<DELETE> request on the given $url. Additional | |
1442 | headers and content options are the same as for the get() method. | |
1443 | ||
1444 | =end original | |
1445 | ||
1446 | このメソッドは、与えられた $url に C<DELETE> リクエストを発行します。 | |
1447 | 追加のヘッダと内容オプションは get() メソッドと同様です。 | |
1448 | ||
1449 | =begin original | |
1450 | ||
1451 | This method will use the DELETE() function from C<HTTP::Request::Common> | |
1452 | to build the request. See L<HTTP::Request::Common> for a details on | |
1453 | how to pass form content and other advanced features. | |
1454 | ||
1455 | =end original | |
1456 | ||
1457 | このメソッドは、リクエストを構築するのに C<HTTP::Request::Common> の | |
1458 | DELETE() 関数を使います。 | |
1459 | フォームの内容の渡し方とその他の高度な機能に関する詳細については | |
1460 | L<HTTP::Request::Common> を参照してください。 | |
1461 | ||
1462 | 922 | =item $ua->mirror( $url, $filename ) |
1463 | 923 | |
1464 | 924 | =begin original |
1465 | 925 | |
1466 | 926 | This method will get the document identified by $url and store it in |
1467 | 927 | file called $filename. If the file already exists, then the request |
1468 | 928 | will contain an "If-Modified-Since" header matching the modification |
1469 | 929 | time of the file. If the document on the server has not changed since |
1470 | 930 | this time, then nothing happens. If the document has been updated, it |
1471 | 931 | will be downloaded again. The modification time of the file will be |
1472 | 932 | forced to match that of the server. |
1473 | 933 | |
1474 | 934 | =end original |
1475 | 935 | |
1476 | 936 | このメソッドは $url で識別されるドキュメントを取得し、$filename で |
1477 | 937 | 指定されるファイルに保管します。 |
1478 | 938 | ファイルが既に存在する場合、リクエストにはそのファイルの修正時刻に一致する |
1479 | 939 | "If-Modified-Since" ヘッダが含まれます。 |
1480 | 940 | ドキュメントが更新されている場合は、再びダウンロードされます。 |
1481 | 941 | ファイルの修正時刻はサーバ上での修正時刻と同じになります。 |
1482 | 942 | |
1483 | 943 | =begin original |
1484 | 944 | |
1485 | 945 | The return value is the the response object. |
1486 | 946 | |
1487 | 947 | =end original |
1488 | 948 | |
1489 | 949 | 返り値はレスポンスオブジェクトです。 |
1490 | 950 | |
1491 | 951 | =item $ua->request( $request ) |
1492 | 952 | |
1493 | 953 | =item $ua->request( $request, $content_file ) |
1494 | 954 | |
1495 | 955 | =item $ua->request( $request, $content_cb ) |
1496 | 956 | |
1497 | 957 | =item $ua->request( $request, $content_cb, $read_size_hint ) |
1498 | 958 | |
1499 | 959 | =begin original |
1500 | 960 | |
1501 | 961 | This method will dispatch the given $request object. Normally this |
1502 | 962 | will be an instance of the C<HTTP::Request> class, but any object with |
1503 | 963 | a similar interface will do. The return value is a response object. |
1504 | 964 | See L<HTTP::Request> and L<HTTP::Response> for a description of the |
1505 | 965 | interface provided by these classes. |
1506 | 966 | |
1507 | 967 | =end original |
1508 | 968 | |
1509 | 969 | このメソッドは与えられた $request オブジェクトを発行します。 |
1510 | 970 | 通常これは C<HTTP::Request> クラスの実体ですが、似たような |
1511 | 971 | インターフェースを持つどのようなオブジェクトでも動作します。 |
1512 | 972 | 返り値はレスポンスオブジェクトです。 |
1513 | 973 | これらのクラスによって提供されるインターフェースの記述については |
1514 | 974 | L<HTTP::Request> と L<HTTP::Response> を参照してください。 |
1515 | 975 | |
1516 | 976 | =begin original |
1517 | 977 | |
1518 | 978 | The request() method will process redirects and authentication |
1519 | 979 | responses transparently. This means that it may actually send several |
1520 | 980 | simple requests via the simple_request() method described below. |
1521 | 981 | |
1522 | 982 | =end original |
1523 | 983 | |
1524 | 984 | request() メソッドはリダイレクトと認証を透過的に処理します。 |
1525 | 985 | これは、実際には後述する simple_request() メソッドを使って単純な |
1526 | 986 | リクエストを複数回送信するかもしれないことを意味します。 |
1527 | 987 | |
1528 | 988 | =begin original |
1529 | 989 | |
1530 | 990 | The request methods described above; get(), head(), post() and |
1531 | 991 | mirror(), will all dispatch the request they build via this method. |
1532 | 992 | They are convenience methods that simply hides the creation of the |
1533 | 993 | request object for you. |
1534 | 994 | |
1535 | 995 | =end original |
1536 | 996 | |
1537 | 997 | 上述のリクエストメソッド: get(), head(), post(), mirror() は全て |
1538 | 998 | 構築したリクエストをこのメソッド経由で発行します。 |
1539 | 999 | これらは単にリクエストメソッドの作成をあなたから隠すための |
1540 | 1000 | 便利メソッドです。 |
1541 | 1001 | |
1542 | 1002 | =begin original |
1543 | 1003 | |
1544 | 1004 | The $content_file, $content_cb and $read_size_hint all correspond to |
1545 | 1005 | options described with the get() method above. |
1546 | 1006 | |
1547 | 1007 | =end original |
1548 | 1008 | |
1549 | 1009 | $content_file, $content_cb, $read_size_hint は全て上述の |
1550 | 1010 | get() メソッドで記述したオプションに対応します。 |
1551 | 1011 | |
1552 | 1012 | =begin original |
1553 | 1013 | |
1554 | 1014 | You are allowed to use a CODE reference as C<content> in the request |
1555 | 1015 | object passed in. The C<content> function should return the content |
1556 | 1016 | when called. The content can be returned in chunks. The content |
1557 | 1017 | function will be invoked repeatedly until it return an empty string to |
1558 | 1018 | signal that there is no more content. |
1559 | 1019 | |
1560 | 1020 | =end original |
1561 | 1021 | |
1562 | 1022 | リクエストオブジェクトに渡す C<content> としてコードリファレンスも使えます。 |
1563 | 1023 | C<content> 関数は、呼び出されたときに内容を返すようにします。 |
1564 | 1024 | 内容は塊で返すこともできます。 |
1565 | 1025 | content 関数は、もう内容がないことを示すために空文字列が返されるまで |
1566 | 1026 | 繰り返し起動されます。 |
1567 | 1027 | |
1568 | 1028 | =item $ua->simple_request( $request ) |
1569 | 1029 | |
1570 | 1030 | =item $ua->simple_request( $request, $content_file ) |
1571 | 1031 | |
1572 | 1032 | =item $ua->simple_request( $request, $content_cb ) |
1573 | 1033 | |
1574 | 1034 | =item $ua->simple_request( $request, $content_cb, $read_size_hint ) |
1575 | 1035 | |
1576 | 1036 | =begin original |
1577 | 1037 | |
1578 | 1038 | This method dispatches a single request and returns the response |
1579 | 1039 | received. Arguments are the same as for request() described above. |
1580 | 1040 | |
1581 | 1041 | =end original |
1582 | 1042 | |
1583 | 1043 | このメソッドは 1 回のリクエストを発行し、受信したレスポンスを返します。 |
1584 | 1044 | 引数は上述の request() のものと同じです。 |
1585 | 1045 | |
1586 | 1046 | =begin original |
1587 | 1047 | |
1588 | 1048 | The difference from request() is that simple_request() will not try to |
1589 | 1049 | handle redirects or authentication responses. The request() method |
1590 | 1050 | will in fact invoke this method for each simple request it sends. |
1591 | 1051 | |
1592 | 1052 | =end original |
1593 | 1053 | |
1594 | 1054 | request() との違いは、simple_request() はリダイレクトや認証を |
1595 | 1055 | 扱おうとしないことです。 |
1596 | 1056 | 実際のところ、request() メソッドは、単純なリクエストを送る度に |
1597 | 1057 | このメソッドを起動します。 |
1598 | 1058 | |
1599 | =item $ua->is_online | |
1600 | ||
1601 | =begin original | |
1602 | ||
1603 | Tries to determine if you have access to the Internet. Returns | |
1604 | TRUE if the built-in heuristics determine that the user agent is | |
1605 | able to access the Internet (over HTTP). See also L<LWP::Online>. | |
1606 | ||
1607 | =end original | |
1608 | ||
1609 | インターネットにアクセスできるかを判断しようとします。 | |
1610 | ユーザーエージェントがインターネットに (HTTP で) アクセスできると | |
1611 | 組み込みのヒューリスティックが判断した場合、真を返します。 | |
1612 | L<LWP::Online> も参照してください。 | |
1613 | ||
1614 | 1059 | =item $ua->is_protocol_supported( $scheme ) |
1615 | 1060 | |
1616 | 1061 | =begin original |
1617 | 1062 | |
1618 | 1063 | You can use this method to test whether this user agent object supports the |
1619 | 1064 | specified C<scheme>. (The C<scheme> might be a string (like 'http' or |
1620 | 1065 | 'ftp') or it might be an URI object reference.) |
1621 | 1066 | |
1622 | 1067 | =end original |
1623 | 1068 | |
1624 | 1069 | このユーザエージェントが指定された C<scheme> を |
1625 | 1070 | サポートしているかどうかを調べるために使うことができます。 |
1626 | 1071 | (C<scheme> には ('http' や 'ftp' のような)文字列や、 |
1627 | 1072 | URI オブジェクトリファレンスを指定できます。) |
1628 | 1073 | |
1629 | 1074 | =begin original |
1630 | 1075 | |
1631 | 1076 | Whether a scheme is supported, is determined by the user agent's |
1632 | 1077 | C<protocols_allowed> or C<protocols_forbidden> lists (if any), and by |
1633 | 1078 | the capabilities of LWP. I.e., this will return TRUE only if LWP |
1634 | 1079 | supports this protocol I<and> it's permitted for this particular |
1635 | 1080 | object. |
1636 | 1081 | |
1637 | 1082 | =end original |
1638 | 1083 | |
1639 | 1084 | あるスキーマが対応しているかどうかは、(もしあれば)ユーザエージェントの |
1640 | 1085 | C<protocols_allowed> と C<protocols_forbidden> のリスト、および |
1641 | 1086 | LWP の能力によって決定されます。 |
1642 | 1087 | つまり、このメソッドは LWP がこのプロトコルに対応していて、I<かつ> それが |
1643 | 1088 | このオブジェクトに対して許可されている場合にのみ TRUE を返します。 |
1644 | 1089 | |
1645 | 1090 | =back |
1646 | 1091 | |
1647 | 1092 | =head2 Callback methods |
1648 | 1093 | |
1649 | 1094 | (コールバックメソッド) |
1650 | 1095 | |
1651 | 1096 | =begin original |
1652 | 1097 | |
1653 | 1098 | The following methods will be invoked as requests are processed. These |
1654 | 1099 | methods are documented here because subclasses of C<LWP::UserAgent> |
1655 | 1100 | might want to override their behaviour. |
1656 | 1101 | |
1657 | 1102 | =end original |
1658 | 1103 | |
1659 | 1104 | 以下のメソッドはリクエストの処理中に起動されます。 |
1660 | 1105 | これらのメソッドは、C<LWP::UserAgent> のサブクラスが振る舞いを |
1661 | 1106 | オーバーライドしたいかもしれないので、ここで記述されています。 |
1662 | 1107 | |
1663 | 1108 | =over |
1664 | 1109 | |
1665 | 1110 | =item $ua->prepare_request( $request ) |
1666 | 1111 | |
1667 | 1112 | =begin original |
1668 | 1113 | |
1669 | 1114 | This method is invoked by simple_request(). Its task is to modify the |
1670 | 1115 | given $request object by setting up various headers based on the |
1671 | 1116 | attributes of the user agent. The return value should normally be the |
1672 | 1117 | $request object passed in. If a different request object is returned |
1673 | 1118 | it will be the one actually processed. |
1674 | 1119 | |
1675 | 1120 | =end original |
1676 | 1121 | |
1677 | 1122 | このメソッドは simple_request() によって起動されます。 |
1678 | 1123 | その使命は、与えられた $request オブジェクトを、ユーザエージェントの |
1679 | 1124 | 属性によって様々なヘッダを設定することで変更することです。 |
1680 | 1125 | 返り値は通常は渡された $request オブジェクトです。 |
1681 | 1126 | 異なる request オブジェクトが返された場合、それは実際に処理されたものです。 |
1682 | 1127 | |
1683 | 1128 | =begin original |
1684 | 1129 | |
1685 | 1130 | The headers affected by the base implementation are; "User-Agent", |
1686 | 1131 | "From", "Range" and "Cookie". |
1687 | 1132 | |
1688 | 1133 | =end original |
1689 | 1134 | |
1690 | 1135 | 基本実装によって影響を受けるヘッダは、 |
1691 | 1136 | "User-Agent", "From", "Range", "Cookie" です。 |
1692 | 1137 | |
1693 | 1138 | =item $ua->redirect_ok( $prospective_request, $response ) |
1694 | 1139 | |
1695 | 1140 | =begin original |
1696 | 1141 | |
1697 | 1142 | This method is called by request() before it tries to follow a |
1698 | 1143 | redirection to the request in $response. This should return a TRUE |
1699 | 1144 | value if this redirection is permissible. The $prospective_request |
1700 | 1145 | will be the request to be sent if this method returns TRUE. |
1701 | 1146 | |
1702 | 1147 | =end original |
1703 | 1148 | |
1704 | 1149 | このメソッドは、$response のリクエストのリダイレクトに |
1705 | 1150 | 従おうとする前に、request() によって呼ばれます。 |
1706 | 1151 | このリダイレクトを許可する場合には真の値を返します。 |
1707 | 1152 | $prospective_request は、このメソッドが真を返した場合に |
1708 | 1153 | 送信されるリクエストです。 |
1709 | 1154 | |
1710 | 1155 | =begin original |
1711 | 1156 | |
1712 | 1157 | The base implementation will return FALSE unless the method |
1713 | 1158 | is in the object's C<requests_redirectable> list, |
1714 | 1159 | FALSE if the proposed redirection is to a "file://..." |
1715 | 1160 | URL, and TRUE otherwise. |
1716 | 1161 | |
1717 | 1162 | =end original |
1718 | 1163 | |
1719 | 1164 | 基本実装では、メソッドがそのオブジェクトの C<requests_redirectable> リストに |
1720 | 1165 | ない場合と、予定されているリダイレクトが "file://..." URL の場合に |
1721 | 1166 | 偽を返し、それ以外では真を返します。 |
1722 | 1167 | |
1723 | 1168 | =item $ua->get_basic_credentials( $realm, $uri, $isproxy ) |
1724 | 1169 | |
1725 | 1170 | =begin original |
1726 | 1171 | |
1727 | 1172 | This is called by request() to retrieve credentials for documents |
1728 | 1173 | protected by Basic or Digest Authentication. The arguments passed in |
1729 | 1174 | is the $realm provided by the server, the $uri requested and a boolean |
1730 | 1175 | flag to indicate if this is authentication against a proxy server. |
1731 | 1176 | |
1732 | 1177 | =end original |
1733 | 1178 | |
1734 | 1179 | 基本認証またはダイジェスト認証により保護されている文書のための |
1735 | 1180 | 証明物 (credentials) の取得のために request() によって呼ばれます。 |
1736 | 1181 | 渡される引数は、$realm がサーバから提供されるレルム、 |
1737 | 1182 | $uri がリクエストされる URI、$isproxy がこれがプロキシサーバーに |
1738 | 1183 | 対する認証かどうかを示す真偽値フラグです。 |
1739 | 1184 | |
1740 | 1185 | =begin original |
1741 | 1186 | |
1742 | 1187 | The method should return a username and password. It should return an |
1743 | 1188 | empty list to abort the authentication resolution attempt. Subclasses |
1744 | 1189 | can override this method to prompt the user for the information. An |
1745 | 1190 | example of this can be found in C<lwp-request> program distributed |
1746 | 1191 | with this library. |
1747 | 1192 | |
1748 | 1193 | =end original |
1749 | 1194 | |
1750 | 1195 | このメソッドはユーザ名とパスワードを返します。 |
1751 | 1196 | 認証解決の試みを中断させるためには空リストを返します。 |
1752 | 1197 | サブクラスはユーザに情報を尋ねるためにこのモジュールを上書きできます。 |
1753 | 1198 | この例はこのライブラリと一緒に配布される |
1754 | 1199 | C<lwp-request> プログラムにあります。 |
1755 | 1200 | |
1756 | 1201 | =begin original |
1757 | 1202 | |
1758 | 1203 | The base implementation simply checks a set of pre-stored member |
1759 | 1204 | variables, set up with the credentials() method. |
1760 | 1205 | |
1761 | 1206 | =end original |
1762 | 1207 | |
1763 | 1208 | 基本実装は単にあらかじめ保管されているメンバ変数をチェックし、 |
1764 | 1209 | credentials() メソッドを設定します。 |
1765 | 1210 | |
1766 | 1211 | =item $ua->progress( $status, $request_or_response ) |
1767 | 1212 | |
1768 | 1213 | =begin original |
1769 | 1214 | |
1770 | 1215 | This is called frequently as the response is received regardless of |
1771 | 1216 | how the content is processed. The method is called with $status |
1772 | 1217 | "begin" at the start of processing the request and with $state "end" |
1773 | 1218 | before the request method returns. In between these $status will be |
1774 | 1219 | the fraction of the response currently received or the string "tick" |
1775 | 1220 | if the fraction can't be calculated. |
1776 | 1221 | |
1777 | 1222 | =end original |
1778 | 1223 | |
1779 | 1224 | これは、内容がどのように処理されるかにかかわらず、レスポンスを |
1780 | 1225 | 受信する度に呼び出されます。 |
1781 | 1226 | このメソッドは、リクエストの処理開始時には |
1782 | 1227 | $status に "begin" を設定して呼び出され、 |
1783 | 1228 | リクエストメソッドが返る前には $status に "end" を設定して呼び出されます。 |
1784 | 1229 | その間では、$status は現在受信したレスポンスの割合か、 |
1785 | 1230 | 割合が計算できない場合は文字列 "tick" です。 |
1786 | 1231 | |
1787 | 1232 | =begin original |
1788 | 1233 | |
1789 | 1234 | When $status is "begin" the second argument is the request object, |
1790 | 1235 | otherwise it is the response object. |
1791 | 1236 | |
1792 | 1237 | =end original |
1793 | 1238 | |
1794 | 1239 | 2 番目の引数は、$status が "begin" の場合はリクエストオブジェクトで、 |
1795 | 1240 | そうでない場合はレスポンスオブジェクトです。 |
1796 | 1241 | |
1797 | 1242 | =back |
1798 | 1243 | |
1799 | 1244 | =head1 SEE ALSO |
1800 | 1245 | |
1801 | 1246 | =begin original |
1802 | 1247 | |
1803 | 1248 | See L<LWP> for a complete overview of libwww-perl5. See L<lwpcook> |
1804 | 1249 | and the scripts F<lwp-request> and F<lwp-download> for examples of |
1805 | 1250 | usage. |
1806 | 1251 | |
1807 | 1252 | =end original |
1808 | 1253 | |
1809 | 1254 | libwww-perl5 の完全な概要は L<LWP> を参照してください。 |
1810 | 1255 | 使い方の例については、L<lwpcook> および |
1811 | 1256 | F<lwp-request> と F<lwp-mirror> のスクリプトを参照してください。 |
1812 | 1257 | |
1813 | 1258 | =begin original |
1814 | 1259 | |
1815 | 1260 | See L<HTTP::Request> and L<HTTP::Response> for a description of the |
1816 | 1261 | message objects dispatched and received. See L<HTTP::Request::Common> |
1817 | 1262 | and L<HTML::Form> for other ways to build request objects. |
1818 | 1263 | |
1819 | 1264 | =end original |
1820 | 1265 | |
1821 | 1266 | 発行したり受信したりするメッセージオブジェクトの記述については |
1822 | 1267 | L<HTTP::Request> と L<HTTP::Response> を参照してください。 |
1823 | 1268 | リクエストオブジェクトを構築するその他の方法については |
1824 | 1269 | L<HTTP::Request::Common> と L<HTML::Form> を参照してください。 |
1825 | 1270 | |
1826 | 1271 | =begin original |
1827 | 1272 | |
1828 | 1273 | See L<WWW::Mechanize> and L<WWW::Search> for examples of more |
1829 | 1274 | specialized user agents based on C<LWP::UserAgent>. |
1830 | 1275 | |
1831 | 1276 | =end original |
1832 | 1277 | |
1833 | 1278 | C<LWP::UserAgent> を基とした、より特殊化したユーザエージェントの例については |
1834 | 1279 | L<WWW::Mechanize> と L<WWW::Search> を参照してください。 |
1835 | 1280 | |
1836 | 1281 | =head1 COPYRIGHT |
1837 | 1282 | |
1838 | Copyright 1995-200 | |
1283 | Copyright 1995-2008 Gisle Aas. | |
1839 | 1284 | |
1840 | 1285 | This library is free software; you can redistribute it and/or |
1841 | 1286 | modify it under the same terms as Perl itself. |
1842 | 1287 | |
1843 | ||
1844 | 1288 | =begin meta |
1845 | 1289 | |
1846 | Translate: Hippo2000 <GCD00051@nifty.ne.jp> (5.48) | |
1290 | Translated: Hippo2000 <GCD00051@nifty.ne.jp> (5.48) | |
1847 | Update: SHIRAKATA | |
1291 | Updated: Kentaro SHIRAKATA <argrath@ub32.org> (5.813) | |
1848 | Status: completed | |
1849 | 1292 | |
1850 | 1293 | =end meta |