HTTP-Tiny-0.012 > 0.017 との差分

HTTP::Tiny 0.017 と 0.012 の差分

11
2=encoding euc-jp
3
42=pod
53
4=encoding euc-jp
5
66=head1 NAME
77
88=begin original
99
1010HTTP::Tiny - A small, simple, correct HTTP/1.1 client
1111
1212=end original
1313
1414HTTP::Tiny - 小さく、シンプルで、正しい HTTP/1.1 クライアント
1515
1616=head1 VERSION
1717
1818=begin original
1919
20version 0.017
20version 0.012
2121
2222=end original
2323
24バージョン 0.017
24バージョン 0.012
2525
2626=head1 SYNOPSIS
2727
2828 use HTTP::Tiny;
2929
3030 my $response = HTTP::Tiny->new->get('http://example.com/');
3131
3232 die "Failed!\n" unless $response->{success};
3333
3434 print "$response->{status} $response->{reason}\n";
3535
3636 while (my ($k, $v) = each %{$response->{headers}}) {
3737 for (ref $v eq 'ARRAY' ? @$v : $v) {
3838 print "$k: $_\n";
3939 }
4040 }
4141
4242 print $response->{content} if length $response->{content};
4343
4444=head1 DESCRIPTION
4545
4646=begin original
4747
48This is a very simple HTTP/1.1 client, designed for doing simple GET
48This is a very simple HTTP/1.1 client, designed primarily for doing simple GET
4949requests without the overhead of a large framework like L<LWP::UserAgent>.
5050
5151=end original
5252
53これはとてもシンプルな HTTP/1.1 クライアントで、
53これはとてもシンプルな HTTP/1.1 クライアントで、基本的には
5454L<LWP::UserAgent> のような大きなフレームワークのオーバーヘッドなしに
5555単純な GET リクエストを実行するために設計されています。
5656
5757=begin original
5858
5959It is more correct and more complete than L<HTTP::Lite>. It supports
6060proxies (currently only non-authenticating ones) and redirection. It
6161also correctly resumes after EINTR.
6262
6363=end original
6464
6565これは L<HTTP::Lite> よりも正しく、完全です。
6666これはプロキシ (現在のところ認証なしのもののみ) および
6767リダイレクトに対応しています。
6868また、EINTR の後正しく再開します。
6969
7070=head1 METHODS
7171
7272=head2 new
7373
7474 $http = HTTP::Tiny->new( %attributes );
7575
7676=begin original
7777
7878This constructor returns a new HTTP::Tiny object. Valid attributes include:
7979
8080=end original
8181
8282このコンストラクタは新しい HTTP::Tiny オブジェクトを返します。
8383有効な属性は以下のものです:
8484
8585=over 4
8686
8787=item *
8888
89C<agent>
89agent
9090
9191=begin original
9292
9393A user-agent string (defaults to 'HTTP::Tiny/$VERSION')
9494
9595=end original
9696
9797ユーザーエージェント文字列 (デフォルトは 'HTTP::Tiny/$VERSION')
9898
9999=item *
100100
101C<default_headers>
101default_headers
102102
103103=begin original
104104
105105A hashref of default headers to apply to requests
106106
107107=end original
108108
109109リクエストに適用されるデフォルトのヘッダのハッシュリファレンス
110110
111111=item *
112112
113C<max_redirect>
113max_redirect
114114
115115=begin original
116116
117117Maximum number of redirects allowed (defaults to 5)
118118
119119=end original
120120
121121リダイレクトの最大数 (デフォルトは 5)
122122
123123=item *
124124
125C<max_size>
125max_size
126126
127127=begin original
128128
129129Maximum response size (only when not using a data callback). If defined,
130responses larger than this will return an exception.
130responses larger than this will die with an error message
131131
132132=end original
133133
134134最大レスポンスサイズ (データコールバックを使っていない場合のみ)。
135定義されると、これより大きなレスポンスは例外します。
135定義されると、これより大きなレスポンスはエラーメッセージ出して die します。
136136
137137=item *
138138
139C<proxy>
139proxy
140140
141141=begin original
142142
143URL of a proxy server to use (default is C<$ENV{http_proxy}> if set)
143URL of a proxy server to use.
144144
145145=end original
146146
147使うプロキシサーバの URL (デフォルトは、設定されていれば
147使うプロキシサーバの URL
148C<$ENV{http_proxy}>)。
149148
150149=item *
151150
152C<timeout>
151timeout
153152
154153=begin original
155154
156155Request timeout in seconds (default is 60)
157156
158157=end original
159158
160159リクエストのタイムアウト秒 (デフォルトは 60)
161160
162161=back
163162
164=begin original
163=head2 get
165164
166Exceptions from C<max_size>, C<timeout> or other errors will result in a
167pseudo-HTTP status code of 599 and a reason of "Internal Exception". The
168content field in the response will contain the text of the exception.
169
170=end original
171
172C<max_size>, C<timeout> からの例外やその他のエラーは疑似 HTTP ステータスコード
173599 と理由 "Internal Exception" を返します。
174レスポンスの content フィールドは例外のテキストを含みます。
175
176=head2 get|head|put|post|delete
177
178165 $response = $http->get($url);
179166 $response = $http->get($url, \%options);
180 $response = $http->head($url);
181167
182168=begin original
183169
184These methods are shorthand for calling C<request()> for the given method. The
170Executes a C<GET> request for the given URL. The URL must have unsafe
185URL must have unsafe characters escaped and international domain names encoded.
171characters escaped and international domain names encoded. Internally, it just
186See C<request()> for valid options and a description of the response.
172calls C<request()> with 'GET' as the method. See C<request()> for valid
173options and a description of the response.
187174
188175=end original
189176
190これらのメソッドは、指定されたメソッドで C<request()> を呼び出す省略形です。
177指定された URL に対して C<GET> リクエスト実行します。
191178URL は安全な文字をエスケープされていなければならず、国際ドメイン名は
192179エンコードされていなければなりません。
180内部としては、単にメソッドを 'GET' として C<request()> を呼び出します。
193181有効なオプションとレスポンスに関する説明については
194182C<request()> を参照してください。
195183
196=begin original
197
198The C<success> field of the response will be true if the status code is 2XX.
199
200=end original
201
202レスポンスの C<success> フィールドは、ステータスコードが 2XX の場合に
203真になります。
204
205=head2 post_form
206
207 $response = $http->post_form($url, $form_data);
208 $response = $http->post_form($url, $form_data, \%options);
209
210=begin original
211
212This method executes a C<POST> request and sends the key/value pairs from a
213form data hash or array reference to the given URL with a C<content-type> of
214C<application/x-www-form-urlencoded>. See documentation for the
215C<www_form_urlencode> method for details on the encoding.
216
217=end original
218
219This method executes a C<POST> request and sends the key/value pairs from a
220form data hash or array reference to the given URL with a C<content-type> of
221C<application/x-www-form-urlencoded>. See documentation for the
222C<www_form_urlencode> method for details on the encoding.
223(TBT)
224
225=begin original
226
227The URL must have unsafe characters escaped and international domain names
228encoded. See C<request()> for valid options and a description of the response.
229Any C<content-type> header or content in the options hashref will be ignored.
230
231=end original
232
233The URL must have unsafe characters escaped and international domain names
234encoded. See C<request()> for valid options and a description of the response.
235Any C<content-type> header or content in the options hashref will be ignored.
236(TBT)
237
238=begin original
239
240The C<success> field of the response will be true if the status code is 2XX.
241
242=end original
243
244レスポンスの C<success> フィールドは、ステータスコードが 2XX の場合に
245真になります。
246
247184=head2 mirror
248185
249186 $response = $http->mirror($url, $file, \%options)
250187 if ( $response->{success} ) {
251188 print "$file is up to date\n";
252189 }
253190
254191=begin original
255192
256193Executes a C<GET> request for the URL and saves the response body to the file
257194name provided. The URL must have unsafe characters escaped and international
258195domain names encoded. If the file already exists, the request will includes an
259196C<If-Modified-Since> header with the modification timestamp of the file. You
260may specify a different C<If-Modified-Since> header yourself in the C<<
197may specificy a different C<If-Modified-Since> header yourself in the C<<
261198$options->{headers} >> hash.
262199
263200=end original
264201
265202URL に対して C<GET> リクエストを実行し、レスポンス本体を指定された
266203ファイル名に保存します。
267204URL は安全でない文字はエスケープされていなければならず、
268205国際ドメイン名はエンコードされていなければなりません。
269206ファイルが既に存在している場合、リクエストにはそのファイルの変更時刻が
270207C<If-Modified-Since> ヘッダに指定されます。
271208C<< $options->{headers} >> ハッシュに異なる C<If-Modified-Since> ヘッダを
272209指定することもできます。
273210
274211=begin original
275212
276213The C<success> field of the response will be true if the status code is 2XX
277or if the status code is 304 (unmodified).
214or 304 (unmodified).
278215
279216=end original
280217
281218レスポンスの C<success> フィールドは、ステータスコードが 2XX または
282219304 (unmodified) の場合に真になります。
283220
284221=begin original
285222
286223If the file was modified and the server response includes a properly
287224formatted C<Last-Modified> header, the file modification time will
288225be updated accordingly.
289226
290227=end original
291228
292229ファイルが変更されていて、サーバレスポンスに適切にフォーマットされている
293230C<Last-Modified> ヘッダが含まれている場合、
294231ファイル変更時刻はそれに応じて更新されます。
295232
296233=head2 request
297234
298235 $response = $http->request($method, $url);
299236 $response = $http->request($method, $url, \%options);
300237
301238=begin original
302239
303240Executes an HTTP request of the given method type ('GET', 'HEAD', 'POST',
304241'PUT', etc.) on the given URL. The URL must have unsafe characters escaped and
305242international domain names encoded. A hashref of options may be appended to
306243modify the request.
307244
308245=end original
309246
310247指定された URL に与えられたメソッド型 ('GET', 'HEAD', 'POST',
311248'PUT' など) で HTTP リクエストを実行します。
312249URL は安全でない文字はエスケープされていなければならず、
313250国際ドメイン名はエンコードされていなければなりません。
314251オプションのハッシュリファレンスはリクエストを修正するために追加されます。
315252
316253=begin original
317254
318255Valid options are:
319256
320257=end original
321258
322259有効なオプションは:
323260
324261=over 4
325262
326263=item *
327264
328265headers
329266
330267=begin original
331268
332269A hashref containing headers to include with the request. If the value for
333270a header is an array reference, the header will be output multiple times with
334271each value in the array. These headers over-write any default headers.
335272
336273=end original
337274
338275リクエストに含まれるヘッダを含むハッシュリファレンス。
339276ヘッダの値が配列リファレンスの場合、ヘッダは配列のそれぞれの値で
340277複数回出力されます。
341278これらのヘッダはどのようなデフォルトヘッダも上書きします。
342279
343280=item *
344281
345282content
346283
347284=begin original
348285
349286A scalar to include as the body of the request OR a code reference
350287that will be called iteratively to produce the body of the response
351288
352289=end original
353290
354291リクエストの本体を含むスカラ、またはレスポンスの本体を生成するために
355292繰り返し呼び出されるコードリファレンス
356293
357294=item *
358295
359296trailer_callback
360297
361298=begin original
362299
363300A code reference that will be called if it exists to provide a hashref
364301of trailing headers (only used with chunked transfer-encoding)
365302
366303=end original
367304
368305(chunked transfer-encoding でのみ使われる) 末尾のヘッダの
369306ハッシュリファレンスを提供するために呼び出されるコードリファレンス
370307
371308=item *
372309
373310data_callback
374311
375312=begin original
376313
377314A code reference that will be called for each chunks of the response
378315body received.
379316
380317=end original
381318
382319レスポンス本体のチャンクを受信する度に呼び出されるコードリファレンス。
383320
384321=back
385322
386323=begin original
387324
388325If the C<content> option is a code reference, it will be called iteratively
389326to provide the content body of the request. It should return the empty
390327string or undef when the iterator is exhausted.
391328
392329=end original
393330
394331C<content> オプションがコードリファレンスの場合、
395332リクエストの本体を提供するために呼び出されます。
396333反復子を終わる場合、空文字列か undef を返す必要があります。
397334
398335=begin original
399336
400337If the C<data_callback> option is provided, it will be called iteratively until
401338the entire response body is received. The first argument will be a string
402339containing a chunk of the response body, the second argument will be the
403340in-progress response hash reference, as described below. (This allows
404341customizing the action of the callback based on the C<status> or C<headers>
405342received prior to the content body.)
406343
407344=end original
408345
409346C<data_callback> オプションが指定されると、
410347レスポンス本体全体が受信されるまで繰り返し呼び出されます。
411348最初の引数はレスポンス本体のチャンクを含む文字列で、2 番目の引数は
412349後述する作業中のレスポンスのハッシュリファレンスです。
413350(これにより、本体の前に受信した C<status> や C<headers> を基にして
414351コールバックの動作を変えることができます。)
415352
416353=begin original
417354
418355The C<request> method returns a hashref containing the response. The hashref
419356will have the following keys:
420357
421358=end original
422359
423360C<request> メソッドはレスポンスを含むハッシュリファレンスを返します。
424361ハッシュリファレンスには以下のキーを持ちます:
425362
426363=over 4
427364
428365=item *
429366
430367success
431368
432369=begin original
433370
434371Boolean indicating whether the operation returned a 2XX status code
435372
436373=end original
437374
438375操作が 2XX ステータスコードを返したかどうかを示す真偽値
439376
440377=item *
441378
442379status
443380
444381=begin original
445382
446383The HTTP status code of the response
447384
448385=end original
449386
450387レスポンスの HTTP ステータス
451388
452389=item *
453390
454391reason
455392
456393=begin original
457394
458395The response phrase returned by the server
459396
460397=end original
461398
462399サーバからのレスポンス文字列
463400
464401=item *
465402
466403content
467404
468405=begin original
469406
470407The body of the response. If the response does not have any content
471408or if a data callback is provided to consume the response body,
472409this will be the empty string
473410
474411=end original
475412
476413レスポンスの本体。
477414レスポンスに内容がなかったり、レスポンスの本体を処理するための
478415データコールバックが提供された場合、これは空文字列の場合があります。
479416
480417=item *
481418
482419headers
483420
484421=begin original
485422
486423A hashref of header fields. All header field names will be normalized
487424to be lower case. If a header is repeated, the value will be an arrayref;
488425it will otherwise be a scalar string containing the value
489426
490427=end original
491428
492429ヘッダフィールドのハッシュリファレンス。
493430全てのフィールド名は小文字に正規化されます。
494431ヘッダが繰り返されている場合、値は配列リファレンスになります;
495432それ以外では値を含むスカラ文字列です。
496433
497434=back
498435
499436=begin original
500437
501438On an exception during the execution of the request, the C<status> field will
502439contain 599, and the C<content> field will contain the text of the exception.
503440
504441=end original
505442
506443リクエストの実行中の例外が起きたの場合、C<status> フィールドには 599 が入り、
507444C<content> フィールドに例外のテキストが入ります。
508445
509=head2 www_form_urlencode
510
511 $params = $http->www_form_urlencode( $data );
512 $response = $http->get("http://example.com/query?$params");
513
514=begin original
515
516This method converts the key/value pairs from a data hash or array reference
517into a C<x-www-form-urlencoded> string. The keys and values from the data
518reference will be UTF-8 encoded and escaped per RFC 3986. If a value is an
519array reference, the key will be repeated with each of the values of the array
520reference. The key/value pairs in the resulting string will be sorted by key
521and value.
522
523=end original
524
525This method converts the key/value pairs from a data hash or array reference
526into a C<x-www-form-urlencoded> string. The keys and values from the data
527reference will be UTF-8 encoded and escaped per RFC 3986. If a value is an
528array reference, the key will be repeated with each of the values of the array
529reference. The key/value pairs in the resulting string will be sorted by key
530and value.
531(TBT)
532
533446=for Pod::Coverage agent
534447default_headers
535448max_redirect
536449max_size
537450proxy
538451timeout
539452
540453=head1 LIMITATIONS
541454
542455=begin original
543456
544457HTTP::Tiny is I<conditionally compliant> with the
545458L<HTTP/1.1 specification|http://www.w3.org/Protocols/rfc2616/rfc2616.html>.
546459It attempts to meet all "MUST" requirements of the specification, but does not
547460implement all "SHOULD" requirements.
548461
549462=end original
550463
551464HTTP::Tiny は
552465L<HTTP/1.1 仕様|http://www.w3.org/Protocols/rfc2616/rfc2616.html> に
553466I<部分的に準拠> しています。
554467仕様の全ての "MUST" 要求に準拠しようとしていますが、
555468全ての "SHOULD" 要求は実装していません。
556469
557470=begin original
558471
559472Some particular limitations of note include:
560473
561474=end original
562475
563476注意するべきいくつかの制限は以下のものです:
564477
565478=over
566479
567480=item *
568481
569482=begin original
570483
571484HTTP::Tiny focuses on correct transport. Users are responsible for ensuring
572485that user-defined headers and content are compliant with the HTTP/1.1
573486specification.
574487
575488=end original
576489
577490HTTP::Tiny は正しい転送に注目しています。
578491ユーザはユーザ定義のヘッダと内容が HTTP/1.1 仕様に準拠することに
579492責任があります。
580493
581494=item *
582495
583496=begin original
584497
585498Users must ensure that URLs are properly escaped for unsafe characters and that
586499international domain names are properly encoded to ASCII. See L<URI::Escape>,
587500L<URI::_punycode> and L<Net::IDN::Encode>.
588501
589502=end original
590503
591504ユーザは、URL に対して安全でない文字がエスケープされ、国際ドメイン名が
592505適切に ASCII にエンコードされるようにしなければなりません。
593506L<URI::Escape>, L<URI::_punycode>, L<Net::IDN::Encode> を参照してください。
594507
595508=item *
596509
597510=begin original
598511
599512Redirection is very strict against the specification. Redirection is only
600513automatic for response codes 301, 302 and 307 if the request method is 'GET' or
601514'HEAD'. Response code 303 is always converted into a 'GET' redirection, as
602515mandated by the specification. There is no automatic support for status 305
603516("Use proxy") redirections.
604517
605518=end original
606519
607520リダイレクトは仕様に対して非常に厳密です。
608521リダイレクトは、リクエストメソッドが 'GET' または 'HEAD' の場合、
609522レスポンスコード 301, 302, 307 の場合にのみ自動的に行われます。
610523レスポンスコード 303 は、仕様で指定されている通り、
611524常に 'GET' リダイレクトに変換されます。
612525ステータス 305 ("Use proxy") リダイレクトの自動対応はしていません。
613526
614527=item *
615528
616529=begin original
617530
618Persistent connections are not supported. The C<Connection> header will
531Persistant connections are not supported. The C<Connection> header will
619532always be set to C<close>.
620533
621534=end original
622535
623536永続接続は対応していません。
624537C<Connection> ヘッダは常に C<close> に設定されています。
625538
626539=item *
627540
628541=begin original
629542
630543Direct C<https> connections are supported only if L<IO::Socket::SSL> is
631544installed. There is no support for C<https> connections via proxy.
632545Any SSL certificate that matches the host is accepted -- SSL certificates
633546are not verified against certificate authorities.
634547
635548=end original
636549
637550直接 C<https> 接続は、L<IO::Socket::SSL> が
638551インストールされている場合にのみ対応します。
639552プロキシ経由の C<https> 接続は対応していません。
640553ホストにマッチングする全ての SSL 証明書は受け入れられます --
641554SSL 証明書の認証局への検証は行われません。
642555
643556=item *
644557
645558=begin original
646559
647560Cookies are not directly supported. Users that set a C<Cookie> header
648561should also set C<max_redirect> to zero to ensure cookies are not
649562inappropriately re-transmitted.
650563
651564=end original
652565
653566クッキーは直接対応していません。
654567C<Cookie> ヘッダを設定するユーザは、
655568クッキーが不適切に再送信されないように C<max_redirect> をゼロに
656569設定するべきです。
657570
658571=item *
659572
660573=begin original
661574
662Only the C<http_proxy> environment variable is supported in the format
575Proxy environment variables are not supported.
663C<http://HOST:PORT/>. If a C<proxy> argument is passed to C<new> (including
664undef), then the C<http_proxy> environment variable is ignored.
665576
666577=end original
667578
668C<http_proxy> 環境変数は C<http://HOST:PORT/> 型式にのみ対応しま
579プロキシ環境変数は対応していせん
669(undef でも) C<proxy> 引数が C<new> に渡されると、
670C<http_proxy> 環境変数は無視されます。
671580
672581=item *
673582
674583=begin original
675584
676585There is no provision for delaying a request body using an C<Expect> header.
677586Unexpected C<1XX> responses are silently ignored as per the specification.
678587
679588=end original
680589
681590C<Expect> ヘッダを使ったリクエストボディの遅延には対応していません。
682591想定外のC<1XX> レスポンスは、仕様通り暗黙に無視されます。
683592
684593=item *
685594
686595=begin original
687596
688597Only 'chunked' C<Transfer-Encoding> is supported.
689598
690599=end original
691600
692601'chunked' C<Transfer-Encoding> のみに対応しています。
693602
694603=item *
695604
696605=begin original
697606
698607There is no support for a Request-URI of '*' for the 'OPTIONS' request.
699608
700609=end original
701610
702611'OPTIONS' リクエストで Request-URI に '*' を指定するのには対応していません。
703612
704613=back
705614
706615=head1 SEE ALSO
707616
708617=over 4
709618
710619=item *
711620
712621L<LWP::UserAgent>
713622
714623=back
715624
716625=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders
717626
718627=head1 SUPPORT
719628
720629(サポート)
721630
722631=head2 Bugs / Feature Requests
723632
724633(バグ / 機能リクエスト)
725634
726635=begin original
727636
728Please report any bugs or feature requests through the issue tracker
637Please report any bugs or feature requests by email to C<bug-http-tiny at rt.cpan.org>, or through
729at L<http://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Tiny>.
638the web interface at L<http://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Tiny>. You will be automatically notified of any
730You will be notified automatically of any progress on your issue.
639progress on the request by the system.
731640
732641=end original
733642
734643バグや機能リクエストについては、
644C<bug-http-tiny at rt.cpan.org> へのメールか、
735645L<http://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Tiny> の
736シュトラッカーを使って報告してください。
646web ンタフェを使って報告してください。
737イシューになんらかの進展があれば自動的に通知されます。
647リクエストになんらかの進展があればシステムによって自動的に通知されます。
738648
739649=head2 Source Code
740650
741651=begin original
742652
743653This is open source software. The code repository is available for
744654public review and contribution under the terms of the license.
745655
746656=end original
747657
748658これはオープンソースソフトウェアです。
749659コードリポジトリはライセンスの元で公式レビューおよび貢献のために利用可能です。
750660
751L<https://github.com/dagolden/p5-http-tiny>
661L<http://github.com/dagolden/p5-http-tiny/tree>
752662
753 git clone https://github.com/dagolden/p5-http-tiny.git
663 git clone git://github.com/dagolden/p5-http-tiny.git
754664
755665=head1 AUTHORS
756666
757667=over 4
758668
759669=item *
760670
761671Christian Hansen <chansen@cpan.org>
762672
763673=item *
764674
765675David Golden <dagolden@cpan.org>
766676
767677=back
768678
769679=head1 COPYRIGHT AND LICENSE
770680
771This software is copyright (c) 2012 by Christian Hansen.
681This software is copyright (c) 2011 by Christian Hansen.
772682
773683This is free software; you can redistribute it and/or modify it under
774684the same terms as the Perl 5 programming language system itself.
775685
776=cut
777
778686=begin meta
779687
780688Translate: SHIRAKATA Kentaro <argrath@ub32.org>
781Status: in progress
689Status: completed
782690
783691=end meta
692
693=cut