ktats****@users*****
ktats****@users*****
2013年 11月 18日 (月) 11:14:29 JST
Index: docs/modules/Furl-3.00/lib/Furl/HTTP.pod diff -u /dev/null docs/modules/Furl-3.00/lib/Furl/HTTP.pod:1.1 --- /dev/null Mon Nov 18 11:14:29 2013 +++ docs/modules/Furl-3.00/lib/Furl/HTTP.pod Mon Nov 18 11:14:29 2013 @@ -0,0 +1,879 @@ +=encoding utf-8 + +=for stopwords sockaddr + +=head1 NAME + +=begin original + +Furl::HTTP - Low level interface to Furl + +=end original + +Furl::HTTP - Furlã®ä½ã¬ãã«ã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ + +=head1 æ¦è¦ + + use Furl; + + my $furl = Furl::HTTP->new( + agent => 'MyGreatUA/2.0', + timeout => 10, + ); + + my ($minor_version, $code, $msg, $headers, $body) = $furl->request( + method => 'GET', + host => 'example.com', + port => 80, + path_query => '/' + ); + # or + + # 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::HTTP->new(%args | \%args) :Furl >> + +=begin original + +Creates and returns a new Furl client with I<%args>. Dies on errors. + +=end original + +æ°ããFurlã¯ã©ã¤ã¢ã³ããI<%args>ã§ä½ãã¾ããã¨ã©ã¼ãããã¨æ»ã«ã¾ãã + +=begin original + +I<%args> might be: + +=end original + +I<%args> ã¯: + +=over + +=item agent :Str = "Furl/$VERSION" + +=item timeout :Int = 10 + +=begin original + +Seconds until the call to $furl->request returns a timeout error (as an internally generated 500 error). The timeout might not be accurate since some underlying modules / built-ins function may block longer than the specified timeout. See the FAQ for how to support timeout during name resolution. + +=end original + +$furl->request ã®å¼åºãã¿ã¤ã ã¢ã¦ãã¨ã©ã¼ãè¿ãã¾ã§ã®ç§æ°(å é¨çã«500ã¨ã©ã¼)ãåºç¤ã¨ãªãã¢ã¸ã¥ã¼ã«/çµè¾¼ã®é¢æ°ãæå®ã®æéããé·ããããã¯ãããããããªãã®ã§ãã¿ã¤ã ã¢ã¦ãã¯æ£ç¢ºã§ã¯ãªããããããã¾ãããåå解決æã®ã¿ã¤ã ã¢ã¦ããµãã¼ãããæ¹æ³ã¯FAQãè¦ã¦ãã ããã + +=item inactivity_timeout :Int = 600 + +=begin original + +An inactivity timer for TCP read/write (in seconds). $furl->request returns a timeout error if no additional data arrives (or is sent) within the specified threshold. + +=end original + +TCP èªã¿/æ¸ãã®ããã®ãéã¢ã¯ãã£ãã¿ã¤ãã¼ã§ã(ç§å )ã$furl->request ã¯ã追å ã®ãã¼ã¿ããæå®ã®ãããå¤å ã«ãã¼ã¿ãæ¥ãªã(ãéãããªã)ãªããã¿ã¤ã ã¢ã¦ãã¨ã©ã¼ãè¿ãã¾ãã + +=item max_redirects :Int = 7 + +=item proxy :Str + +=item no_proxy :Str + +=item headers :ArrayRef + +=item header_format :Int = HEADERS_AS_ARRAYREF + +=begin original + +This option choose return value format of C<< $furl->request >>. + +=end original + +ãã®ãªãã·ã§ã³ã§ã¯C<<$furl->request>>ã®è¿ãå¤ã®ãã©ã¼ããããé¸ã³ã¾ãã + +=begin original + +This option allows HEADERS_NONE or HEADERS_AS_ARRAYREF. + +=end original + +HEADERS_NONE ã HEADERS_AS_ARRAYREF ã使ãã¾ãã + +=begin original + +B<HEADERS_AS_ARRAYREF> is a default value. This makes B<$headers> as ArrayRef. + +=end original + +B<HEADERS_AS_ARRAYREF>> ã¯ããã©ã«ãå¤ã§ããB<$headers>ãArrayRefã¨ãã¦ä½ãã¾ãã + +=begin original + +B<HEADERS_NONE> makes B<$headers> as undef. Furl does not return parsing result of headers. You should take needed headers from B<special_headers>. + +=end original + +B<HEADERS_NONE> B<$headers> ã undef ã«ãã¾ããFurlãããã解æããçµæãè¿ãã¾ããã B<special_headers>ããå¿ è¦ãªãããåãã¨ãã¹ãã§ãã + +=item connection_pool :Object + +=begin original + +This is the connection pool object for keep-alive requests. By default, it is a instance of L<Furl::ConnectionCache>. + +=end original + +keep-aliveãªã¯ã¨ã¹ãç¨ã®ã³ãã¯ã·ã§ã³ãã¼ã«ãªãã¸ã§ã¯ãã§ããããã©ã«ãã§ã¯L<Furl::ConnectionCache>ã®ã¤ã³ã¹ã¿ã³ã¹ã§ãã + +=begin original + +You may not customize this variable otherwise to use L<Coro>. This attribute requires a duck type object. It has two methods, C<< $obj->steal($host, $port >> and C<< $obj->push($host, $port, $sock) >>. + +=end original + +L<Coro> ã使ã以å¤ã®æ¹æ³ã§ãã®å¤ãã«ã¹ã¿ãã¤ãºã§ããªãã§ãããããã®ã¢ããªãã¥ã¼ãã¯ããã¯ã¿ã¤ããªãã¸ã§ã¯ããå¿ è¦ã¨ãã¾ãã2ã¤ã®ã¡ã½ãããC<< $obj->steal($host, $port >> 㨠C<< $obj->push($host, $port, $sock) >> ãããã¾ãã + +=item stop_if :CodeRef + +=begin original + +A callback function that is called by Furl after when a blocking function call returns EINTR. Furl will abort the HTTP request and return immediately if the callback returns true. Otherwise the operation is continued (the default behaviour). + +=end original + +ããããã³ã°é¢æ°ãEINTRãå¼ãã å¾ã«Furlãå¼ã¶ã³ã¼ã«ããã¯é¢æ°ã§ããã³ã¼ã«ããã¯ãçãªããFurlã¯HTTPãªã¯ã¨ã¹ããä¸æããå³åº§ã«æ»ãã¾ããããã§ãªããã°ããªãã¬ã¼ã·ã§ã³ã¯ç¶è¡ããã¾ã(ããã©ã«ãã®æå)ã + +=item get_address :CodeRef + +=begin original + +=begin original + +A callback function to override the default address resolution logic. Takes three arguments: ($hostname, $port, $timeout_in_seconds) and returns: ($sockaddr, $errReason). If the returned $sockaddr is undef, then the resolution is considered as a failure and $errReason is propagated to the caller. + +=end original + +ããã©ã«ãã®ã¢ãã¬ã¹è§£æ±ºãã¸ãã¯ãä¸æ¸ãããã³ã¼ã«ããã¯é¢æ°ã§ãã3ã¤ã®å¼æ°ãåãã¾ã: ($hostname, $port, $timeout_in_seconds) ããã¦ãæ»ãå¤ã¯: ($socketaddrã$errReason)ãè¿ããã $socketaddr ã undef ã§ããã°ã解決ã¯å¤±æã¨ãã¦èãããã$errReason ãå¼ã³åºãå ã«åºãããã¾ãã + +=end original + +=item inet_aton :CodeRef + +=begin original + +Deprecated. New applications should use B<get_address> instead. + +=end original + +å»æ¢ãæ°ããã¢ããªã±ã¼ã·ã§ã³ã¯ B<get_address> ã代ããã«ä½¿ãã¹ãã§ãã + +=begin original + +A callback function to customize name resolution. Takes two arguments: ($hostname, $timeout_in_seconds). If omitted, Furl calls L<Socket::inet_aton>. + +=end original + +åå解決ãã«ã¹ã¿ãã¤ãºããããã®ã³ã¼ã«ããã¯é¢æ°ã§ãã2ã¤ã®å¼æ°ãåãã¾ã: ($hostname, $timeout_in_seconds)ãçç¥ããã¨ãFurlã¯L<Socket::inet_aton>ãå¼ã³ã¾ãã + +=item ssl_opts :HashRef + +=begin original + +SSL configuration used on https requests, passed directly to C<< IO::Socket::SSL->new() >>, + +=end original + +https ãªã¯ã¨ã¹ãã§ä½¿ãããSSLè¨å®ã§ããC<< IO::Socket::SSL->new() >>ã«ç´æ¥æ¸¡ããã¾ãã + +=begin original + +for example: + +=end original + +ä¾: + + use IO::Socket::SSL; + + my $ua = Furl::HTTP->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 + +=head2 Instance Methods + +(ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã) + +=head3 C<< $furl->request(%args) :($protocol_minor_version, $code, $msg, \@headers, $body) >> + +=begin original + +Sends an HTTP request to a specified URL and returns a protocol minor version, +status code, status message, response headers, response body respectively. + +=end original + +HTTPãªã¯ã¨ã¹ããæå®ããURLã¸éãããããã³ã«ã®ãã¤ãã¼ãã¼ã¸ã§ã³ãã¹ãã¼ã¿ã¹ã³ã¼ãã +ã¹ãã¼ã¿ã¼ã¹ã¡ãã»ã¼ã¸ãã¬ã¹ãã³ã¹ãããã¼ãã¬ã¹ãã³ã¹ããã£ã¼ãããããè¿ãã¾ãã + +=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 + +ãªã¯ã¨ã¹ãããå 容ã + +=item write_file : FileHandle + +=begin original + +If this parameter is set, the response content will be saved here instead of in the response object. + +=end original + +ãã®ãã©ã¡ã¼ã¿ãã»ããããã¦ããã¨ãã¬ã¹ãã³ã¹ã®å 容ã¯ã¬ã¹ãã³ã¹ãªãã¸ã§ã¯ãã§ã¯ãªãæå®ããããã¡ã¤ã«ãã³ãã« +ã«ä¿åããã¾ãã + +=begin original + +It's like a C<:content_file> in L<LWP::UserAgent>. + +=end original + +L<LWP::UserAgent>ã®C<:content_file>ã¨ä¼¼ã¦ãã¾ãã + +=item write_code : CodeRef + +=begin original + +If a callback is provided with the "write_code" option +then this function will be called for each chunk of the response +content as it is received from the server. + +=end original + +"write_code"ãªãã·ã§ã³ã§ã³ã¼ã«ããã¯ãæå®ããå ´åã +ãã®é¢æ°ã¯ããµã¼ãããåãåãã¬ã¹ãã³ã¹ã®å 容ã®ãã£ã³ã¯æ¯ã«å¼ã°ãã¾ãã + +=begin original + +It's like a C<:content_cb> in L<LWP::UserAgent>. + +=end original + +L<LWP::UserAgent>ã®<:content_cb>ã¨ä¼¼ã¦ãã¾ãã + +=back + +=begin original + +The C<request()> method assumes the first argument to be an instance +of C<HTTP::Request> if the arguments are an odd number: + +=end original + +C<response()> ã¡ã½ããã¯å¼æ°ãå¥æ°ã®å ´åãæåã®å¼æ°ãC<HTTP::Request>ã®ã¤ã³ã¹ã¿ã³ã¹ã¨æ³å®ãã¾ãã + + my $req = HTTP::Request->new(...); + my @res = $furl->request($req); # allowed + +=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>ã¡ã½ãããéãã¾ãã + +=head1 FAQ + +=over 4 + +=item ã©ãã㦠IO::Socket::SSL? + +=begin original + +(Why IO::Socket::SSL?) + +=end original + +=begin original + +Net::SSL is not well documented. + +=end original + +Net::SSL ã¯ããã¥ã¡ã³ãã貧弱ã§ãã + +=item env_proxy ã¯ãªããªãã·ã§ãã«ãªã®ã§ãã? + +=begin original + +(Why is env_proxy optional?) + +=end original + +=begin original + +Environment variables are highly dependent on each users' environment, +and we think it may confuse users when something doesn't go right. + +=end original + +ç°å¢å¤æ°ã¯ã¦ã¼ã¶ã¼ã®ç°å¢ã«å¼·ãä¾åãã¾ãã +ãã¾ãåããªãã¨ãã«ã¦ã¼ã¶ã¼ãæ··ä¹±ããã¾ãã + +=item ãµãã¼ããã¦ãããªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã¯? + +=begin original + +(What operating systems are supported?) + +=end original + +=begin original + +Linux 2.6 or higher, OSX Tiger or higher, Windows XP or higher. + +=end original + +Linux 2.6 以ä¸ã OSX Tiger 以ä¸ã Windows XP 以ä¸ã + +=begin original + +And other operating systems will be supported if you send a patch. + +=end original + +ããªããããããéãã°ãä»ã®ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ããµãã¼ããããã§ãããã + +=item ãªãFurlã¯ãã£ã³ã¯ãããã¢ãããã¼ãããµãã¼ãããªãã®ã§ãã? + +=begin original + +(Why doesn't Furl support chunked upload?) + +=end original + +=begin original + +There are reasons why chunked POST/PUTs should not be used in general. + +=end original + +ä¸è¬çã«ããã£ã³ã¯ãããPOST/PUTããªã使ãã¹ãã§ã¯ãªããã¨ããçç±ãããã¾ãã + +=begin original + +First, you cannot send chunked requests unless the peer server at the other end of the established TCP connection is known to be a HTTP/1.1 server. + +=end original + +ã¾ãã確ç«ãããTCPã®æ¥ç¶ã®ããä¸æ¹ã®çµç«¯ã®ãã¢ãµã¼ããHTTP/1.1ã®ãµã¼ãã¨ããã£ã¦ããªããã°ããã£ã³ã¯ããããªã¯ã¨ã¹ããéããã¨ãã§ãã¾ããã + +=begin original + +Second, HTTP/1.1 servers disconnect their persistent connection quite quickly (compared to the time they wait for the first request), so it is not a good idea to post non-idempotent requests (e.g. POST, PUT, etc.) as a succeeding request over persistent connections. + +=end original + +次ã«ãHTTP/1.1ã®ãµã¼ãã¯æ°¸ç¶çãªæ¥ç¶ãé常ã«éãåæãã¾ã(æåã®ãªã¯ã¨ã¹ããå¾ ã¤æéã«æ¯ã¹ã¦)ã +ãã®ãããæ°¸ç¶çãªæ¥ç¶è¶ãã«ãé£ç¶ãããªã¯ã¨ã¹ãã¨ãã¦ä¸å¤ã§ãªããªã¯ã¨ã¹ã(ä¾ POST,PUTãªã©)ããã¹ãããã®ã¯è¯ãããã¾ããã + +=begin original + +These facts together makes using chunked requests virtually impossible (unless you _know_ that the server supports HTTP/1.1), and this is why we decided that supporting the feature is NOT of high priority. + +=end original + +ãããã®è¦å ã§ãã£ã³ã¯ããããªã¯ã¨ã¹ãã使ãã®ã¯äºå®ä¸ä¸å¯è½ã§ã(ãµã¼ããHTTP/1.1ããµãã¼ããã¦ããã¨ããã£ã¦ããªããã°)ã +ãã®ããããã®æ©è½ã®ãµãã¼ãã¯é«ããã©ã¤ãªãªãã£ã§ã¯ããã¾ããã + +=item å°éããã¬ã¹ãã³ã¹ã®å 容ãã©ã®ããã«ä½ãã¾ãã? + +=begin original + +(How do you build the response content as it arrives?) + +=end original + +=begin original + +You can use L<IO::Callback> for this purpose. + +=end original + +ãã®ããã«L<IO::Callback>ã使ãã¾ãã + + my $fh = IO::Callback->new( + '<', + sub { + my $x = shift @data; + $x ? "-$x" : undef; + } + ); + my ( $code, $msg, $headers, $content ) = + $furl->put( "http://127.0.0.1:$port/", [ 'Content-Length' => $len ], $fh, + ); + +=item gzip/deflate å§ç¸®ãããã³ãã¥ãã±ã¼ã·ã§ã³ã使ãã¾ãã? + +=begin original + +(How do you use gzip/deflate compressed communication?) + +=end original + +=begin original + +Add an B<Accept-Encoding> header to your request. Furl inflates response bodies transparently according to the B<Content-Encoding> response header. + +<<<<<<< /home/ktat/cvs/perldocjp/docs/modules/Furl-0.31//lib/Furl/HTTP.pod +=end original + +B<Accept-Encoding>ãããããªã¯ã¨ã¹ãã«è¿½å ãã¦ãã ãããFurlã¬ã¹ãã³ã¹ããã£ã¼ãB<Content-Encoding>ã¬ã¹ãã³ã¹ãããã«å¾ã£ã¦ééçã«ã¤ã³ãã¬ã¼ããã¾ãã + +=item multipart/form-data ã使ãã«ã¯? + +=begin original + +(How do you use multipart/form-data?) + +=begin original + +You can use multipart/form-data with L<HTTP::Request::Common>. + +=end original + +L<HTTP::Request::Common>ã使ã£ã¦ãmultipart/form-dataã使ãã¾ãã + + use HTTP::Request::Common; + + my $furl = Furl->new(); + $req = POST 'http://www.perl.org/survey.cgi', + Content_Type => 'form-data', + Content => [ + name => 'Hiromu Tokunaga', + email => 'tokuh****@examp*****', + gender => 'F', + born => '1978', + init => ["$ENV{HOME}/.profile"], + ]; + $furl->request($req); + +=begin original + +Native multipart/form-data support for L<Furl> is available if you can send a patch for me. + +=end original + +ããããéããã¨ãã§ãããªããL<Furl>ã§ãã¤ãã£ãã®multipart/form-dataãµãã¼ãã¯å©ç¨å¯è½ã§ãã + +=item Kee-Alive ãã©ããã£ã¦ä½¿ãã®ãã¨HEADã¡ã½ããã§ã¯ä½ãèµ·ããã®ã? + +=begin original + +(How do you use Keep-Alive and what happens on the HEAD method?) + +=end original + +=begin original + +Furl supports HTTP/1.1, hence C<Keep-Alive>. However, if you use the HEAD +method, the connection is closed immediately. + +=end original + +Furlã¯HTTP/1.1ããµãã¼ããã¾ããå¾ã£ã¦ãC<Keep-Alive>ããµãã¼ããã¾ãã +ã§ãããHEADã¡ã½ããã§ä½¿ã£ã¦ããæ¥ç¶ã¯å³åº§ã«åæããã¾ãã + +=begin original + +RFC 2616 section 9.4 says: + +=end original + +RFC 2616 section 9.4 ã«ããã¨: + +=begin original + + The HEAD method is identical to GET except that the server MUST NOT + return a message-body in the response. + +=end original + + HEADã¡ã½ããã¯ããµã¼ããã¬ã¹ãã³ã¹ã«ã¡ãã»ã¼ã¸ããã£ãè¿ããã¦ã¯ãããªããã¨ã + é¤ãã¦ãGETã¡ã½ããã¨åä¸ã§ãã + +=begin original + +Some web applications, however, returns message bodies on the HEAD method, +which might confuse C<Keep-Alive> processes, so Furl closes connection in +such cases. + +=end original + +ã§ããWebã¢ããªã±ã¼ã·ã§ã³ã«ãã£ã¦ã¯ãHEADã¡ã½ããã§ã¡ãã»ã¼ã¸ããã£ã +è¿ããã¨ãããã¾ãããC<Kee-Alive>ããã»ã¹ãæ··ä¹±ããã¾ãããã®ããFurl +ã¯ãã®ãããªã±ã¼ã¹ã§ã¯æ¥ç¶ãéãã¾ãã + +=begin original + +Anyway, the HEAD method is not so useful nowadays. The GET method and +C<If-Modified-Sinse> are more suitable to cache HTTP contents. + +=end original + +ãããã«ãããHEADã¡ã½ããã¯ãä»æ¥ã§ã¯ããããªã«æç¨ã§ã¯ããã¾ãããGETã¡ã½ãã㨠+C<If-Modified-Sinse>ã®ã»ããHTTPã³ã³ãã³ãããã£ãã·ã¥ããã®ã«åã£ã¦ãã¾ãã + +=item ãªãFurlã¯ã¿ã¤ã ã¢ã¦ãã¨ã©ã¼ãè¿ãã¾ã§æå®ããé·ããããã®ã§ãã? + +=begin original + +(Why does Furl take longer than specified until it returns a timeout error?) + +=end original + +=begin original + +Although Furl itself supports timeout, some underlying modules / functions do not. And the most noticeable one is L<Socket::inet_aton>, the function used for name resolution (a function that converts host names to IP addresses). If you need accurate and short timeout for name resolution, the use of L<Net::DNS::Lite> is recommended. The following code snippet describes how to use the module in conjunction with Furl. + +=end original + +Furlèªèº«ã¯ã¿ã¤ã ã¢ã¦ãããµãã¼ããã¾ãããåºç¤çãªã¢ã¸ã¥ã¼ã«ãé¢æ°ã¯ãµãã¼ããã¾ããããã£ã¨ãé¡èãªä¾ã¨ãã¦ã¯ãL<Socket::inet_aton>ã§ãããã®é¢æ°ã¯åå解決(ãã¹ãã®ååããIPã¢ãã¬ã¹ã¸ã®å¤æ)ã«ä½¿ããã¦ãã¾ãã +ããåå解決ã«æ£ç¢ºã§çããã¿ã¤ã ã¢ã¦ããå¿ è¦ãªããL<Net::DNS::Lite>ããå§ããã¾ããä¸è¨ã®ã³ã¼ãã¹ããããã¯ãFurlã§ã©ã®ããã«ä½¿ããã説æãã¦ãã¾ãã + + use Net::DNS::Lite qw(); + + my $furl = Furl->new( + timeout => $my_timeout_in_seconds, + inet_aton => sub { Net::DNS::Lite::inet_aton(@_) }, + ); + +=item ãã¹ãåã®ä»£ããã«Hostããããç½®ãæããã«ã¯? + +=begin original + +How can I replace Host header instead of hostname? + +=end original + +=begin original + +Furl::HTTP does not provide a way to replace the Host header because such a design leads to security issues. + +=end original + +Furl::HTTP Hostããããç½®ãæããæ¹æ³ã¯æä¾ãã¦ãã¾ããããã®ãããªè¨è¨ã¯ãã»ãã¥ãªãã£ã«åé¡ãå¼ãèµ·ããããã§ãã + +=begin original + +If you want to send HTTP requests to a dedicated server (or a UNIX socket), you should use the B<get_address> callback to designate the peer to which L<Furl> should connect as B<sockaddr>. + +=end original + +HTTPãªã¯ã¨ã¹ããç¹å®ã®ãµã¼ã(ã UNIXã½ã±ãã)ã«ãªã¯ã¨ã¹ãããããªããL<Furl> 㯠B<socketaddr> ã¨ãã¦æ¥ç¶ãã¹ããã¢ãæå®ãããB<get_address>ã³ã¼ã«ããã¯ã使ãã¹ãã§ãã + +=begin original + +The example below sends all requests to 127.0.0.1:8080. + +=end original + +以ä¸ã®ä¾ã§ã¯ãå ¨ã¦ã®ãªã¯ã¨ã¹ãã 127.0.0.1:8080 ã«éãã¾ãã + + my $ua = Furl::HTTP->new( + get_address => sub { + my ($host, $port, $timeout) = @_; + sockaddr_in(8080, inet_aton("127.0.0.1")); + }, + ); + + my ($minor_version, $code, $msg, $headers, $body) = $furl->request( + url => 'http://example.com/foo', + method => 'GET' + ); + +=back + +=head1 TODO + + - AnyEvent::Furl? + - ipv6 support + - better docs for NO_PROXY + +=head1 ãªãã·ã§ãã«ãªæ©è½ + +=begin original + +=head2 Internationalized Domain Name (IDN) + +=end original + +=head2 å½éãã¡ã¤ã³å(IDN) + +=begin original + +This feature requires Net::IDN::Encode. + +=end original + +ãã®æ©è½ã¯ Net::IDN::Encode ãå¿ è¦ã§ãã + +=head2 SSL + +=begin original + +This feature requires IO::Socket::SSL. + +=end original + +ãã®æ©è½ã¯ IO::Socket::SSL ãå¿ è¦ã§ãã + +=head2 Content-Encoding (deflate, gzip) + +=begin original + +This feature requires Compress::Raw::Zlib. + +=end original + +ãã®æ©è½ã¯ Compress::Raw::Zlib ãå¿ è¦ã§ãã + +=head1 éçº + +=begin original + +To setup your environment: + +=end original + +ç°å¢ã®ã»ããã¢ãã: + + $ git clone http://github.com/tokuhirom/p5-Furl.git + $ cd p5-Furl + +=begin original + +To get picohttpparser: + +=end original + +picohttpparser ã®åå¾: + + $ git submodule init + $ git submodule update + + $ perl Makefile.PL + $ make + $ sudo make install + +=head2 è²¢ç®ããã«ã¯ + +=begin original + +Please send the pull request via L<http://github.com/tokuhirom/p5-Furl/>. + +=end original + +L<http://github.com/tokuhirom/p5-Furl/> ã« pull request ãéã£ã¦ãã ããã + +=head1 åç § + +L<LWP> + +HTTP specs: +L<http://www.w3.org/Protocols/HTTP/1.0/spec.html> +L<http://www.w3.org/Protocols/HTTP/1.1/spec.html> + +=head1 LICENSE + +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 + Index: docs/modules/Furl-3.00/lib/Furl/Headers.pod diff -u /dev/null docs/modules/Furl-3.00/lib/Furl/Headers.pod:1.1 --- /dev/null Mon Nov 18 11:14:29 2013 +++ docs/modules/Furl-3.00/lib/Furl/Headers.pod Mon Nov 18 11:14:29 2013 @@ -0,0 +1,168 @@ +=encoding utf-8 + +=head1 åå + +=begin original + +Furl::Headers - HTTP Headers object + +=end original + +Furl::Headers - HTTPãããã¼ãªãã¸ã§ã¯ã + +=head1 æ¦è¦ + +=head1 ã³ã³ã¹ãã©ã¯ã¿ + +=over 4 + +=item my $headers = Furl::Headers->new(\%headers); + +=begin original + +The constructor takes one argument. It is a hashref. +Every key of hashref must be lower-cased. + +=end original + +ã³ã³ã¹ãã©ã¯ã¿ã¯ããã·ã¥ãªãã¡ã¬ã³ã¹ã®å¼æ°ãä¸ã¤ã¨ãã¾ãã +ããã·ã¥ãªãã¡ã¬ã³ã¹ã®ãã¹ã¦ã®ãã¼ã¯å°æåã§ãªããã°ããã¾ããã + +=begin original + +The format of the argument is like following: + +=end original + +å¼æ°ã®ãã©ã¼ãããã¯ä»¥ä¸ã®ããã«ãªãã¾ã: + + +{ + 'content-length' => [30], + 'set-cookies' => ['auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT', '_twitter_sess=JKLJBNBLKSFJBLKSJBLKSJLKJFLSDJFjkDKFUFIOSDUFSDVjOTUzNzUwNTE2%250AZWFiMWRiNDZhMDcwOWEwMWQ5IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--d9ce07496a22525bc178jlkhafklsdjflajfl411; domain=.twitter.com; path=/'], + } + +=back + +=head1 ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã + +=over 4 + +=item my @values = $headers->header($key); + +=begin original + +Get the header value in array. + +=end original + +é åã§ãããã®å¤ãããã¨ãã¾ãã + +=item my $values_joined = $headers->header($key); + +=begin original + +Get the header value in scalar. This is not a first value of header. This is same as: + +=end original + +ã¹ã«ã©ã§ãããã®å¤ãããã¨ãã¾ããããã¯ãããã®åãã®å¤ã§ã¯ããã¾ããã次ã®ãã®ã¨åãã§ã: + + my $values = join(", ", $headers->header($key)) + +=item $headers->header($key, $val); + +=item $headers->header($key, \@val); + +=begin original + +Set the new value of headers. + +=end original + +ãããã«æ°ããå¤ãã»ãããã¾ãï¼ + +=item $headers->remove_header($key); + +=begin original + +Delete key from headers. + +=end original + +ãããããå¤ãåé¤ãã¾ãã + +=item my @h = $headers->flatten(); + +=begin original + +Gets pairs of keys and values. + +=end original + +ãã¼ã¨å¤ã®ãã¢ãå¾ã¾ãã + +=item my @keys = $headers->keys(); + +=item my @keys = $headers->header_field_names(); + +=begin original + +Returns keys of headers in array. The return value do not contains duplicated value. + +=end original + +é åã§ãããã®ãã¼ãè¿ãã¾ããè¿ãå¤ã¯éè¤ããå¤ãè¿ãã¾ããã + +=item my $str = $headers->as_string(); + +=begin original + +Return the header fields as a formatted MIME header. + +=end original + +æ´å½¢æ¸ã¿ã®MIMEãããã¨ãã¦ããããã£ã¼ã«ããè¿ãã¾ãã + +=item my $val = $headers->referer() + +=item my $val = $headers->expires() + +=item my $val = $headers->last_modified() + +=item my $val = $headers->if_modified_since() + +=item my $val = $headers->content_type() + +=item my $val = $headers->content_length() + +=item my $val = $headers->content_encoding() + +=begin original + +These methods are shortcut for popular headers. + +=end original + +ãããã®ã¡ã½ããã¯ããã¥ã©ã¼ãªãããã®ããã®ã·ã§ã¼ãã«ããã§ãã + +=back + +=item $headers->clone(); + +=begin original + +Returns a copy of this "Furl::Headers" object. + +=end original + +"Furl::Headers" ãªãã¸ã§ã¯ãã®ã³ãã¼ãè¿ãã¾ãã + +=back + +=head1 SEE ALSO + +L<HTTP::Headers> + + +=cut + Index: docs/modules/Furl-3.00/lib/Furl/Request.pod diff -u /dev/null docs/modules/Furl-3.00/lib/Furl/Request.pod:1.1 --- /dev/null Mon Nov 18 11:14:29 2013 +++ docs/modules/Furl-3.00/lib/Furl/Request.pod Mon Nov 18 11:14:29 2013 @@ -0,0 +1,166 @@ +=encoding utf-8 + +=head1 NAME + +=begin original + +Furl::Request - Request object for Furl + +=end original + +Furl::Request - Furl ã®ãªã¯ã¨ã¹ããªãã¸ã§ã¯ã + +=head1 SYNOPSIS + + my $f = Furl->new; + my $req = Furl::Request->new($method, $uri, $headers, $content); + my $res = $f->request($req); + + print $req->request_line, "\n"; + my $http_req = $req->as_http_request; + my $req_hash = $req->as_hashref; + +=head1 DESCRIPTION + +=begin original + +This is a HTTP request object in Furl. + +=end original + +Furl ã® HTTP ãªã¯ã¨ã¹ããªãã¸ã§ã¯ãã§ãã + +=head1 CONSTRUCTOR + + my $req = Furl::Request->new($method, $uri); + # or + my $req = Furl::Request->new($method, $uri, \%headers); + # or + my $req = Furl::Request->new($method, $uri, \%headers, $content); + + # and + + my $req = Furl::Request->parse($http_request_raw_string); + +=head1 INSTANCE METHODS + +(ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã) + +=over 4 + +=item $req->method($method) + +=begin original + +Gets/Sets HTTP request method + +=end original + +HTTP ãªã¯ã¨ã¹ãã¡ã½ãããåå¾/ã»ãããã¾ãã + +=item $req->uri($uri) + +=begin original + +Gets/Sets request URI + +=end original + +ãªã¯ã¨ã¹ã URI ãåå¾/ã»ãããã¾ãã + +=item $req->headers($headers) + +=begin original + +Gets/Sets instance of L<Furl::Headers> + +=end original + +L<Furl::Headers> ã®ã¤ã³ã¹ã¿ã³ã¹ãåå¾/ã»ãããã¾ãã + +=item $req->content($content) + +=item $req->body($content) + +=begin original + +Gets/Sets request body in scalar. + +=end original + +ã¹ã«ã©ã§ããªã¯ã¨ã¹ãããã£ãåå¾/ã»ãããã¾ãã + +=item $req->protocol($protocol) + + $req->protocol('HTTP/1.1'); + print $req->protocol; #=> "HTTP/1.1" + +=begin original + +Gets/Sets HTTP protocol in string. + +=end original + +æåå㧠HTTP ãããã³ã«ãåå¾/ã»ãããã¾ãã + +=item $req->content_length + +=item $req->content_type + +=item $req->header + +=begin original + +Shorthand to access L<Furl::Headers>. + +=end original + +L<Furl::Headers>ã«éè¨ã§ã¢ã¯ã»ã¹ãã¾ãã + +=item $req->as_http_request + +=begin original + +Make instance of L<HTTP::Request> from L<Furl::Request>. + +=end original + +L<Furl::Request> ãã L<HTTP::Request> ã®ã¤ã³ã¹ã¿ã³ã¹ãä½ãã¾ãã + +=item $req->as_hashref + +=begin original + +Convert request object to HashRef. + +=end original + +ãªã¯ã¨ã¹ããªãã¸ã§ã¯ããããã·ã¥ãªãã¡ã¬ã³ã¹ã«ãã¾ãã + +=begin original + +Format is following: + +=end original + +ãã©ãããã¯ä»¥ä¸ã«ãªãã¾ã: + + method: Str + uri: Str + protocol: Str + headers: ArrayRef[Str] + content: Str + +=item $req->request_line + + print $req->request_line; #=> "GET / HTTP/1.1" + +=begin original + +Returns HTTP request line. + +=end original + +HTTP ãªã¯ã¨ã¹ãã©ã¤ã³ãè¿ãã¾ãã + +=back Index: docs/modules/Furl-3.00/lib/Furl/Response.pod diff -u /dev/null docs/modules/Furl-3.00/lib/Furl/Response.pod:1.1 --- /dev/null Mon Nov 18 11:14:29 2013 +++ docs/modules/Furl-3.00/lib/Furl/Response.pod Mon Nov 18 11:14:29 2013 @@ -0,0 +1,249 @@ +=encoding utf-8 + +=begin original + +=for stopwords charsets + +=head1 NAME + +Furl::Response - Response object for Furl + +=end original + +Furl::Response - Furlã®ã¬ã¹ãã³ã¹ãªãã¸ã§ã¯ã + +=head1 æ¦è¦ + + my $res = Furl::Response->new($minor_version, $code, $message, $headers, $content); + print $res->status, "\n"; + +=head1 説æ + +=begin original + +This is a HTTP response object in Furl. + +=end original + +ããã¯Furl ã® HTTPã¬ã¹ãã³ã¹ãªãã¸ã§ã¯ãã§ãã + +=head1 ã³ã³ã¹ãã©ã¯ã¿ + + my $res = Furl::Response->new($minor_version, $code, $msg, \%headers, $content); + +=head1 ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã + +=over 4 + +=item $res->code + +=item $res->status + +=begin original + +Returns HTTP status code. + +=end original + +HTTPã¹ãã¼ã¿ã¹ã³ã¼ããè¿ãã¾ãã + +=item $res->message + +=begin original + +Returns HTTP status message. + +=end original + +HTTPã¹ãã¼ã¿ã¹ã¡ãã»ã¼ã¸ãè¿ãã¾ãã + +=item $res->headers + +=begin original + +Returns instance of L<Furl::Headers> + +=end original + +L<Furl::Headers>ã®ã¤ã³ã¹ã¿ã³ã¹ãè¿ãã¾ãã + +=item $res->content + +=item $res->body + +=begin original + +Returns response body in scalar. + +=end original + +ã¬ã¹ãã³ã¹ããã£ãã¹ã«ã©ã§è¿ãã¾ãã + +=item $res->decoded_content + +=begin original + +This will return the content after any C<< Content-Encoding >> and charsets have been decoded. See L<< HTTP::Message >> for details + +=end original + +ããã¯ãC<< Content-Encoding >> ã¨æåã»ããããã³ã¼ããããå¾ã§ãå 容ãè¿ãã¾ãã詳細㯠L<< HTTP::Message >> ãè¦ã¦ãã ããã + +=item $res->request + +=begin original + +Returns instance of L<Furl::Request> related this response. + +=end original + +ã¬ã¹ãã³ã¹ã«é¢é£ãããL<Furl::Request> ã®ã¤ã³ã¹ã¿ã³ã¹ãè¿ãã¾ãã + +=item $res->content_length + +=item $res->content_type + +=item $res->content_encoding + +=item $res->header + +=begin original + +Shorthand to access L<Furl::Headers>. + +=end original + +L<Furl::Headers>ã¸ã¢ã¯ã»ã¹ããããã®ã·ã§ã¼ããã³ãã§ãã + +=item $res->protocol + + $res->protocol(); # => "HTTP/1.1" + +=begin original + +Returns HTTP protocol in string. + +=end original + +HTTP ãããã³ã«ãæååã§è¿ãã¾ãã + +=item $res->as_http_response + +=begin original + +Make instance of L<HTTP::Response> from L<Furl::Response>. + +=end original + +L<Furl::Response>ããL<HTTP::Response>ã®ã¤ã³ã¹ã¿ã³ã¹ãä½ãã¾ãã + +=item $res->to_psgi() + +=begin original + +Convert object to L<PSGI> response. It's very useful to make proxy. + +=end original + +L<PSGI> ã¬ã¹ãã³ã¹ã®ãªãã¸ã§ã¯ãã«å¤æãã¾ãããããã·ãä½ãã®ã«ã¨ã¦ã便å©ã§ãã + +=item $res->as_hashref() + +=begin original + +Convert response object to HashRef. + +=end original + +ã¬ã¹ãã³ã¹ãªãã¸ã§ã¯ããããã·ã¥ãªãã¡ã¬ã³ã¹ã«ãã¾ãã + +=begin original + +Format is following: + +=end original + +ãã©ã¼ãããã¯ä»¥ä¸ã«ãªãã¾ã: + + code: Int + message: Str + protocol: Str + headers: ArrayRef[Str] + content: Str + +=item $res->is_success + +=begin original + +Returns true if status code is 2xx. + +=end original + +ã¹ãã¼ã¿ã¹ã³ã¼ãã2xxã§ããã°ãçãè¿ãã¾ãã + +=item $res->status_line + + + $res->status_line() # => "200 OK" + +=begin original + +Returns status line. + +=end original + +ã¹ãã¼ã¿ã¹ã©ã¤ã³ãè¿ãã¾ãã + +=item my $headers = $res->captured_req_headers() : Str + +=begin original + +Captured request headers in raw string. + +=end original + +ãã£ããã£ãããçã®æååã®ãªã¯ã¨ã¹ããããã + +=begin original + +This method is only for debugging. + +=end original + +ãã®ã¡ã½ããã¯ãããã°ç¨ã§ãã + +=begin original + +You can use this method if you are using C<< capture_request >> parameter is true. + +=end original + +C<< capture_request >> ãçã«ãã¦ä½¿ã£ã¦ãããªãããã®ã¡ã½ããã使ããã¨ãã§ãã¾ãã + +=item my $content = $res->captured_req_content() : Str + +=begin original + +Captured request content in raw string. + +=end original + +ãã£ããã£ãããçã®æååã®ãªã¯ã¨ã¹ãã®å 容ã + +=begin original + +This method is only for debugging. + +=end original + +ãã®ã¡ã½ããã¯ãããã°ç¨ã§ãã + +=begin original + +You can use this method if you are using C<< capture_request >> parameter is true. + +=end original + +C<< capture_request >> ãçã«ãã¦ä½¿ã£ã¦ãããªãããã®ã¡ã½ããã使ããã¨ãã§ãã¾ãã + +=back