ktats****@users*****
ktats****@users*****
2013年 11月 18日 (月) 11:14:29 JST
Index: docs/modules/Furl-3.00/lib/Furl.pod diff -u /dev/null docs/modules/Furl-3.00/lib/Furl.pod:1.1 --- /dev/null Mon Nov 18 11:14:29 2013 +++ docs/modules/Furl-3.00/lib/Furl.pod Mon Nov 18 11:14:29 2013 @@ -0,0 +1,579 @@ +=encoding utf-8 + +=head1 åå + +=begin original + +Furl - Lightning-fast URL fetcher + +=end original + +Furl - 軽éã§éã URL fecher + +=head1 æ¦è¦ + + use Furl; + + my $furl = Furl->new( + agent => 'MyGreatUA/2.0', + timeout => 10, + ); + + my $res = $furl->get('http://example.com/'); + die $res->status_line unless $res->is_success; + print $res->content; + + my $res = $furl->post( + 'http://example.com/', # URL + [...], # headers + [ foo => 'bar' ], # form data (HashRef/FileHandle are also okay) + ); + + # Accept-Encoding is supported but optional + $furl = Furl->new( + headers => [ 'Accept-Encoding' => 'gzip' ], + ); + my $body = $furl->get('http://example.com/some/compressed'); + +=head1 説æ + +=begin original + +Furl is yet another HTTP client library. LWP is the de facto standard HTTP +client for Perl 5, but it is too slow for some critical jobs, and too complex +for weekend hacking. Furl resolves these issues. Enjoy it! + +=end original + +Furl ã¯ããä¸ã¤ã® HTTP ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªã§ããLWP 㯠Perl 5 ã®ããã¡ã¯ãã¹ã¿ã³ãã¼ã㪠+HTTP ã¯ã©ã¤ã¢ã³ãã§ãããã¯ãªãã£ã«ã«ãªã¸ã§ãã§ã¯é ããã¾ãããé±æ«ã®ãããã³ã°ã«ã¯ +è¤ééãã¾ããFurl ã¯ãããã®åé¡ã解決ãã¾ãã楽ããã§ä¸ããï¼ + + +=head1 INTERFACE + +(ã¤ã³ã¿ã¼ãã§ã¼ã¹) + +=head2 Class Methods + +(ã¯ã©ã¹ã¡ã½ãã) + +=head3 C<< Furl->new(%args | \%args) :Furl >> + +=begin original + +Creates and returns a new Furl client with I<%args>. Dies on errors. + +=end original + +I<%args> ã§æ°ãã Furl ã¯ã©ã¤ã¢ã³ããä½ãã¾ããã¨ã©ã¼ãããã°æ»ã«ã¾ãã + +=begin original + +I<%args> might be: + +=end original + +I<%args> ã¯: + +=over + +=item agent :Str = "Furl/$VERSION" + +=item timeout :Int = 10 + +=item max_redirects :Int = 7 + +=item capture_request :Bool = false + +=begin original + +If this parameter is true, L<Furl::HTTP> captures raw request string. +You can get it by C<< $res->captured_req_headers >> and C<< $res->captured_req_content >>. + +=end original + +ãã®ãã©ã¡ã¼ã¿ãçãªããL<Furl::HTTP> ã¯çã®ãªã¯ã¨ã¹ãæååããã£ããã£ãã¾ãã +C<< $res->captured_req_headers >> 㨠C<< $res->captured_req_content >> ã§ãã£ããã£ãããã®ãåå¾ã§ãã¾ãã + +=item proxy :Str + +=item no_proxy :Str + +=item headers :ArrayRef + +=back + +=head2 Instance Methods + +(ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã) + +=head3 C<< $furl->request([$request,] %args) :Furl::Response >> + +=begin original + +Sends an HTTP request to a specified URL and returns a instance of L<Furl::Response>. + +=end original + +HTTPãªã¯ã¨ã¹ããæå®ã®URLã«éããL<Furl::Response>ã®ã¤ã³ã¹ã¿ã³ã¹ãè¿ãã¾ãã + +=begin original + +I<%args> might be: + +=end original + +I<%args> ã¯: + +=over + +=item scheme :Str = "http" + +=begin original + +Protocol scheme. May be C<http> or C<https>. + +=end original + +ãããã³ãã¹ãã¼ããC<http> ã C<https> ã§ãããã + +=item host :Str + +=begin original + +Server host to connect. + +=end original + +æ¥ç¶ãããµã¼ããã¹ãã + +=begin original + +You must specify at least C<host> or C<url>. + +=end original + +C<host> ã C<url>ã®ãããããæå®ããªããã°ããã¾ããã + +=item port :Int = 80 + +=begin original + +Server port to connect. The default is 80 on C<< scheme => 'http' >>, +or 443 on C<< scheme => 'https' >>. + +=end original + +æ¥ç¶ãããµã¼ãã®ãã¼ããããã©ã«ãã¯ãC<< schema => 'http' >>ãªã80ã§ã +C<< scheme => 'https' >>ãªãã443ã§ãã + +=item path_query :Str = "/" + +=begin original + +Path and query to request. + +=end original + +ãªã¯ã¨ã¹ããããã¹ã¨ã¯ã¨ãªã + +=item url :Str + +=begin original + +URL to request. + +=end original + +ãªã¯ã¨ã¹ãããURLã + +=begin original + +You can use C<url> instead of C<scheme>, C<host>, C<port> and C<path_query>. + +=end original + +C<schema>ãC<host>ãC<port>ãC<path_query>ãæå®ãã代ããã«C<url>ã使ãã¾ãã + +=item headers :ArrayRef + +=begin original + +HTTP request headers. e.g. C<< headers => [ 'Accept-Encoding' => 'gzip' ] >>. + +=end original + +HTTPãªã¯ã¨ã¹ãããããä¾ C<< headers => [ 'Accept-Encoding' => 'gzip' ] >>. + +=item content : Str | ArrayRef[Str] | HashRef[Str] | FileHandle + +=begin original + +Content to request. + +=end original + +ãªã¯ã¨ã¹ãããå 容ã + +=back + +=begin original + +If the number of arguments is an odd number, this method assumes that the +first argument is an instance of C<HTTP::Request>. Remaining arguments +can be any of the previously describe values (but currently there's no +way to really utilize them, so don't use it) + +=end original + +å¼æ°ã®æ°ãå¥æ°ã®å ´åããã®ã¡ã½ããã¯æåã®å¼æ°ã C<HTTP::Request>ã®ã¤ã³ã¹ã¿ã³ã¹ã¨ +æ³å®ãã¾ããæ®ãã®å¼æ°ã¯å ã«èª¬æãããããã®å¤ãåãã¾ã(ã§ãããä»ã®æ, +ãããã®å¤ã¯å®éã«ã¯å½¹ã«ãã¡ã¾ãããã§ãã®ã§ã使ããªãã§ä¸ãã)ã + + my $req = HTTP::Request->new(...); + my $res = $furl->request($req); + +=begin original + +You can also specify an object other than HTTP::Request (e.g. Furl::Request), +but the object must implement the following methods: + +=end original + +HTTP::Request以å¤ã®ãªãã¸ã§ã¯ã(e.g. Furl::Request)ãæå®ã§ãã¾ããã +æå®ãããªãã¸ã§ã¯ãã¯ä»¥ä¸ã®ã¡ã½ãããå®è£ ãã¦ããªãã¦ã¯ããã¾ããã + +=over 4 + +=item uri + +=item method + +=item content + +=item headers + +=back + +=begin original + +These must return the same type of values as their counterparts in +C<HTTP::Request>. + +=end original + +C<HTTP::Request>ã«ããã¡ã½ããã¨åãã¿ã¤ãã®å¤ãè¿ããªãã¦ã¯è¡ãã¾ããã + +=begin original + +You must encode all the queries or this method will die, saying +C<Wide character in ...>. + +=end original + +ãã¹ã¦ã®ã¯ã¨ãªãã¨ã³ã³ã¼ãããå¿ è¦ãããã¾ãããããªãã°ãC<Wide character in ...> +ãåãã¦æ»ã«ã¾ãã + +=head3 C<< $furl->get($url :Str, $headers :ArrayRef[Str] ) >> + +=begin original + +This is an easy-to-use alias to C<request()>, sending the C<GET> method. + +=end original + +C<request()>ç°¡åã«ä½¿ãããã®ã¨ã¤ãªã¢ã¹ã§ããC<GET>ã¡ã½ãããéãã¾ãã + +=head3 C<< $furl->head($url :Str, $headers :ArrayRef[Str] ) >> + +=begin original + +This is an easy-to-use alias to C<request()>, sending the C<HEAD> method. + +=end original + +C<request()>ç°¡åã«ä½¿ãããã®ã¨ã¤ãªã¢ã¹ã§ããC<HED>ã¡ã½ãããéãã¾ãã + +=head3 C<< $furl->post($url :Str, $headers :ArrayRef[Str], $content :Any) >> + +=begin original + +This is an easy-to-use alias to C<request()>, sending the C<POST> method. + +=end original + +C<request()>ç°¡åã«ä½¿ãããã®ã¨ã¤ãªã¢ã¹ã§ããC<POST>ã¡ã½ãããéãã¾ãã + +=head3 C<< $furl->put($url :Str, $headers :ArrayRef[Str], $content :Any) >> + +=begin original + +This is an easy-to-use alias to C<request()>, sending the C<PUT> method. + +=end original + +C<request()>ç°¡åã«ä½¿ãããã®ã¨ã¤ãªã¢ã¹ã§ããC<PUT>ã¡ã½ãããéãã¾ãã + +=head3 C<< $furl->delete($url :Str, $headers :ArrayRef[Str] ) >> + +=begin original + +This is an easy-to-use alias to C<request()>, sending the C<DELETE> method. + +=end original + +C<request()>ç°¡åã«ä½¿ãããã®ã¨ã¤ãªã¢ã¹ã§ããC<DELETE>ã¡ã½ãããéãã¾ãã + +=head3 C<< $furl->env_proxy() >> + +=begin original + +Loads proxy settings from C<< $ENV{HTTP_PROXY} >> and C<< $ENV{NO_PROXY} >>. + +=end original + +C<< $ENV{HTTP_PROXY} >> 㨠C<< $ENV{NO_PROXY} >> ãããããã·è¨å®ãèªã¿ãã¿ã¾ãã + +=head1 FAQ + +=over 4 + +=item Furlã¯XSã¢ã¸ã¥ã¼ã«ã«ä¾åãã¾ããï¼ + +=begin original + +(Does Furl depends on XS modules?) + +=end original + +=begin original + +No. Although some optional features require XS modules, basic features are +available without XS modules. + +=end original + +ããããããã¤ãã®ãªãã·ã§ãã«ãªæ©è½ã¯XSã¢ã¸ã¥ã¼ã«ãå¿ è¦ã¨ãã¾ããã +åºæ¬çãªæ©è½ã¯XSã¢ã¸ã¥ã¼ã«ãªãã«ä½¿ãã¾ãã + +=begin original + +Note that Furl requires HTTP::Parser::XS, which seems an XS module +but includes a pure Perl backend, HTTP::Parser::XS::PP. + +=end original + +Furlã¯HTTP::Parser::XSãå¿ è¦ã¨ãã¾ããããã¯XSã¢ã¸ã¥ã¼ã«ã®ããã§ããã +pure Perlã®ããã¯ã¨ã³ãã§ããHTTP::Parser::XS::PPãå«ãã§ãã¾ãã + +=item ãã£ã¨ã¹ãã¼ããå¿ è¦ã§ãã + +=begin original + +(I need more speed.) + +=end original + +=begin original + +See L<Furl::HTTP>, which provides the low level interface of L<Furl>. +It is faster than C<Furl.pm> since L<Furl::HTTP> does not create response objects. + +=end original + +L<Furl::HTTP> ãè¦ã¦ãã ãããL<Furl>ã®ä½ã¬ãã«ã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãæä¾ãã¦ãã¾ãã +L<Furl::HTTP>ã¯ã¬ã¹ãã³ã¹ãªãã¸ã§ã¯ããä½ããªãã®ã§C<Furl.pm>ããéãã§ãã + +=item cookie_jar ã使ãã«ã¯? + +=begin original + +(How do you use cookie_jar?) + +=end original + +=begin original + +Furl does not directly support the cookie_jar option available in LWP. You can use L<HTTP::Cookies>, L<HTTP::Request>, L<HTTP::Response> like following. + +=end original + +Furl ã¯LWPã§ä½¿ããcookie_jarãªãã·ã§ã³ãç´æ¥ã«ã¯ãµãã¼ããã¾ããã L<HTTP::Cookies>ã L<HTTP::Request>ã L<HTTP::Response>ã使ã£ã¦ +以ä¸ã®ããã«ã§ãã¾ãã + + + my $f = Furl->new(); + my $cookies = HTTP::Cookies->new(); + my $req = HTTP::Request->new(...); + $cookies->add_cookie_header($req); + my $res = H$f->request_with_http_request($req)->as_http_response; + $res->request($req); + $cookies->extract_cookies($res); + # and use $res. + +=item ã³ã³ãã³ãã¬ã³ã°ã¹ãã©ã®ããã«å¶éã§ãã¾ãã? + +=begin original + +(How do you limit the response content length?) + +=end original + +=begin original + +You can limit the content length by callback function. + +=end original + +ã³ã¼ã«ããã¯é¢æ°ã使ã£ã¦ã³ã³ãã³ãã¬ã³ã°ã¹ãå¶éã§ãã¾ãã + + my $f = Furl->new(); + my $content = ''; + my $limit = 1_000_000; + my %special_headers = ('content-length' => undef); + my $res = $f->request( + method => 'GET', + url => $url, + special_headers => \%special_headers, + write_code => sub { + my ( $status, $msg, $headers, $buf ) = @_; + if (($special_headers{'content-length'}||0) > $limit || length($content) > $limit) { + die "over limit: $limit"; + } + $content .= $buf; + } + ); + +=item ããã°ã¬ã¹ãã¼ã表示ã§ãã¾ãã? + +=begin original + +(How do you display the progress bar?) + +=end original + + my $bar = Term::ProgressBar->new({count => 1024, ETA => 'linear'}); + $bar->minor(0); + $bar->max_update_rate(1); + + my $f = Furl->new(); + my $content = ''; + my %special_headers = ('content-length' => undef);; + my $did_set_target = 0; + my $received_size = 0; + my $next_update = 0; + $f->request( + method => 'GET', + url => $url, + special_headers => \%special_headers, + write_code => sub { + my ( $status, $msg, $headers, $buf ) = @_; + unless ($did_set_target) { + if ( my $cl = $special_headers{'content-length'} ) { + $bar->target($cl); + $did_set_target++; + } + else { + $bar->target( $received_size + 2 * length($buf) ); + } + } + $received_size += length($buf); + $content .= $buf; + $next_update = $bar->update($received_size) + if $received_size >= $next_update; + } + ); + +=item HTTPS ãªã¯ã¨ã¹ããè¦åã表示ãã + +=begin original + +(HTTPS requests claims warnings!) + +=end original + +=begin original + +When you make https requests, IO::Socket::SSL may complain about it like: + +=end original + +https ãªã¯ã¨ã¹ããããã¨ãã«ã IO::Socket::SSL ã次ã®yãããªè¦åãããããããã¾ãã: + + ******************************************************************* + Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client + is depreciated! Please set SSL_verify_mode to SSL_VERIFY_PEER + together with SSL_ca_file|SSL_ca_path for verification. + If you really don't want to verify the certificate and keep the + connection open to Man-In-The-Middle attacks please set + SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application. + ******************************************************************* + +=begin original + +You should set C<SSL_verify_mode> explicitly with Furl's C<ssl_opts>. + +=end original + +C<SSL_verify_mode> ãæ示çã«ãFurlã® C<ssl_opts> ã«ã»ãããã¹ãã§ãã + + use IO::Socket::SSL; + + my $ua = Furl->new( + ssl_opts => { + SSL_verify_mode => SSL_VERIFY_PEER(), + }, + }); + +=begin original + +See L<IO::Socket::SSL> for details. + +=end original + +詳細ã¯ãL<IO::Socket::SSL>ãè¦ã¦ãã ããã + +=back + +=head1 èè + +Tokuhiro Matsuno E<lt>tokuh****@gmail*****<gt> +Fuji, Goro (gfx) + +=head1 è¬è¾ + +Kazuho Oku + +mala + +mattn + +lestrrat + +walf443 + +lestrrat + +audreyt + +=head1 åç § + +L<LWP> + +L<IO::Socket::SSL> + +L<Furl::HTTP> + +L<Furl::Response> + +=head1 ã©ã¤ã»ã³ã¹ + +Copyright (C) Tokuhiro Matsuno. + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + + +=cut +