libwww-perl-5.813 > 5.836 との差分

LWP::UserAgent 5.836 と 5.813 の差分

11
22=encoding euc-jp
33
44=head1 NAME
55
66=begin original
77
88LWP::UserAgent - Web user agent class
99
1010=end original
1111
1212LWP::UserAgent - Web ユーザエージェントクラス
1313
1414=head1 SYNOPSIS
1515
1616 require LWP::UserAgent;
1717
1818 my $ua = LWP::UserAgent->new;
1919 $ua->timeout(10);
2020 $ua->env_proxy;
2121
2222 my $response = $ua->get('http://search.cpan.org/');
2323
2424 if ($response->is_success) {
25 print $response->decoded_content; # or whatever
25 print $response->content; # or whatever
2626 }
2727 else {
2828 die $response->status_line;
2929 }
3030
3131=head1 DESCRIPTION
3232
3333=begin original
3434
3535The C<LWP::UserAgent> is a class implementing a web user agent.
3636C<LWP::UserAgent> objects can be used to dispatch web requests.
3737
3838=end original
3939
4040C<LWP::UserAgent> は web ユーザエージェントを実装するクラスです。
4141C<LWP::UserAgent> オブジェクトは web リクエストを発行(dispatch)するために
4242使えます。
4343
4444=begin original
4545
4646In normal use the application creates an C<LWP::UserAgent> object, and
4747then configures it with values for timeouts, proxies, name, etc. It
4848then creates an instance of C<HTTP::Request> for the request that
4949needs to be performed. This request is then passed to one of the
5050request method the UserAgent, which dispatches it using the relevant
5151protocol, and returns a C<HTTP::Response> object. There are
5252convenience methods for sending the most common request types: get(),
5353head() and post(). When using these methods then the creation of the
5454request object is hidden as shown in the synopsis above.
5555
5656=end original
5757
5858通常の使用では、アプリケーションは C<LWP::UserAgent> クラスを作成し、
5959タイムアウト、プロキシ、名前などのための値でそれを設定します。
6060それから実行される必要があるリクエストのために C<HTTP::Request> の
6161インスタンスを作成します。
6262そしてこのリクエストは UserAgent のリクエストメソッドの一つに渡されます;
6363これは対応するプロトコルを使ってそれを発行し、
6464C<HTTP::Response> オブジェクトを返します。
6565もっとも一般的なリクエスト型のための便利メソッド get(), head(), post()
6666があります。
6767これらのメソッドを使うときは、上述の用例の通り、
6868リクエストオブジェクトの作成は隠蔽されます。
6969
7070=begin original
7171
7272The basic approach of the library is to use HTTP style communication
7373for all protocol schemes. This means that you will construct
7474C<HTTP::Request> objects and receive C<HTTP::Response> objects even
7575for non-HTTP resources like I<gopher> and I<ftp>. In order to achieve
7676even more similarity to HTTP style communications, gopher menus and
7777file directories are converted to HTML documents.
7878
7979=end original
8080
8181このライブラリの基本的なアプローチは、HTTP 式通信をすべての
8282プロトコルスキームに使うことです。
8383つまり I<gopher> や I<ftp> のような非 HTTP リソースでも
8484C<HTTP::Request> オブジェクトを構築して
8585C<HTTP::Response> オブジェクトを受け取るということです。
8686より HTTP 式通信に似せるため、gopher メニューとファイルディレクトリは
8787HTML ドキュメントに変換されます。
8888
8989=head1 CONSTRUCTOR METHODS
9090
9191(コンストラクタメソッド)
9292
9393=begin original
9494
9595The following constructor methods are available:
9696
9797=end original
9898
9999以下のコンストラクタメソッドが利用可能です:
100100
101101=over 4
102102
103103=item $ua = LWP::UserAgent->new( %options )
104104
105105=begin original
106106
107107This method constructs a new C<LWP::UserAgent> object and returns it.
108108Key/value pair arguments may be provided to set up the initial state.
109109The following options correspond to attribute methods described below:
110110
111111=end original
112112
113113このメソッドは新しい C<LWP::UserAgent> オブジェクトを構成して、それを
114114返します。
115115初期状態を設定するためにキー-値のペアの引数を指定できます。
116116以下のオプションは後述する属性メソッドに対応します:
117117
118118 KEY DEFAULT
119119 ----------- --------------------
120 agent "libwww-perl/#.#<#del>#"
120 agent "libwww-perl/#.##"
121121 from undef
122122 conn_cache undef
123123 cookie_jar undef
124124 default_headers HTTP::Headers->new
125 local_address undef
126125 max_size undef
127126 max_redirect 7
128127 parse_head 1
129128 protocols_allowed undef
130129 protocols_forbidden undef
131130 requests_redirectable ['GET', 'HEAD']
132131 timeout 180
133132
134133=begin original
135134
136135The following additional options are also accepted: If the
137136C<env_proxy> option is passed in with a TRUE value, then proxy
138137settings are read from environment variables (see env_proxy() method
139138below). If the C<keep_alive> option is passed in, then a
140139C<LWP::ConnCache> is set up (see conn_cache() method below). The
141140C<keep_alive> value is passed on as the C<total_capacity> for the
142141connection cache.
143142
144143=end original
145144
146145以下の追加のオプションも指定できます:
147146C<env_proxy> オプションが真の値とともに渡されると、プロキシセッティングは
148147環境変数から読み込まれます(後述する env_proxy() メソッドを参照してください)。
149148C<keep_alive> オプションが渡されると、
150149C<LWP::ConnCache> が設定されます(後述する conn_cache() メソッドを
151150参照してください)。
152151C<keep_alive> の値は接続キャッシュのための C<total_capacity> として
153152渡されます。
154153
155154=item $ua->clone
156155
157156=begin original
158157
159158Returns a copy of the LWP::UserAgent object.
160159
161160=end original
162161
163162LWP::UserAgent オブジェクトのコピーを返します。
164163
165164=back
166165
167166=head1 ATTRIBUTES
168167
169168(属性)
170169
171170=begin original
172171
173172The settings of the configuration attributes modify the behaviour of the
174173C<LWP::UserAgent> when it dispatches requests. Most of these can also
175174be initialized by options passed to the constructor method.
176175
177176=end original
178177
179178設定属性は、C<LWP::UserAgent> がリクエストを発行するときの振る舞いを
180179変更します。
181180これらのほとんどはコンストラクタメソッドに渡されたオプションによっても
182181初期化できます。
183182
184183=begin original
185184
186The following attribute methods are provided. The attribute value is
185The following attributes methods are provided. The attribute value is
187186left unchanged if no argument is given. The return value from each
188187method is the old attribute value.
189188
190189=end original
191190
192191以下の属性メソッドが提供されています。
193192引数がない場合は属性値は変更されません。
194193それぞれのメソッドの返り値は古い属性値です。
195194
196195=over
197196
198197=item $ua->agent
199198
200199=item $ua->agent( $product_id )
201200
202201=begin original
203202
204203Get/set the product token that is used to identify the user agent on
205204the network. The agent value is sent as the "User-Agent" header in
206205the requests. The default is the string returned by the _agent()
207206method (see below).
208207
209208=end original
210209
211210ネットワーク上でユーザエージェントを識別するために使われる
212211製品トークン(product token)を取得または設定します。
213212エージェントの値はリクエストの "User-Agent" ヘッダとして送信されます。
214213デフォルトは _agent() メソッド(後述)で返される文字列です。
215214
216215=begin original
217216
218217If the $product_id ends with space then the _agent() string is
219218appended to it.
220219
221220=end original
222221
223222$product_id が空白で終わっている場合は、その値に _agent() の文字列が
224223追加されます。
225224
226225=begin original
227226
228227The user agent string should be one or more simple product identifiers
229228with an optional version number separated by the "/" character.
230229Examples are:
231230
232231=end original
233232
234233ユーザエージェント文字列は、オプションで "/" 文字で
235234区切られたバージョン番号がついた、一つもしくはそれ以上の単純な
236235製品トークンです。
237236例を以下に示します:
238237
239238 $ua->agent('Checkbot/0.4 ' . $ua->_agent);
240239 $ua->agent('Checkbot/0.4 '); # same as above
241240 $ua->agent('Mozilla/5.0');
242241 $ua->agent(""); # don't identify
243242
244243=item $ua->_agent
245244
246245=begin original
247246
248247Returns the default agent identifier. This is a string of the form
249"libwww-perl/#.#<#del>#", where "#.###" is substituted with the version number
248"libwww-perl/#.##", where "#.##" is substituted with the version number
250249of this library.
251250
252251=end original
253252
254253デフォルトのエージェント識別子を返します。
255これは "libwww-perl/#.#<#del>#" 形式の文字列で、"#.###" はこのライブラリの
254これは "libwww-perl/#.##" 形式の文字列で、"#.##" はこのライブラリの
256255バージョン番号で置き換えられます。
257256
258257=item $ua->from
259258
260259=item $ua->from( $email_address )
261260
262261=begin original
263262
264263Get/set the e-mail address for the human user who controls
265264the requesting user agent. The address should be machine-usable, as
266265defined in RFC 822. The C<from> value is send as the "From" header in
267266the requests. Example:
268267
269268=end original
270269
271270リクエストしているユーザエージェントを制御している人間であるユーザの
272271e-mail アドレスを取得または設定します。
273272アドレスは RFC で定義されているように、機械で利用できなければなりません。
274273C<from> の値はリクエストでの "From" ヘッダとして送信されます。
275274例:
276275
277276 $ua->from('gaas@cpan.org');
278277
279278=begin original
280279
281280The default is to not send a "From" header. See the default_headers()
282281method for the more general interface that allow any header to be defaulted.
283282
284283=end original
285284
286285デフォルトでは、"From" ヘッダを送信しません。
287286任意のヘッダをデフォルトで指定できる、より一般的なインターフェースについては
288287default_headers() メソッドを参照してください。
289288
290289=item $ua->cookie_jar
291290
292291=item $ua->cookie_jar( $cookie_jar_obj )
293292
294293=begin original
295294
296295Get/set the cookie jar object to use. The only requirement is that
297296the cookie jar object must implement the extract_cookies($request) and
298297add_cookie_header($response) methods. These methods will then be
299298invoked by the user agent as requests are sent and responses are
300299received. Normally this will be a C<HTTP::Cookies> object or some
301300subclass.
302301
303302=end original
304303
305304使用するクッキー瓶(cookie jar)オブジェクトを取得または設定します。
306305唯一の必要条件は、クッキー瓶オブジェクトは
307306extract_cookies($request) メソッドと add_cookie_header($response) メソッドを
308307実装している必要があると言うことです。
309308これらのメソッドは、リクエストが送信されるときとレスポンスが受信されたときに
310309ユーザエージェントによって起動されます。
311310通常これは C<HTTP::Cookies> オブジェクトかそのサブクラスです。
312311
313312=begin original
314313
315314The default is to have no cookie_jar, i.e. never automatically add
316315"Cookie" headers to the requests.
317316
318317=end original
319318
320319デフォルトではクッキー瓶を使いません;
321320つまり自動的には "Cookie" ヘッダをリクエストに追加しません。
322321
323322=begin original
324323
325324Shortcut: If a reference to a plain hash is passed in as the
326325$cookie_jar_object, then it is replaced with an instance of
327326C<HTTP::Cookies> that is initialized based on the hash. This form also
328327automatically loads the C<HTTP::Cookies> module. It means that:
329328
330329=end original
331330
332331短縮形: もし単純なハッシュへのリファレンスが
333332$cookie_jar_object として渡されると、このハッシュを基にして初期化された
334333C<HTTP::Cookies> のインスタンスで置き換えられます。
335334この形式はまた、自動的に C<HTTP::Cookies> モジュールを読み込みます。
336335つまり、以下のようにすると:
337336
338337 $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
339338
340339=begin original
341340
342341is really just a shortcut for:
343342
344343=end original
345344
346345これは実際には以下の省略形です:
347346
348347 require HTTP::Cookies;
349348 $ua->cookie_jar(HTTP::Cookies->new(file => "$ENV{HOME}/.cookies.txt"));
350349
351350=item $ua->default_headers
352351
353352=item $ua->default_headers( $headers_obj )
354353
355354=begin original
356355
357356Get/set the headers object that will provide default header values for
358357any requests sent. By default this will be an empty C<HTTP::Headers>
359object.
358object. Example:
360359
361360=end original
362361
363362任意のレスポンスが送信されるときのデフォルトのヘッダ値を提供する
364363ヘッダオブジェクトを取得または設定します。
365364デフォルトではこれは空の C<HTTP::Headers> オブジェクトです。
365例:
366366
367 $ua->default_headers->push_header('Accept-Language' => "no, en");
368
367369=item $ua->default_header( $field )
368370
369371=item $ua->default_header( $field => $value )
370372
371373=begin original
372374
373375This is just a short-cut for $ua->default_headers->header( $field =>
374376$value ). Example:
375377
376378=end original
377379
378380これは単に $ua->default_headers->header( $field => $value ) の
379381短縮形です。
380382例:
381383
382 $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
383384 $ua->default_header('Accept-Language' => "no, en");
384385
385386=item $ua->conn_cache
386387
387388=item $ua->conn_cache( $cache_obj )
388389
389390=begin original
390391
391392Get/set the C<LWP::ConnCache> object to use. See L<LWP::ConnCache>
392393for details.
393394
394395=end original
395396
396397使用する C<LWP::ConnCache> オブジェクトを取得または設定します。
397398詳しくは L<LWP::ConnCache> を参照してください。
398399
399=item $ua->credentials( $netloc, $realm )
400
401400=item $ua->credentials( $netloc, $realm, $uname, $pass )
402401
403402=begin original
404403
405Get/set the user name and password to be used for a realm.
404Set the user name and password to be used for a realm. It is often more
405useful to specialize the get_basic_credentials() method instead.
406406
407407=end original
408408
409あるレルムのために使われるユーザ名、パスワードを取得/設定します。
409あるレルムのために使われるユーザ名、パスワードを設定します。
410しばしば get_basic_credentials() メソッドを特殊化するよりも便利です。
410411
411412=begin original
412413
413The $netloc is a string of the form "<host>:<port>". The username and
414The $netloc a string of the form "<host>:<port>". The username and
414415password will only be passed to this server. Example:
415416
416417=end original
417418
418419$netloc は "<host>:<port>" の形式の文字列です。
419420ユーザ名とパスワードはこのサーバにのみ渡されます。
420421例:
421422
422423 $ua->credentials("www.example.com:80", "Some Realm", "foo", "secret");
423424
424=item $ua->local_address
425
426=item $ua->local_address( $address )
427
428=begin original
429
430Get/set the local interface to bind to for network connections. The interface
431can be specified as a hostname or an IP address. This value is passed as the
432C<LocalAddr> argument to L<IO::Socket::INET>.
433
434=end original
435
436ネットワーク接続のために bind するローカルインターフェースを取得/設定します。
437インターフェースはホスト名または IP アドレスとして指定できます。
438この値は L<IO::Socket::INET> に C<LocalAddr> 引数として渡されます。
439
440425=item $ua->max_size
441426
442427=item $ua->max_size( $bytes )
443428
444429=begin original
445430
446431Get/set the size limit for response content. The default is C<undef>,
447432which means that there is no limit. If the returned response content
448433is only partial, because the size limit was exceeded, then a
449434"Client-Aborted" header will be added to the response. The content
450435might end up longer than C<max_size> as we abort once appending a
451436chunk of data makes the length exceed the limit. The "Content-Length"
452437header, if present, will indicate the length of the full content and
453438will normally not be the same as C<< length($res->content) >>.
454439
455440=end original
456441
457442レスポンスの内容(content)の大きさの制限を取得または設定します。
458443デフォルトは C<undef> で、これは制限なしを意味します。
459444長さの制限を越えているために、戻されたレスポンスの内容が
460445一部だけであれば、"Client-Aborted" ヘッダがレスポンスに追加されます。
461446内容の長さが制限を超えることになるデータの固まりに追加するのを
462447中断するので、内容の長さは結局 C<max_size> を
463448超えることになることがあります。
464449もし "Content-Length" ヘッダがあれば、内容全体の長さを示していて、
465450これは通常は C<< length($res->content) >> と同じではありません。
466451
467452=item $ua->max_redirect
468453
469454=item $ua->max_redirect( $n )
470455
471456=begin original
472457
473458This reads or sets the object's limit of how many times it will obey
474459redirection responses in a given request cycle.
475460
476461=end original
477462
478463これは、1 回のリクエストで従うリダイレクトレスポンスの
479464回数の制限を読み込みまたは設定します。
480465
481466=begin original
482467
483468By default, the value is 7. This means that if you call request()
484469method and the response is a redirect elsewhere which is in turn a
485470redirect, and so on seven times, then LWP gives up after that seventh
486471request.
487472
488473=end original
489474
490475デフォルトでは、この値は 7 です。
491476これは、request() を呼び出して、リダイレクトされた先でさらに
492477リダイレクトされて、というのを 7 回繰り返すと、LWP は 7 回目の
493478リクエストの後に諦めます。
494479
495480=item $ua->parse_head
496481
497482=item $ua->parse_head( $boolean )
498483
499484=begin original
500485
501486Get/set a value indicating whether we should initialize response
502487headers from the E<lt>head> section of HTML documents. The default is
503488TRUE. Do not turn this off, unless you know what you are doing.
504489
505490=end original
506491
507492HTML ドキュメントの E<lt>head> セクションからレスポンスヘッダを
508493初期化すべきかどうかを示す値を取得または設定します。
509494デフォルトは TRUE です。
510495何をしているのかわからなければ、これをオフにしないで下さい。
511496
512497=item $ua->protocols_allowed
513498
514499=item $ua->protocols_allowed( \@protocols )
515500
516501=begin original
517502
518503This reads (or sets) this user agent's list of protocols that the
519504request methods will exclusively allow. The protocol names are case
520505insensitive.
521506
522507=end original
523508
524509これはこのユーザエージェントが排他的に許可されているプロトコルのリストを
525510読み込み(または設定)します。
526511プロトコル名は大文字小文字を無視します。
527512
528513=begin original
529514
530515For example: C<$ua-E<gt>protocols_allowed( [ 'http', 'https'] );>
531516means that this user agent will I<allow only> those protocols,
532517and attempts to use this user agent to access URLs with any other
533518schemes (like "ftp://...") will result in a 500 error.
534519
535520=end original
536521
537522例: C<$ua-E<gt>protocols_allowed( [ 'http', 'https'] );> というのは、
538523このユーザエージェントはこれらのプロトコル I<のみ許可されている> ことを
539524意味していて、このユーザエージェントが ("ftp://..." のような) その他の
540525スキームの URL にアクセスしようとすると 500 エラーとなります。
541526
542527=begin original
543528
544529To delete the list, call: C<$ua-E<gt>protocols_allowed(undef)>
545530
546531=end original
547532
548533リストを削除するには、以下のように呼び出します: C<$ua-E<gt>protocols_allowed(undef)>
549534
550535=begin original
551536
552537By default, an object has neither a C<protocols_allowed> list, nor a
553538C<protocols_forbidden> list.
554539
555540=end original
556541
557542デフォルトでは、オブジェクトは C<protocols_allowed> リストと
558543C<protocols_forbidden> リストのどちらも持ちません。
559544
560545=begin original
561546
562547Note that having a C<protocols_allowed> list causes any
563548C<protocols_forbidden> list to be ignored.
564549
565550=end original
566551
567552C<protocols_allowed> リストがあると C<protocols_forbidden> リストは
568553無視されることに注意してください。
569554
570555=item $ua->protocols_forbidden
571556
572557=item $ua->protocols_forbidden( \@protocols )
573558
574559=begin original
575560
576561This reads (or sets) this user agent's list of protocols that the
577562request method will I<not> allow. The protocol names are case
578563insensitive.
579564
580565=end original
581566
582567これはこのユーザエージェントが I<許可されていない> プロトコルのリストを
583568読み込み(または設定)します。
584569プロトコル名は大文字小文字を無視します。
585570
586571=begin original
587572
588573For example: C<$ua-E<gt>protocols_forbidden( [ 'file', 'mailto'] );>
589574means that this user agent will I<not> allow those protocols, and
590575attempts to use this user agent to access URLs with those schemes
591576will result in a 500 error.
592577
593578=end original
594579
595580例: C<$ua-E<gt>protocols_forbidden( [ 'file', 'mailto'] );> は
596581このユーザエージェントはこれらのプロトコルを I<許可せず>、
597582このユーザエージェントを使ってこれらのスキーマで URL に
598583アクセスしようとすると 500 エラーになります。
599584
600585=begin original
601586
602587To delete the list, call: C<$ua-E<gt>protocols_forbidden(undef)>
603588
604589=end original
605590
606591リストを削除するには、このように呼び出します: C<$ua-E<gt>protocols_forbidden(undef)>
607592
608593=item $ua->requests_redirectable
609594
610595=item $ua->requests_redirectable( \@requests )
611596
612597=begin original
613598
614599This reads or sets the object's list of request names that
615600C<$ua-E<gt>redirect_ok(...)> will allow redirection for. By
616601default, this is C<['GET', 'HEAD']>, as per RFC 2616. To
617602change to include 'POST', consider:
618603
619604=end original
620605
621606これは C<$ua-E<gt>redirect_ok(...)> がリダイレクトを許可する
622607リクエスト名のリストを読み込みまたは設定します。
623608デフォルトでは、これは RFC 2616 に従って C<['GET', 'HEAD']> になっています。
624609'POST' を含むようにするには、以下のようにします:
625610
626611 push @{ $ua->requests_redirectable }, 'POST';
627612
628=item $ua->show_progress
629
630=item $ua->show_progress( $boolean )
631
632=begin original
633
634Get/set a value indicating whether a progress bar should be displayed
635on on the terminal as requests are processed. The default is FALSE.
636
637=end original
638
639リクエストの処理時に端末にプログレスバーを表示するかどうかを示す
640値を取得/設定します。
641デフォルトは偽です。
642
643613=item $ua->timeout
644614
645615=item $ua->timeout( $secs )
646616
647617=begin original
648618
649619Get/set the timeout value in seconds. The default timeout() value is
650620180 seconds, i.e. 3 minutes.
651621
652622=end original
653623
654624秒単位のタイムアウト値を取得または設定します。
655625デフォルトの timeout() の値は 180 秒、つまり 3 分です。
656626
657627=begin original
658628
659629The requests is aborted if no activity on the connection to the server
660630is observed for C<timeout> seconds. This means that the time it takes
661631for the complete transaction and the request() method to actually
662632return might be longer.
663633
664634=end original
665635
666636サーバへの接続において C<timeout> 秒反応がないと、リクエストは中断します。
667637つまり、トランザクションが完了して request() メソッドが実際に返るまでの
668638時間を意味します。
669639
670640=back
671641
672642=head2 Proxy attributes
673643
674644(プロキシ属性)
675645
676646=begin original
677647
678648The following methods set up when requests should be passed via a
679649proxy server.
680650
681651=end original
682652
683653以下のメソッドはプロキシサーバー経由で渡されるべきリクエストを設定します。
684654
685655=over
686656
687657=item $ua->proxy(\@schemes, $proxy_url)
688658
689659=item $ua->proxy($scheme, $proxy_url)
690660
691661=begin original
692662
693663Set/retrieve proxy URL for a scheme:
694664
695665=end original
696666
697667あるスキームのためのプロキシ URL を設定または取得します:
698668
699669 $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
700670 $ua->proxy('gopher', 'http://proxy.sn.no:8001/');
701671
702672=begin original
703673
704674The first form specifies that the URL is to be used for proxying of
705675access methods listed in the list in the first method argument,
706676i.e. 'http' and 'ftp'.
707677
708678=end original
709679
710680最初の形式はその URL がメソッドの最初に引数のリストに入っている
711681アクセスメソッド、つまり 'http' と 'ftp' のプロキシのために
712682使われることを指定します。
713683
714684=begin original
715685
716686The second form shows a shorthand form for specifying
717687proxy URL for a single access scheme.
718688
719689=end original
720690
7216912 番目の形式は一つのアクセス機能のためのプロキシ URL を
722692指定するための短縮した形式を示しています。
723693
724694=item $ua->no_proxy( $domain, ... )
725695
726696=begin original
727697
728698Do not proxy requests to the given domains. Calling no_proxy without
729699any domains clears the list of domains. Eg:
730700
731701=end original
732702
733703与えられたドメインへのリクエストをプロキシしません。
734704何もドメインを指定しないで no_proxy を呼ぶと、ドメインのリストを
735705クリアします。
736706例:
737707
738 $ua->no_proxy('localhost', 'example.com');
708 $ua->no_proxy('localhost', 'no', ...);
739709
740710=item $ua->env_proxy
741711
742712=begin original
743713
744714Load proxy settings from *_proxy environment variables. You might
745715specify proxies like this (sh-syntax):
746716
747717=end original
748718
749719*_proxy 環境変数からプロキシ設定をロードします。
750720以下のように指定できるでしょう(sh での書き方):
751721
752722 gopher_proxy=http://proxy.my.place/
753723 wais_proxy=http://proxy.my.place/
754 no_proxy="localhost,example.com"
724 no_proxy="localhost,my.domain"
755725 export gopher_proxy wais_proxy no_proxy
756726
757727=begin original
758728
759729csh or tcsh users should use the C<setenv> command to define these
760730environment variables.
761731
762732=end original
763733
764734csh または tcsh のユーザは、これらの環境変数を定義するために
765735C<setenv> コマンドを使わなければなりません。
766736
767737=begin original
768738
769739On systems with case insensitive environment variables there exists a
770740name clash between the CGI environment variables and the C<HTTP_PROXY>
771741environment variable normally picked up by env_proxy(). Because of
772742this C<HTTP_PROXY> is not honored for CGI scripts. The
773743C<CGI_HTTP_PROXY> environment variable can be used instead.
774744
775745=end original
776746
777747環境変数名に大文字小文字の区別がないシステムでは、
778748CGI 環境変数と、通常 env_proxy() によって読み込まれる C<HTTP_PROXY>
779749環境変数の間で名前の衝突があります。
780750この理由により、C<HTTP_PROXY> は CGI スクリプトのためのものではありません。
781751代わりに C<CGI_HTTP_PROXY> 環境変数を使えます。
782752
783753=back
784754
785=head2 Handlers
786
787(ハンドラ)
788
789=begin original
790
791Handlers are code that injected at various phases during the
792processing of requests. The following methods are provided to manage
793the 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
806Add handler to be invoked in the given processing phase. For how to
807specify %matchspec see L<HTTP::Config/"Matching">.
808
809=end original
810
811指定された処理フェーズで起動されるハンドラを追加します。
812%matchspec の指定方法については L<HTTP::Config/"Matching"> を
813参照してください。
814
815=begin original
816
817The 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
829The handler is called before the C<request_prepare> and other standard
830initialization of of the request. This can be used to set up headers
831and attributes that the C<request_prepare> handler depends on. Proxy
832initialization should take place here; but in general don't register
833handlers 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
848The handler is called before the request is sent and can modify the
849request any way it see fit. This can for instance be used to add
850certain headers to specific requests.
851
852=end original
853
854ハンドラは、リクエストを送信する前に呼び出され、
855適合するならどのような形でもリクエストを変更できます。
856これは例えば特定のリクエストにある種のヘッダを追加するのに使えます。
857
858=begin original
859
860The method can assign a new request object to $_[0] to replace the
861request that is sent fully.
862
863=end original
864
865メソッドは、送られるリクエストを完全に置き換えるために、
866$_[0] に新しいリクエストオブジェクトを代入できます。
867
868=begin original
869
870The return value from the callback is ignored. If an exceptions is
871raised 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
884This handler get a chance of handling requests before it's sent to the
885protocol handlers. It should return an HTTP::Response object if it
886wishes 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
897The C<response_header> and C<response_data> handlers will not be
898invoked for this response, but the C<response_done> will be.
899
900=end original
901
902C<response_header> と C<response_data> のハンドラは
903このレスポンスでは起動されませんが、
904C<response_done> は起動されます。
905
906=item response_header => sub { my($response, $ua, $h) = @_; ... }
907
908=begin original
909
910This handler is called right after the response headers have been
911received, but before any content data. The handler might set up
912handlers for data and might croak to abort the request.
913
914=end original
915
916このハンドラは、レスポンスヘッダを受信した直後、本体データを
917受信する前に呼び出されます。
918ハンドラはデータのためにハンドラを設定したりリクエストを中止するために
919croak したりできます。
920
921=begin original
922
923The handler might set the $response->{default_add_content} value to
924control if any received data should be added to the response object
925directly. This will initially be false if the $ua->request() method
926was 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
939This handlers is called for each chunk of data received for the
940response. The handler might croak to abort the request.
941
942=end original
943
944このハンドラは、レスポンスとしてデータの塊を受信する毎に呼び出されます。
945このハンドラはリクエストを中止するために croak できます。
946
947=begin original
948
949This handler need to return a TRUE value to be called again for
950subsequent 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
961The handler is called after the response has been fully received, but
962before any redirect handling is attempted. The handler can be used to
963extract 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
975The handler is called in $ua->request after C<response_done>. If the
976handler return an HTTP::Request object we'll start over with processing
977this 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
993Remove handlers that match the given %matchspec. If $phase is not
994provided remove handlers from all phases.
995
996=end original
997
998%matchspec に一致するハンドラを削除します。
999$phase が指定されないと、全てのフェーズからハンドラを削除します。
1000
1001=begin original
1002
1003Be careful as calling this function with %matchspec that is not not
1004specific enough can remove handlers not owned by you. It's probably
1005better 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
1015The 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
1025Set handlers private to the executing subroutine. Works by defaulting
1026an C<owner> field to the %matchspec that holds the name of the called
1027subroutine. You might pass an explicit C<owner> to override this.
1028
1029=end original
1030
1031サブルーチンを実行するのにプライベートなハンドラを設定します。
1032C<owner> フィールドに、呼び出したサブルーチン名を保持した %matchspec を
1033デフォルトで設定することで動作します。
1034これを上書きするために明示的な C<owner> を渡すことができます。
1035
1036=begin original
1037
1038If $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
1050Will retrieve the matching handler as hash ref.
1051
1052=end original
1053
1054一致するハンドラをハッシュリファレンスとして受け取ります。
1055
1056=begin original
1057
1058If C<$init> is passed passed as a TRUE value, create and add the
1059handler if it's not found. If $init is a subroutine reference, then
1060it's called with the created handler hash as argument. This sub might
1061populate the hash with extra fields; especially the callback. If
1062$init is a hash reference, merge the hashes.
1063
1064=end original
1065
1066C<$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
1080Returns the handlers that apply to the given request or response at
1081the given processing phase.
1082
1083=end original
1084
1085指定された処理フェーズで指定されたリクエストまたはレスポンスに
1086適用されるハンドラを返します。
1087
1088=back
1089
1090755=head1 REQUEST METHODS
1091756
1092757(リクエストメソッド)
1093758
1094759=begin original
1095760
1096761The methods described in this section are used to dispatch requests
1097762via the user agent. The following request methods are provided:
1098763
1099764=end original
1100765
1101766この章で記述されているメソッドはユーザエージェント経由でリクエストを
1102767発行するために使われます。
1103768以下のリクエストメソッドが提供されています:
1104769
1105770=over
1106771
1107772=item $ua->get( $url )
1108773
1109774=item $ua->get( $url , $field_name => $value, ... )
1110775
1111776=begin original
1112777
1113778This method will dispatch a C<GET> request on the given $url. Further
1114779arguments can be given to initialize the headers of the request. These
1115780are given as separate name/value pairs. The return value is a
1116781response object. See L<HTTP::Response> for a description of the
1117782interface it provides.
1118783
1119784=end original
1120785
1121786このメソッドは、与えられた $url に C<GET> リクエストを発行します。
1122787リクエストのヘッダを初期化するために追加の引数を与えることもできます。
1123788これらは別々の名前/値の組で与えられます。
1124789返り値はレスポンスオブジェクトです。
1125790これが提供するインターフェースの説明については L<HTTP::Response> を
1126791参照してください。
1127792
1128793=begin original
1129794
1130There will still be a response object returned when LWP can't connect to the
1131server specified in the URL or when other failures in protocol handlers occur.
1132These internal responses use the standard HTTP status codes, so the responses
1133can't be differentiated by testing the response status code alone. Error
1134responses that LWP generates internally will have the "Client-Warning" header
1135set to the value "Internal response". If you need to differentiate these
1136internal responses from responses that a remote server actually generates, you
1137need to test this header value.
1138
1139=end original
1140
1141LWP が URL で指定されたサーバに接続できない場合や、プロトコルハンドラ内で
1142その他のエラーが発生した場合でも、レスポンスオブジェクトが返されます。
1143これらの内部レスポンスは標準の HTTP ステータスコードを使うので、
1144レスポンスステータスコードだけをテストしても、レスポンスを
1145区別することはできません。
1146LWP が内部で生成したエラーレスポンスは、"Client-Warning" ヘッダに
1147"Internal response" という値が設定されます。
1148これらの内部レスポンスを実際にリモートサーバが生成したレスポンスと
1149区別する必要がある場合は、このヘッダの値をテストする必要があります。
1150
1151=begin original
1152
1153795Fields names that start with ":" are special. These will not
1154796initialize headers of the request but will determine how the response
1155797content is treated. The following special field names are recognized:
1156798
1157799=end original
1158800
1159801":" で始まるフィールド名は特殊です。
1160802これらはリクエストのヘッダの初期化はせず、レスポンスオブジェクトが
1161803どのように扱われるかを決定します。
1162804以下の特殊フィールド名を認識します:
1163805
1164806 :content_file => $filename
1165807 :content_cb => \&callback
1166808 :read_size_hint => $bytes
1167809
1168810=begin original
1169811
1170812If a $filename is provided with the C<:content_file> option, then the
1171813response content will be saved here instead of in the response
1172814object. If a callback is provided with the C<:content_cb> option then
1173815this function will be called for each chunk of the response content as
1174816it is received from the server. If neither of these options are
1175817given, then the response content will accumulate in the response
1176818object itself. This might not be suitable for very large response
1177819bodies. Only one of C<:content_file> or C<:content_cb> can be
1178820specified. The content of unsuccessful responses will always
1179821accumulate in the response object itself, regardless of the
1180822C<:content_file> or C<:content_cb> options passed in.
1181823
1182824=end original
1183825
1184826C<:content_file> オプションで $filename が指定されると、レスポンスの内容は
1185827レスポンスオブジェクトの代わりにこのファイルに保存されます。
1186828C<:content_cb> オプションでコールバック関数が指定されると、
1187829レスポンスの内容の塊ををサーバから受信する毎にこの関数が呼び出されます。
1188830これらのオプションのどちらも指定されなかった場合、レスポンスの内容は
1189831レスポンスオブジェクト自身に蓄積されます。
1190832これはレスポンスボディがとても大きい場合には向いていません。
1191833C<:content_file> と C<:content_cb> のどちらか一つのみが指定できます。
1192834失敗したレスポンスの内容は、C<:content_file> や C<:content_cb> の
1193835オプションが指定されているかどうかに関わらず
1194836常にレスポンスオブジェクト自身に蓄積されます。
1195837
1196838=begin original
1197839
1198840The C<:read_size_hint> option is passed to the protocol module which
1199841will try to read data from the server in chunks of this size. A
1200842smaller value for the C<:read_size_hint> will result in a higher
1201843number of callback invocations.
1202844
1203845=end original
1204846
1205847C<:read_size_hint> オプションは、このサイズの塊でサーバからデータを
1206848読み込もうとするようにプロトコルモジュールに渡されます。
1207849C<:read_size_hint> の値を小さくすると、コールバックの起動回数は
1208850多くなります。
1209851
1210852=begin original
1211853
1212854The callback function is called with 3 arguments: a chunk of data, a
1213855reference to the response object, and a reference to the protocol
1214856object. The callback can abort the request by invoking die(). The
1215857exception message will show up as the "X-Died" header field in the
1216858response returned by the get() function.
1217859
1218860=end original
1219861
1220862コールバック関数は 3 引数で呼び出されます: データの塊、
1221863レスポンスオブジェクトへのリファレンス、プロトコルオブジェクトへの
1222864リファレンス、です。
1223865コールバックは die() を起動することでリクエストを中断できます。
1224866例外メッセージは、get() 関数で返されるレスポンスの中の
1225867"X-Died" ヘッダフィールドで得られます。
1226868
1227869=item $ua->head( $url )
1228870
1229871=item $ua->head( $url , $field_name => $value, ... )
1230872
1231873=begin original
1232874
1233875This method will dispatch a C<HEAD> request on the given $url.
1234876Otherwise it works like the get() method described above.
1235877
1236878=end original
1237879
1238880このメソッドは、与えられた $url に C<HEAD> リクエストを発行します。
1239881その他は上述の get() メソッドと同様に動作します。
1240882
1241883=item $ua->post( $url, \%form )
1242884
1243885=item $ua->post( $url, \@form )
1244886
1245887=item $ua->post( $url, \%form, $field_name => $value, ... )
1246888
1247889=item $ua->post( $url, $field_name => $value,... Content => \%form )
1248890
1249891=item $ua->post( $url, $field_name => $value,... Content => \@form )
1250892
1251893=item $ua->post( $url, $field_name => $value,... Content => $content )
1252894
1253895=begin original
1254896
1255897This method will dispatch a C<POST> request on the given $url, with
1256898%form or @form providing the key/value pairs for the fill-in form
1257899content. Additional headers and content options are the same as for
1258900the get() method.
1259901
1260902=end original
1261903
1262904このメソッドは、与えられた $url に、フォームの内容として
1263905%form または @form で与えられるキー/値の組を使って
1264906C<POST> リクエストを発行します。
1265907追加のヘッダと内容のオプションは get() メソッドと同じです。
1266908
1267909=begin original
1268910
1269911This method will use the POST() function from C<HTTP::Request::Common>
1270912to build the request. See L<HTTP::Request::Common> for a details on
1271913how to pass form content and other advanced features.
1272914
1273915=end original
1274916
1275917このメソッドは、リクエストを構築するために
1276918C<HTTP::Request::Common> の POST() 関数を使います。
1277919フォームの内容の渡し方とその他の高度な機能に関する詳細については
1278920L<HTTP::Request::Common> を参照してください。
1279921
1280922=item $ua->mirror( $url, $filename )
1281923
1282924=begin original
1283925
1284926This method will get the document identified by $url and store it in
1285927file called $filename. If the file already exists, then the request
1286928will contain an "If-Modified-Since" header matching the modification
1287929time of the file. If the document on the server has not changed since
1288930this time, then nothing happens. If the document has been updated, it
1289931will be downloaded again. The modification time of the file will be
1290932forced to match that of the server.
1291933
1292934=end original
1293935
1294936このメソッドは $url で識別されるドキュメントを取得し、$filename で
1295937指定されるファイルに保管します。
1296938ファイルが既に存在する場合、リクエストにはそのファイルの修正時刻に一致する
1297939"If-Modified-Since" ヘッダが含まれます。
1298940ドキュメントが更新されている場合は、再びダウンロードされます。
1299941ファイルの修正時刻はサーバ上での修正時刻と同じになります。
1300942
1301943=begin original
1302944
1303945The return value is the the response object.
1304946
1305947=end original
1306948
1307949返り値はレスポンスオブジェクトです。
1308950
1309951=item $ua->request( $request )
1310952
1311953=item $ua->request( $request, $content_file )
1312954
1313955=item $ua->request( $request, $content_cb )
1314956
1315957=item $ua->request( $request, $content_cb, $read_size_hint )
1316958
1317959=begin original
1318960
1319961This method will dispatch the given $request object. Normally this
1320962will be an instance of the C<HTTP::Request> class, but any object with
1321963a similar interface will do. The return value is a response object.
1322964See L<HTTP::Request> and L<HTTP::Response> for a description of the
1323965interface provided by these classes.
1324966
1325967=end original
1326968
1327969このメソッドは与えられた $request オブジェクトを発行します。
1328970通常これは C<HTTP::Request> クラスの実体ですが、似たような
1329971インターフェースを持つどのようなオブジェクトでも動作します。
1330972返り値はレスポンスオブジェクトです。
1331973これらのクラスによって提供されるインターフェースの記述については
1332974L<HTTP::Request> と L<HTTP::Response> を参照してください。
1333975
1334976=begin original
1335977
1336978The request() method will process redirects and authentication
1337979responses transparently. This means that it may actually send several
1338980simple requests via the simple_request() method described below.
1339981
1340982=end original
1341983
1342984request() メソッドはリダイレクトと認証を透過的に処理します。
1343985これは、実際には後述する simple_request() メソッドを使って単純な
1344986リクエストを複数回送信するかもしれないことを意味します。
1345987
1346988=begin original
1347989
1348990The request methods described above; get(), head(), post() and
1349991mirror(), will all dispatch the request they build via this method.
1350992They are convenience methods that simply hides the creation of the
1351993request object for you.
1352994
1353995=end original
1354996
1355997上述のリクエストメソッド: get(), head(), post(), mirror() は全て
1356998構築したリクエストをこのメソッド経由で発行します。
1357999これらは単にリクエストメソッドの作成をあなたから隠すための
13581000便利メソッドです。
13591001
13601002=begin original
13611003
13621004The $content_file, $content_cb and $read_size_hint all correspond to
13631005options described with the get() method above.
13641006
13651007=end original
13661008
13671009$content_file, $content_cb, $read_size_hint は全て上述の
13681010get() メソッドで記述したオプションに対応します。
13691011
13701012=begin original
13711013
13721014You are allowed to use a CODE reference as C<content> in the request
13731015object passed in. The C<content> function should return the content
13741016when called. The content can be returned in chunks. The content
13751017function will be invoked repeatedly until it return an empty string to
13761018signal that there is no more content.
13771019
13781020=end original
13791021
13801022リクエストオブジェクトに渡す C<content> としてコードリファレンスも使えます。
13811023C<content> 関数は、呼び出されたときに内容を返すようにします。
13821024内容は塊で返すこともできます。
13831025content 関数は、もう内容がないことを示すために空文字列が返されるまで
13841026繰り返し起動されます。
13851027
13861028=item $ua->simple_request( $request )
13871029
13881030=item $ua->simple_request( $request, $content_file )
13891031
13901032=item $ua->simple_request( $request, $content_cb )
13911033
13921034=item $ua->simple_request( $request, $content_cb, $read_size_hint )
13931035
13941036=begin original
13951037
13961038This method dispatches a single request and returns the response
13971039received. Arguments are the same as for request() described above.
13981040
13991041=end original
14001042
14011043このメソッドは 1 回のリクエストを発行し、受信したレスポンスを返します。
14021044引数は上述の request() のものと同じです。
14031045
14041046=begin original
14051047
14061048The difference from request() is that simple_request() will not try to
14071049handle redirects or authentication responses. The request() method
14081050will in fact invoke this method for each simple request it sends.
14091051
14101052=end original
14111053
14121054request() との違いは、simple_request() はリダイレクトや認証を
14131055扱おうとしないことです。
14141056実際のところ、request() メソッドは、単純なリクエストを送る度に
14151057このメソッドを起動します。
14161058
14171059=item $ua->is_protocol_supported( $scheme )
14181060
14191061=begin original
14201062
14211063You can use this method to test whether this user agent object supports the
14221064specified C<scheme>. (The C<scheme> might be a string (like 'http' or
14231065'ftp') or it might be an URI object reference.)
14241066
14251067=end original
14261068
14271069このユーザエージェントが指定された C<scheme> を
14281070サポートしているかどうかを調べるために使うことができます。
14291071(C<scheme> には ('http' や 'ftp' のような)文字列や、
14301072URI オブジェクトリファレンスを指定できます。)
14311073
14321074=begin original
14331075
14341076Whether a scheme is supported, is determined by the user agent's
14351077C<protocols_allowed> or C<protocols_forbidden> lists (if any), and by
14361078the capabilities of LWP. I.e., this will return TRUE only if LWP
14371079supports this protocol I<and> it's permitted for this particular
14381080object.
14391081
14401082=end original
14411083
14421084あるスキーマが対応しているかどうかは、(もしあれば)ユーザエージェントの
14431085C<protocols_allowed> と C<protocols_forbidden> のリスト、および
14441086LWP の能力によって決定されます。
14451087つまり、このメソッドは LWP がこのプロトコルに対応していて、I<かつ> それが
14461088このオブジェクトに対して許可されている場合にのみ TRUE を返します。
14471089
14481090=back
14491091
14501092=head2 Callback methods
14511093
14521094(コールバックメソッド)
14531095
14541096=begin original
14551097
14561098The following methods will be invoked as requests are processed. These
14571099methods are documented here because subclasses of C<LWP::UserAgent>
14581100might want to override their behaviour.
14591101
14601102=end original
14611103
14621104以下のメソッドはリクエストの処理中に起動されます。
14631105これらのメソッドは、C<LWP::UserAgent> のサブクラスが振る舞いを
14641106オーバーライドしたいかもしれないので、ここで記述されています。
14651107
14661108=over
14671109
14681110=item $ua->prepare_request( $request )
14691111
14701112=begin original
14711113
14721114This method is invoked by simple_request(). Its task is to modify the
14731115given $request object by setting up various headers based on the
14741116attributes of the user agent. The return value should normally be the
14751117$request object passed in. If a different request object is returned
14761118it will be the one actually processed.
14771119
14781120=end original
14791121
14801122このメソッドは simple_request() によって起動されます。
14811123その使命は、与えられた $request オブジェクトを、ユーザエージェントの
14821124属性によって様々なヘッダを設定することで変更することです。
14831125返り値は通常は渡された $request オブジェクトです。
14841126異なる request オブジェクトが返された場合、それは実際に処理されたものです。
14851127
14861128=begin original
14871129
14881130The headers affected by the base implementation are; "User-Agent",
14891131"From", "Range" and "Cookie".
14901132
14911133=end original
14921134
14931135基本実装によって影響を受けるヘッダは、
14941136"User-Agent", "From", "Range", "Cookie" です。
14951137
14961138=item $ua->redirect_ok( $prospective_request, $response )
14971139
14981140=begin original
14991141
15001142This method is called by request() before it tries to follow a
15011143redirection to the request in $response. This should return a TRUE
15021144value if this redirection is permissible. The $prospective_request
15031145will be the request to be sent if this method returns TRUE.
15041146
15051147=end original
15061148
15071149このメソッドは、$response のリクエストのリダイレクトに
15081150従おうとする前に、request() によって呼ばれます。
15091151このリダイレクトを許可する場合には真の値を返します。
15101152$prospective_request は、このメソッドが真を返した場合に
15111153送信されるリクエストです。
15121154
15131155=begin original
15141156
15151157The base implementation will return FALSE unless the method
15161158is in the object's C<requests_redirectable> list,
15171159FALSE if the proposed redirection is to a "file://..."
15181160URL, and TRUE otherwise.
15191161
15201162=end original
15211163
15221164基本実装では、メソッドがそのオブジェクトの C<requests_redirectable> リストに
15231165ない場合と、予定されているリダイレクトが "file://..." URL の場合に
15241166偽を返し、それ以外では真を返します。
15251167
15261168=item $ua->get_basic_credentials( $realm, $uri, $isproxy )
15271169
15281170=begin original
15291171
15301172This is called by request() to retrieve credentials for documents
15311173protected by Basic or Digest Authentication. The arguments passed in
15321174is the $realm provided by the server, the $uri requested and a boolean
15331175flag to indicate if this is authentication against a proxy server.
15341176
15351177=end original
15361178
15371179基本認証またはダイジェスト認証により保護されている文書のための
15381180証明物 (credentials) の取得のために request() によって呼ばれます。
15391181渡される引数は、$realm がサーバから提供されるレルム、
15401182$uri がリクエストされる URI、$isproxy がこれがプロキシサーバーに
15411183対する認証かどうかを示す真偽値フラグです。
15421184
15431185=begin original
15441186
15451187The method should return a username and password. It should return an
15461188empty list to abort the authentication resolution attempt. Subclasses
15471189can override this method to prompt the user for the information. An
15481190example of this can be found in C<lwp-request> program distributed
15491191with this library.
15501192
15511193=end original
15521194
15531195このメソッドはユーザ名とパスワードを返します。
15541196認証解決の試みを中断させるためには空リストを返します。
15551197サブクラスはユーザに情報を尋ねるためにこのモジュールを上書きできます。
15561198この例はこのライブラリと一緒に配布される
15571199C<lwp-request> プログラムにあります。
15581200
15591201=begin original
15601202
15611203The base implementation simply checks a set of pre-stored member
15621204variables, set up with the credentials() method.
15631205
15641206=end original
15651207
15661208基本実装は単にあらかじめ保管されているメンバ変数をチェックし、
15671209credentials() メソッドを設定します。
15681210
15691211=item $ua->progress( $status, $request_or_response )
15701212
15711213=begin original
15721214
15731215This is called frequently as the response is received regardless of
15741216how the content is processed. The method is called with $status
15751217"begin" at the start of processing the request and with $state "end"
15761218before the request method returns. In between these $status will be
15771219the fraction of the response currently received or the string "tick"
15781220if the fraction can't be calculated.
15791221
15801222=end original
15811223
15821224これは、内容がどのように処理されるかにかかわらず、レスポンスを
15831225受信する度に呼び出されます。
15841226このメソッドは、リクエストの処理開始時には
15851227$status に "begin" を設定して呼び出され、
15861228リクエストメソッドが返る前には $status に "end" を設定して呼び出されます。
15871229その間では、$status は現在受信したレスポンスの割合か、
15881230割合が計算できない場合は文字列 "tick" です。
15891231
15901232=begin original
15911233
15921234When $status is "begin" the second argument is the request object,
15931235otherwise it is the response object.
15941236
15951237=end original
15961238
159712392 番目の引数は、$status が "begin" の場合はリクエストオブジェクトで、
15981240そうでない場合はレスポンスオブジェクトです。
15991241
16001242=back
16011243
16021244=head1 SEE ALSO
16031245
16041246=begin original
16051247
16061248See L<LWP> for a complete overview of libwww-perl5. See L<lwpcook>
16071249and the scripts F<lwp-request> and F<lwp-download> for examples of
16081250usage.
16091251
16101252=end original
16111253
16121254libwww-perl5 の完全な概要は L<LWP> を参照してください。
16131255使い方の例については、L<lwpcook> および
16141256F<lwp-request> と F<lwp-mirror> のスクリプトを参照してください。
16151257
16161258=begin original
16171259
16181260See L<HTTP::Request> and L<HTTP::Response> for a description of the
16191261message objects dispatched and received. See L<HTTP::Request::Common>
16201262and L<HTML::Form> for other ways to build request objects.
16211263
16221264=end original
16231265
16241266発行したり受信したりするメッセージオブジェクトの記述については
16251267L<HTTP::Request> と L<HTTP::Response> を参照してください。
16261268リクエストオブジェクトを構築するその他の方法については
16271269L<HTTP::Request::Common> と L<HTML::Form> を参照してください。
16281270
16291271=begin original
16301272
16311273See L<WWW::Mechanize> and L<WWW::Search> for examples of more
16321274specialized user agents based on C<LWP::UserAgent>.
16331275
16341276=end original
16351277
16361278C<LWP::UserAgent> を基とした、より特殊化したユーザエージェントの例については
16371279L<WWW::Mechanize> と L<WWW::Search> を参照してください。
16381280
16391281=head1 COPYRIGHT
16401282
1641Copyright 1995-2009 Gisle Aas.
1283Copyright 1995-2008 Gisle Aas.
16421284
16431285This library is free software; you can redistribute it and/or
16441286modify it under the same terms as Perl itself.
16451287
1646
16471288=begin meta
16481289
1649Translate: Hippo2000 <GCD00051@nifty.ne.jp> (5.48)
1290Translated: Hippo2000 <GCD00051@nifty.ne.jp> (5.48)
1650Update: SHIRAKATA Kentaro <argrath@ub32.org> (5.813-)
1291Updated: Kentaro SHIRAKATA <argrath@ub32.org> (5.813)
1651Status: completed
16521292
16531293=end meta