ktats****@users*****
ktats****@users*****
2011年 2月 10日 (木) 11:26:34 JST
Index: docs/modules/Furl-0.22/lib/Furl/HTTP.pod diff -u docs/modules/Furl-0.22/lib/Furl/HTTP.pod:1.1 docs/modules/Furl-0.22/lib/Furl/HTTP.pod:1.2 --- docs/modules/Furl-0.22/lib/Furl/HTTP.pod:1.1 Thu Feb 10 04:25:44 2011 +++ docs/modules/Furl-0.22/lib/Furl/HTTP.pod Thu Feb 10 11:26:33 2011 @@ -57,14 +57,21 @@ ãã®ã©ã¤ãã©ãªã¯ B<ãã¼ã¿>ã½ããã¦ã§ã¢ã§ããäºåãªãAPIãå¤æ´ãããããç¥ãã¾ããã -=head1 INTERFACE +=head1 ã¤ã³ã¿ã¼ãã§ã¼ã¹ -=head2 Class Methods +=head2 ã¯ã©ã¹ã¡ã½ãã =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 + + + + I<%args> might be: =over @@ -122,115 +129,325 @@ =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 ':content_file' in L<LWP::UserAgent>. +=end original + +L<LWP::UserAgent>ã®':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 ':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 + =item Why IO::Socket::SSL? +=end original + +=begin original + Net::SSL is not well documented. +=end original + +Net::SSL ã¯ããã¥ã¡ã³ãã貧弱ã§ãã + +=begin original + =item Why is env_proxy optional? +=end original + +=item env_proxy ã¯ãªããªãã·ã§ãã«ãªã®ã§ãã? + +=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 + +ç°å¢å¤æ°ã¯ã¦ã¼ã¶ã¼ã®ç°å¢ã«å¼·ãä¾åãã¾ãã +ãã¾ãåããªãã¨ãã«ã¦ã¼ã¶ã¼ãæ··ä¹±ããã¾ãã + +=begin original + =item What operating systems are supported? +=end original + +=item ã©ã®ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ããµãã¼ããã¾ãã? + +=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 + +ããªããããããéãã°ãä»ã®ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ããµãã¼ããããã§ãããã + +=begin original + =item Why doesn't Furl support chunked upload? +=end original + +=item ãªãFurlã¯ãã£ã³ã¯ãããã¢ãããã¼ãããµãã¼ãããªãã®ã§ãã? + +=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 + 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. +=begin original + =item How do you build the response content as it arrives? +=end original + +=item å°éããã¬ã¹ãã³ã¹ã®å 容ãã©ã®ããã«ä½ãã¾ãã? + +=begin original + You can use L<IO::Callback> for this purpose. +=end original + +ãã®ããã«L<IO::Callback>ã使ãã¾ãã + my $fh = IO::Callback->new( '<', sub { @@ -242,14 +459,38 @@ $furl->put( "http://127.0.0.1:$port/", [ 'Content-Length' => $len ], $fh, ); +=begin original + =item How do you use gzip/deflate compressed communication? +=end original + +=item gzip/deflate å§ç¸®ãããã³ãã¥ãã±ã¼ã·ã§ã³ã使ãã¾ãã? + +=begin original + Add an B<Accept-Encoding> header to your request. Furl inflates response bodies transparently according to the B<Content-Encoding> response header. +=end original + +B<Accept-Encoding>ãããããªã¯ã¨ã¹ãã«è¿½å ãã¦ãã ãããFurlã¬ã¹ãã³ã¹ããã£ã¼ãB<Content-Encoding>ã¬ã¹ãã³ã¹ãããã«å¾ã£ã¦ééçã«ã¤ã³ãã¬ã¼ããã¾ãã + +=begin original + =item How do you use mutipart/form-data? +=end original + +=item mutipart/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(); @@ -264,29 +505,91 @@ ]; $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ãµãã¼ãã¯å©ç¨å¯è½ã§ãã + +=begin original + =item How do you use Keep-Alive and what happens on the HEAD method? +=end original + +=item Kee-Alive ãã©ããã£ã¦ä½¿ãã®ãã¨HEADã¡ã½ããã§ã¯ä½ãèµ·ããã®ã? + +=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ã³ã³ãã³ãããã£ãã·ã¥ããã®ã«åã£ã¦ãã¾ãã + +=begin original + =item Why does Furl take longer than specified until it returns a timeout error? +=end original + +=item Why does Furl take longer than specified until it returns a timeout error? + +ãªãFurlã¯ã¿ã¤ã ã¢ã¦ãã¨ã©ã¼ãè¿ãã¾ã§æå®ããé·ããããã®ã§ãã? + +=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 hostnames 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( @@ -302,29 +605,65 @@ - ipv6 support - better docs for NO_PROXY -=head1 OPTIONAL FEATURES +=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. -=head1 DEVELOPMENT +=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 @@ -332,11 +671,11 @@ $ make $ sudo make install -=head2 HOW TO CONTRIBUTE +=head2 è²¢ç®ããã«ã¯ Please send the pull-req via L<http://github.com/tokuhirom/p5-Furl/>. -=head1 SEE ALSO +=head1 åç § L<LWP>