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