perl.libwww http://www.nntp.perl.org/group/perl.libwww/ ... Copyright 1998-2008 perl.org Wed, 08 Oct 2008 01:29:19 +0000 ask@perl.org libww-perl-5.816 by Gisle Aas Unfortunately 5.815 broke download-to-file on Windows. I&#39;ve now<br/>uploaded 5.816 to CPAN. This release only adds the binmode()<br/>statement that was missing.<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7235.html Mon, 29 Sep 2008 08:44:41 +0000 Re: Silent removed parameters when posting UTF8 by Bill Moseley On Thu, Sep 25, 2008 at 11:35:40AM +0200, Gisle Aas wrote:<br/>&gt; &gt; Do the url-encoded post parameters have to be of<br/>&gt; &gt; a given character encoding or is that just an agreement between the<br/>&gt; &gt; sender and receiver?<br/>&gt; <br/>&gt; There certainly has to be agreement between the sender and the<br/>&gt; receiver. I thought the normal behaviour was to encode using the same<br/>&gt; encoding as the document the form was embedded in uses.<br/><br/>Yes, that&#39;s why I use accept-charset=utf8 on my forms. BTW, I looked<br/>at a Firefox post with Wireshark and there&#39;s no charset added to the<br/>urlencoded content type. Seems like I&#39;ve seen example of adding a<br/>charset to that content type.<br/><br/>In absence of a charset in the post I guess the server just has to<br/>assume it&#39;s encoded as requested (with accept-charset). That&#39;s what I<br/>do.<br/><br/><br/>Now, in the case that trigged this question there is no form -- just<br/>documentation that says &quot;post to this url&quot;, and the url has<br/>?encoding=utf8 if the content is utf8.<br/><br/><br/><br/>&gt; &gt; If that&#39;s the case then it would seem like query_param should die if<br/>&gt; &gt; it receives any strings with the utf8 flag on. You can&#39;t encode_utf8<br/>&gt; &gt; or utf8::downgrade because we don&#39;t know what (octet) encoding that<br/>&gt; &gt; the sender and receiver agreed on.<br/>&gt; <br/>&gt; I basically agree with that view. It can still be convenient to have<br/>&gt; it assume UTF-8 encoding in this case, and there is the potential that<br/>&gt; introducing this strictness breaks code.<br/><br/>With something as widely used as URI I don&#39;t think you can make that<br/>change. But a warning would probably be safe. Maybe a package<br/>variable could be used to enable exceptions.<br/><br/><br/>&gt; $u-&gt;query_form(foo =&gt; &quot;b&aring;l&quot;);<br/>&gt; $u-&gt;query_form(foo =&gt; &quot;b&aring;l&quot;, bar =&gt; &quot;\N{WATCH}&quot;);<br/>&gt; <br/>&gt; which prints:<br/>&gt; <br/>&gt; http://www.example.com?foo=b%E5l<br/>&gt; http://www.example.com?foo=b%C3%A5l&amp;bar=%E2%8C%9A<br/>&gt; <br/>&gt; Here the encoding of the first parameter depends on the presence of<br/>&gt; the second parameter which is clearly not a good thing.<br/><br/>Right, the 8859-1 encoded b&aring;l was upgraded to a utf8 character string<br/>when combined with the ut8 character string. Might been different if<br/>your script was encoded in utf8 and had the use utf8 pragma.<br/><br/>I kind of wish the uf8 flag in Perl was called &quot;character&quot; instead.<br/>It&#39;s not utf8 (ok, it is), but it really should be though of as an<br/>abstract representation of characters without any encoding.<br/><br/>When the utf8 flag is set then the string is a Perl character string<br/>and to use it external of Perl (i.e. sending to another server) it<br/>really needs to be converted to octets. And most of the time it&#39;s up<br/>to the user to decide what encoding to use and not something the<br/>module can guess.<br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7234.html Thu, 25 Sep 2008 06:27:48 +0000 libww-perl-5.815 by Gisle Aas I&#39;ve uploaded libwww-perl 5.815 to CPAN.<br/><br/>The main change this time is the introduction of handlers to drive the<br/>processing of requests in LWP::UserAgent. You can also register your<br/>own handlers for modifying and processing requests or responses on<br/>their way, which I think is a much more flexible approach that trying<br/>to subclass LWP::UserAgent to customize it. If we have had these<br/>early on then the LWP::UserAgent API could have been so much simpler<br/>as the effect of most current attributes can easily be set up with<br/>trivial handlers. Also thanks to contributions by Bron Gondwana LWP&#39;s<br/>Basic/Digest authenticate modules now registers handlers which allow<br/>them to automatically fill in the Authorization headers without first<br/>taking the roundtrip of a 401 response when LWP knows the credentials<br/>for a given realm.<br/><br/>This code shows some examples of what you can use custom handlers for:<br/><br/>#!perl<br/><br/>use LWP::UserAgent;<br/>$ua = LWP::UserAgent-&gt;new;<br/><br/># example of handler to add custom headers<br/>$ua-&gt;add_handler(&quot;request_prepare&quot;, sub {<br/> my $req = shift;<br/> $req-&gt;init_header(&quot;Accept-Language&quot; =&gt; [&quot;no&quot;, &quot;en-US&quot;]);<br/>});<br/><br/># example of handler to rewrite the method for certain requests<br/>$ua-&gt;add_handler(&quot;request_prepare&quot;,<br/> sub {<br/> my $req = shift;<br/> $req-&gt;method(&quot;TRACE&quot;);<br/> },<br/> m_scheme =&gt; &quot;http&quot;,<br/> m_method =&gt; &quot;GET&quot;,<br/> m_domain =&gt; &quot;example.com&quot;,<br/>);<br/><br/># example of handler to monitor the requests that are sent<br/>$ua-&gt;add_handler(&quot;request_send&quot;, sub {<br/> my $req = shift;<br/> print $req-&gt;as_string;<br/> return;<br/>});<br/><br/># example of handler that only pass HTTP requests through<br/>$ua-&gt;add_handler(&quot;request_send&quot;, sub {<br/> my $req = shift;<br/> return if $req-&gt;uri-&gt;scheme =~ /^http/;<br/> return HTTP::Response-&gt;new(403, undef,<br/> [&quot;Server&quot; =&gt; $ua-&gt;agent, &quot;Content-Type&quot; =&gt; &quot;text/plain&quot;],<br/> &quot;It&#39;s our brand new policy to restrict access to HTTP!\n&quot;<br/> );<br/>});<br/><br/># example of handler that counts number how much data we receive<br/>my $bytes_received = 0;<br/>$ua-&gt;add_handler(&quot;response_data&quot;, sub {<br/> $bytes_received += length($_[3]);<br/>});<br/><br/>print $ua-&gt;get(&quot;http://www.example.com&quot;)-&gt;as_string;<br/>print $ua-&gt;get(&quot;ftp://ftp.example.com&quot;)-&gt;as_string;<br/><br/>print &quot;$bytes_received bytes of content received (not including<br/>protocol overhead)\n&quot;;<br/><br/>__END__<br/><br/>Enjoy!<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7233.html Thu, 25 Sep 2008 03:24:12 +0000 Re: Silent removed parameters when posting UTF8 by Gisle Aas On Thu, Sep 25, 2008 at 5:57 AM, Bill Moseley &lt;moseley@hank.org&gt; wrote:<br/>&gt; On Sun, Sep 21, 2008 at 08:36:32AM +0200, Gisle Aas wrote:<br/>&gt;&gt; The issue with dropped chars has been fixed so I don&#39;t worry about<br/>&gt;&gt; that. Just upgrade the URI module.<br/>&gt;&gt;<br/>&gt;&gt; The remaining issue is if $url-&gt;query_form should accept Unicode data<br/>&gt;&gt; and automatically UTF-8 encode it as it does now. When I accepted<br/>&gt;&gt; that patch I though it would be harmless as this provide a convenience<br/>&gt;&gt; for some at the same time as it does not change anything for users<br/>&gt;&gt; that properly encode their data before passing it to this API. What&#39;s<br/>&gt;&gt; problematic is that this strengthens the idea that the UTF-8 flag has<br/>&gt;&gt; semantic meaning at the Perl level. Strings with chars in the range<br/>&gt;&gt; 128-255 behave differently depending on the internal representation.<br/>&gt;&gt; I&#39;m not happy about that. It&#39;s certainly not my idea of a sane<br/>&gt;&gt; Unicode model.<br/>&gt;&gt;<br/>&gt;&gt; To me that leaves 2 options; either make the URI API strict and only<br/>&gt;&gt; accept args that are bytes (strings that can be utf8::downgraded) or<br/>&gt;&gt; just live with the ugliness of inconsistent Unicode model and try to<br/>&gt;&gt; document the issues better over time. I&#39;m leaning towards the later.<br/>&gt;<br/>&gt; Sorry, kind of got stuck behind work here.<br/>&gt;<br/>&gt; So, in my situation I need to post some utf8 characters. The service<br/>&gt; I&#39;m using requires an ?encoding=utf8 query parameter to say what<br/>&gt; encoding the text is encoded in. The post doesn&#39;t include<br/>&gt; a charset:<br/>&gt;<br/>&gt; Content-Type: application/x-www-form-urlencoded<br/>&gt;<br/>&gt; So it seems the server needs to be explicitly told.<br/>&gt;<br/>&gt;<br/>&gt; The problem I had was if I passed in a character string (utf8 flag on)<br/>&gt; then the url-encoding process dropped chars. You say that has been<br/>&gt; fixed. I fixed on my side by simply calling encode_utf8 to convert my<br/>&gt; character string into octets. Then all octets were url-encoded and<br/>&gt; passed to the server and all works fine.<br/><br/>Yes and that will always continue to work. If you encode the strings<br/>yourself things behave consistently and you select what encoding to<br/>use.<br/><br/>If you mix encoded (byte) strings and Unicode strings bad things<br/>happens. If you only use Unicode strings (and at least one of them<br/>has the utf8-flag set or none of them has chars above 127) you should<br/>get UTF-8 encoded output.<br/><br/>&gt; Now, here&#39;s my question. Could I pass in any byte (octet) string and<br/>&gt; have it url-encoded?<br/><br/>Yes. URI-&gt;query_form just encodes the bytes asis.<br/><br/>&gt; Do the url-encoded post parameters have to be of<br/>&gt; a given character encoding or is that just an agreement between the<br/>&gt; sender and receiver?<br/><br/>There certainly has to be agreement between the sender and the<br/>receiver. I thought the normal behaviour was to encode using the same<br/>encoding as the document the form was embedded in uses.<br/><br/>&gt; That is, can I encode my character string into any character<br/>&gt; encoding and send it url-encoded? Then as long as the server<br/>&gt; receiving the post knows how to decoded (using same encoding I used)<br/>&gt; then it would be fine?<br/><br/>Right.<br/><br/>&gt; If that&#39;s the case then it would seem like query_param should die if<br/>&gt; it receives any strings with the utf8 flag on. You can&#39;t encode_utf8<br/>&gt; or utf8::downgrade because we don&#39;t know what (octet) encoding that<br/>&gt; the sender and receiver agreed on.<br/><br/>I basically agree with that view. It can still be convenient to have<br/>it assume UTF-8 encoding in this case, and there is the potential that<br/>introducing this strictness breaks code.<br/><br/>It could also be argued that it might be helpful to break such code<br/>because it has the potential of already being broken. Consider this<br/>example:<br/><br/>#!perl -wl<br/><br/>use URI;<br/>use charnames &#39;:full&#39;;<br/><br/>$u = URI-&gt;new(&quot;http://www.example.com&quot;);<br/>$u-&gt;query_form(foo =&gt; &quot;b&aring;l&quot;);<br/>print $u;<br/><br/>$u-&gt;query_form(foo =&gt; &quot;b&aring;l&quot;, bar =&gt; &quot;\N{WATCH}&quot;);<br/>print $u;<br/><br/>__END__<br/><br/>which prints:<br/><br/> http://www.example.com?foo=b%E5l<br/> http://www.example.com?foo=b%C3%A5l&amp;bar=%E2%8C%9A<br/><br/>Here the encoding of the first parameter depends on the presence of<br/>the second parameter which is clearly not a good thing.<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7232.html Thu, 25 Sep 2008 02:35:50 +0000 Re: Silent removed parameters when posting UTF8 by Bill Moseley On Sun, Sep 21, 2008 at 08:36:32AM +0200, Gisle Aas wrote:<br/>&gt; The issue with dropped chars has been fixed so I don&#39;t worry about<br/>&gt; that. Just upgrade the URI module.<br/>&gt; <br/>&gt; The remaining issue is if $url-&gt;query_form should accept Unicode data<br/>&gt; and automatically UTF-8 encode it as it does now. When I accepted<br/>&gt; that patch I though it would be harmless as this provide a convenience<br/>&gt; for some at the same time as it does not change anything for users<br/>&gt; that properly encode their data before passing it to this API. What&#39;s<br/>&gt; problematic is that this strengthens the idea that the UTF-8 flag has<br/>&gt; semantic meaning at the Perl level. Strings with chars in the range<br/>&gt; 128-255 behave differently depending on the internal representation.<br/>&gt; I&#39;m not happy about that. It&#39;s certainly not my idea of a sane<br/>&gt; Unicode model.<br/>&gt; <br/>&gt; To me that leaves 2 options; either make the URI API strict and only<br/>&gt; accept args that are bytes (strings that can be utf8::downgraded) or<br/>&gt; just live with the ugliness of inconsistent Unicode model and try to<br/>&gt; document the issues better over time. I&#39;m leaning towards the later.<br/><br/>Sorry, kind of got stuck behind work here.<br/><br/>So, in my situation I need to post some utf8 characters. The service<br/>I&#39;m using requires an ?encoding=utf8 query parameter to say what<br/>encoding the text is encoded in. The post doesn&#39;t include<br/>a charset:<br/><br/> Content-Type: application/x-www-form-urlencoded<br/><br/>So it seems the server needs to be explicitly told.<br/><br/><br/>The problem I had was if I passed in a character string (utf8 flag on)<br/>then the url-encoding process dropped chars. You say that has been<br/>fixed. I fixed on my side by simply calling encode_utf8 to convert my<br/>character string into octets. Then all octets were url-encoded and<br/>passed to the server and all works fine.<br/><br/>Now, here&#39;s my question. Could I pass in any byte (octet) string and<br/>have it url-encoded? Do the url-encoded post parameters have to be of<br/>a given character encoding or is that just an agreement between the<br/>sender and receiver?<br/><br/>That is, can I encode my character string into any character<br/>encoding and send it url-encoded? Then as long as the server<br/>receiving the post knows how to decoded (using same encoding I used)<br/>then it would be fine?<br/><br/>If that&#39;s the case then it would seem like query_param should die if<br/>it receives any strings with the utf8 flag on. You can&#39;t encode_utf8<br/>or utf8::downgrade because we don&#39;t know what (octet) encoding that<br/>the sender and receiver agreed on.<br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7231.html Wed, 24 Sep 2008 20:57:32 +0000 Re: Silent removed parameters when posting UTF8 by Gisle Aas The issue with dropped chars has been fixed so I don&#39;t worry about<br/>that. Just upgrade the URI module.<br/><br/>The remaining issue is if $url-&gt;query_form should accept Unicode data<br/>and automatically UTF-8 encode it as it does now. When I accepted<br/>that patch I though it would be harmless as this provide a convenience<br/>for some at the same time as it does not change anything for users<br/>that properly encode their data before passing it to this API. What&#39;s<br/>problematic is that this strengthens the idea that the UTF-8 flag has<br/>semantic meaning at the Perl level. Strings with chars in the range<br/>128-255 behave differently depending on the internal representation.<br/>I&#39;m not happy about that. It&#39;s certainly not my idea of a sane<br/>Unicode model.<br/><br/>To me that leaves 2 options; either make the URI API strict and only<br/>accept args that are bytes (strings that can be utf8::downgraded) or<br/>just live with the ugliness of inconsistent Unicode model and try to<br/>document the issues better over time. I&#39;m leaning towards the later.<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7230.html Sat, 20 Sep 2008 23:36:43 +0000 Re: Silent removed parameters when posting UTF8 by Bill Moseley On Fri, Sep 19, 2008 at 03:54:13PM +0200, Gisle Aas wrote:<br/>&gt; This is probably not be a perl issue as I did not have the same<br/>&gt; version of URI and libwww-perl installed where I tested. What version<br/>&gt; of URI and libwww-perl did you use? I now think that you&#39;ll see the<br/>&gt; first behaviour with URI &lt;= 1.35 and the later if URI is more recent.<br/><br/>I have version 1.35.<br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7229.html Fri, 19 Sep 2008 07:05:16 +0000 Re: Silent removed parameters when posting UTF8 by Bill Moseley On Fri, Sep 19, 2008 at 02:14:25PM +0200, Gisle Aas wrote:<br/>&gt; I wonder if this is a bug in perl itself. With perl-5.8.8 I get:<br/>&gt; <br/>&gt; count=123&amp;works=%E2%98%BA&amp;does_not_work=&amp;foo=bar<br/>&gt; <br/>&gt; as you showed, but with perl-5.8.9(tobe) and perl-5.10.0 I get:<br/>&gt; <br/>&gt; count=123&amp;works=%C3%A2%C2%98%C2%BA&amp;does_not_work=%E2%98%BA&amp;foo=bar<br/>&gt; <br/>&gt; so now it&#39;s the &#39;works&#39; case that does_not_work but in a different way :(<br/><br/>That&#39;s bothersome.<br/><br/>Would you agree that the url encoding must be done on octets? If so,<br/>then I think it would be correct to issue a warning if the utf8 flag<br/>is on.<br/><br/>I think doing it in query_form would be the best place as it tells the<br/>user what specific item had the utf8 flag on.<br/><br/><br/> while (my($key,$vals) = splice(@new, 0, 2)) {<br/> $key = &#39;&#39; unless defined $key;<br/><br/> warn &quot;key [$key] has utf8 flag set and may not url-encode&quot;<br/> if utf8::is_utf8( $key );<br/><br/> $key =~ s/([;\/?:@&amp;=+,\$\[\]%])/$URI::Escape::escapes{$1}/g;<br/> $key =~ s/ /+/g;<br/> $vals = [ref($vals) eq &quot;ARRAY&quot; ? @$vals : $vals];<br/> for my $val (@$vals) {<br/> $val = &#39;&#39; unless defined $val;<br/><br/> warn &quot;value [$val] for key [$key] has utf8 flag set and may not url-encode&quot;<br/> if utf8::is_utf8( $val );<br/><br/> $val =~ s/([;\/?:@&amp;=+,\$\[\]%])/$URI::Escape::escapes{$1}/g;<br/> <br/><br/>Actually, I guess I&#39;d argue to die, but that might break existing<br/>code. After all, if trying to url-encode characters might result in<br/>dropped or altered data that&#39;s pretty serious.<br/><br/>Thanks,<br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7228.html Fri, 19 Sep 2008 07:04:08 +0000 Re: Silent removed parameters when posting UTF8 by Gisle Aas This is probably not be a perl issue as I did not have the same<br/>version of URI and libwww-perl installed where I tested. What version<br/>of URI and libwww-perl did you use? I now think that you&#39;ll see the<br/>first behaviour with URI &lt;= 1.35 and the later if URI is more recent.<br/><br/>--Gisle<br/><br/>On Fri, Sep 19, 2008 at 2:14 PM, Gisle Aas &lt;gisle@aas.no&gt; wrote:<br/>&gt; I wonder if this is a bug in perl itself. With perl-5.8.8 I get:<br/>&gt;<br/>&gt; count=123&amp;works=%E2%98%BA&amp;does_not_work=&amp;foo=bar<br/>&gt;<br/>&gt; as you showed, but with perl-5.8.9(tobe) and perl-5.10.0 I get:<br/>&gt;<br/>&gt; count=123&amp;works=%C3%A2%C2%98%C2%BA&amp;does_not_work=%E2%98%BA&amp;foo=bar<br/>&gt;<br/>&gt; so now it&#39;s the &#39;works&#39; case that does_not_work but in a different way :(<br/>&gt;<br/>&gt; --Gisle<br/>&gt;<br/>&gt;<br/>&gt; On Fri, Sep 19, 2008 at 7:54 AM, Bill Moseley &lt;moseley@hank.org&gt; wrote:<br/>&gt;&gt; I have a form that posts to a service, and noticed not all<br/>&gt;&gt; parameters were being posted.<br/>&gt;&gt;<br/>&gt;&gt; I realized my mistake of not encoding to utf8, but I&#39;m curious why<br/>&gt;&gt; this did not generate any warnings.<br/>&gt;&gt;<br/>&gt;&gt; I can imagine others getting caught by this, so a warning would be very<br/>&gt;&gt; helpful.<br/>&gt;&gt;<br/>&gt;&gt; Not really sure where it should be checked -- in query_form when<br/>&gt;&gt; processing the individual parameters, I suspect, but the damage seems<br/>&gt;&gt; to happen when $uri-&gt;query is called:<br/>&gt;&gt;<br/>&gt;&gt; $q =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;<br/>&gt;&gt;<br/>&gt;&gt; Would it not be better to issue a waring?<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; use HTTP::Request::Common;<br/>&gt;&gt; use strict;<br/>&gt;&gt; use warnings;<br/>&gt;&gt; use Data::Dumper;<br/>&gt;&gt; use Encode;<br/>&gt;&gt;<br/>&gt;&gt; my $content = {<br/>&gt;&gt; foo =&gt; &#39;bar&#39;,<br/>&gt;&gt; count =&gt; 123,<br/>&gt;&gt; works =&gt; encode_utf8(&quot;\x{263A}&quot;),<br/>&gt;&gt; does_not_work =&gt; &quot;\x{263A}&quot;,<br/>&gt;&gt; };<br/>&gt;&gt;<br/>&gt;&gt; my $x = HTTP::Request::Common::POST(<br/>&gt;&gt; &#39;http://localhost.com&#39;,<br/>&gt;&gt; $content,<br/>&gt;&gt; );<br/>&gt;&gt; print Dumper $x;<br/>&gt;<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7227.html Fri, 19 Sep 2008 06:54:21 +0000 Re: Silent removed parameters when posting UTF8 by Gisle Aas I wonder if this is a bug in perl itself. With perl-5.8.8 I get:<br/><br/> count=123&amp;works=%E2%98%BA&amp;does_not_work=&amp;foo=bar<br/><br/>as you showed, but with perl-5.8.9(tobe) and perl-5.10.0 I get:<br/><br/> count=123&amp;works=%C3%A2%C2%98%C2%BA&amp;does_not_work=%E2%98%BA&amp;foo=bar<br/><br/>so now it&#39;s the &#39;works&#39; case that does_not_work but in a different way :(<br/><br/>--Gisle<br/><br/><br/>On Fri, Sep 19, 2008 at 7:54 AM, Bill Moseley &lt;moseley@hank.org&gt; wrote:<br/>&gt; I have a form that posts to a service, and noticed not all<br/>&gt; parameters were being posted.<br/>&gt;<br/>&gt; I realized my mistake of not encoding to utf8, but I&#39;m curious why<br/>&gt; this did not generate any warnings.<br/>&gt;<br/>&gt; I can imagine others getting caught by this, so a warning would be very<br/>&gt; helpful.<br/>&gt;<br/>&gt; Not really sure where it should be checked -- in query_form when<br/>&gt; processing the individual parameters, I suspect, but the damage seems<br/>&gt; to happen when $uri-&gt;query is called:<br/>&gt;<br/>&gt; $q =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;<br/>&gt;<br/>&gt; Would it not be better to issue a waring?<br/>&gt;<br/>&gt;<br/>&gt; use HTTP::Request::Common;<br/>&gt; use strict;<br/>&gt; use warnings;<br/>&gt; use Data::Dumper;<br/>&gt; use Encode;<br/>&gt;<br/>&gt; my $content = {<br/>&gt; foo =&gt; &#39;bar&#39;,<br/>&gt; count =&gt; 123,<br/>&gt; works =&gt; encode_utf8(&quot;\x{263A}&quot;),<br/>&gt; does_not_work =&gt; &quot;\x{263A}&quot;,<br/>&gt; };<br/>&gt;<br/>&gt; my $x = HTTP::Request::Common::POST(<br/>&gt; &#39;http://localhost.com&#39;,<br/>&gt; $content,<br/>&gt; );<br/>&gt; print Dumper $x;<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7226.html Fri, 19 Sep 2008 05:14:40 +0000 Silent removed parameters when posting UTF8 by Bill Moseley I have a form that posts to a service, and noticed not all<br/>parameters were being posted.<br/><br/>I realized my mistake of not encoding to utf8, but I&#39;m curious why<br/>this did not generate any warnings.<br/><br/>I can imagine others getting caught by this, so a warning would be very<br/>helpful.<br/><br/>Not really sure where it should be checked -- in query_form when<br/>processing the individual parameters, I suspect, but the damage seems<br/>to happen when $uri-&gt;query is called:<br/><br/> $q =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;<br/><br/>Would it not be better to issue a waring?<br/><br/><br/>use HTTP::Request::Common;<br/>use strict;<br/>use warnings;<br/>use Data::Dumper;<br/>use Encode;<br/><br/>my $content = {<br/> foo =&gt; &#39;bar&#39;,<br/> count =&gt; 123,<br/> works =&gt; encode_utf8(&quot;\x{263A}&quot;),<br/> does_not_work =&gt; &quot;\x{263A}&quot;,<br/>};<br/><br/>my $x = HTTP::Request::Common::POST(<br/> &#39;http://localhost.com&#39;,<br/> $content,<br/>);<br/>print Dumper $x;<br/><br/>$VAR1 = bless( {<br/> &#39;_content&#39; =&gt; &#39;count=123&amp;works=%E2%98%BA&amp;does_not_work=&amp;foo=bar&#39;,<br/> &#39;_uri&#39; =&gt; bless( do{\(my $o = &#39;http://localhost.com&#39;)}, &#39;URI::http&#39; ),<br/> &#39;_headers&#39; =&gt; bless( {<br/> &#39;content-type&#39; =&gt; &#39;application/x-www-form-urlencoded&#39;,<br/> &#39;content-length&#39; =&gt; 48<br/> }, &#39;HTTP::Headers&#39; ),<br/> &#39;_method&#39; =&gt; &#39;POST&#39;<br/>}, &#39;HTTP::Request&#39; );<br/><br/><br/><br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7225.html Thu, 18 Sep 2008 22:54:56 +0000 Re: Using LWP module in perl with Crypt::SSLeay by Tom Hukins On Thu, Sep 18, 2008 at 08:22:46AM -0400, Kathalkar, Sanket wrote:<br/>&gt; I am going to use LWP module for accessing urls which are SSL<br/>&gt; enabled. Is Crypt::SSLeay required for this?<br/><br/>The README.SSL distributed with LWP answers this:<br/>http://search.cpan.org/src/GAAS/libwww-perl-5.814/README.SSL<br/><br/>&gt; Do I need to create a certificate to access a remote server?<br/><br/>I&#39;ve never needed to: most SSL enabled Web servers don&#39;t need client<br/>certificates. But if you&#39;re running against a server that needs an<br/>SSL certificate to authenticate you, you will need to provide that<br/>certificate somehow.<br/><br/>Tom<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7224.html Thu, 18 Sep 2008 09:21:04 +0000 Using LWP module in perl with Crypt::SSLeay by Kathalkar, Sanket Hi,<br/><br/> I am going to use LWP module for accessing urls which are SSL<br/>enabled. Is Crypt::SSLeay required for this? Give me the steps to<br/>impement this. Do I need to create a certificate to access a remote<br/>server?<br/><br/> <br/><br/>Thanks and Regards,<br/><br/>Sanket Kathalkar<br/><br/> <br/><br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7223.html Thu, 18 Sep 2008 06:43:23 +0000 Re: LWP content encode by Bjoern Hoehrmann * stefano tacconi wrote:<br/>&gt;I&#39;m writing a simple script to download some web pages on the net.<br/>&gt;Using LWP it&#39;s works fine, but how can I get html page with strange<br/>&gt;characher?<br/><br/>You are probably looking for HTML::Encoding, the script in the synopsis<br/>shows how to decode the content; HTTP::Response::Encoding seems to be a<br/>rather crude module that is unaware of HTML semantics.<br/>-- <br/>Bj&ouml;rn H&ouml;hrmann &middot; mailto:bjoern@hoehrmann.de &middot; http://bjoern.hoehrmann.de<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7222.html Mon, 15 Sep 2008 08:56:07 +0000 LWP content encode by stefano tacconi Hi List,<br/><br/>I&#39;m writing a simple script to download some web pages on the net.<br/>Using LWP it&#39;s works fine, but how can I get html page with strange<br/>characher?<br/><br/>For example LWP doesn&#39;t get page with &quot;on-demand&acirc;&euro; &quot; string<br/>(on-demand%C3%A2%C2%80%C2%9D).<br/><br/>I tried in vain with Encode, HTTP::Response::Encoding.<br/><br/>if ($res-&gt;is_success){<br/> my $html_content = $res-&gt;content;<br/> #my $html_content = $res-&gt;decoded_content;<br/> #my $html_content = encode( &#39;utf8&#39;, $res-&gt;decoded_content );<br/> my $html_content = uri_escape_utf8($res-&gt;content);<br/>...<br/>...<br/><br/>LWP returns half pages, untile it finds a strange character.<br/><br/>Any suggestions?<br/><br/>S.T.<br/><br/>p.s. I read &quot;jerakeen.org/files/2005/perl-utf8.slides.pdf&quot; documentation but<br/>I&#39;ve some problem again... :)<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7221.html Mon, 15 Sep 2008 08:39:28 +0000 Re: restrict download bandwidth by libwww On Fri, 12 Sep 2008, Jan Buchholz wrote:<br/><br/>&gt; does anybody know, i could restrict the download bandwidth with<br/>&gt; LWP::UserAgent.<br/><br/>Use a slowing proxy server? Download<br/><br/> http://perlmeister.com/snapshots/200105/scripts/slowie.pl<br/><br/>and start<br/><br/> $ slowie.pl<br/> Server listening at port 8018<br/><br/>then configure LWP::UserAgent to use it<br/><br/> $ua-&gt;proxy([&#39;http&#39;], &#39;http://localhost:8018/&#39;);<br/><br/>Here&#39;s the article if you can read German:<br/> http://www.linux-magazin.de/heft_abo/ausgaben/2001/05/urlaub_in_der_steinzeit<br/><br/>-- Mike<br/><br/>Mike Schilli<br/>libwww@perlmeister.com<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7220.html Fri, 12 Sep 2008 10:13:58 +0000 restrict download bandwidth by Jan Buchholz Hallo,<br/><br/>does anybody know, i could restrict the download bandwidth with LWP::UserAgent.<br/><br/>THX<br/><br/>--<br/>Jan Buchholz<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7219.html Fri, 12 Sep 2008 03:49:03 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Gisle Aas On Sun, Sep 7, 2008 at 1:49 PM, Michael Greb &lt;mgreb@linode.com&gt; wrote:<br/>&gt; On Sep 5, 2008, at 7:23 PM, Gisle Aas wrote:<br/>&gt;&gt;<br/>&gt;&gt; True; and in this case we need to define what happens when fields are<br/>&gt;&gt; modified with &#39;push&#39;, &#39;set&#39; or &#39;init&#39; and &#39;remove&#39; as that&#39;s the API<br/>&gt;&gt; that modify stuff. Let me suggest the following definition of the<br/>&gt;&gt; behaviour:<br/>&gt;&gt;<br/>&gt;&gt; - &#39;push&#39; always append the field at the end of all headers. multiple<br/>&gt;&gt; occurrences of a field name do not have to be consecutive.<br/>&gt;&gt;<br/>&gt;&gt; - &#39;init&#39; either does nothing or it works like &#39;push&#39;.<br/>&gt;&gt;<br/>&gt;&gt; - &#39;remove&#39; will always remove all concurrences of a field.<br/>&gt;&gt;<br/>&gt;&gt; - &#39;set&#39; will work like &#39;push&#39; if no other occurrence of the field exists.<br/>&gt;&gt;<br/>&gt;&gt; - &#39;set&#39; will update the first occurrence if the field exists (and<br/>&gt;&gt; remove all other occurrences). if multiple field values is provided<br/>&gt;&gt; with &#39;set&#39; they are basically all injected at the location of the<br/>&gt;&gt; first existing value.<br/>&gt;<br/>&gt;<br/>&gt; On Sep 6, 2008 at 2:57 AM, Gisle Aas wrong:<br/>&gt;&gt;<br/>&gt;&gt; I think it makes sense to be able to enable them separately.<br/>&gt;&gt; Suggested interface:<br/>&gt;&gt;<br/>&gt;&gt; $h-&gt;scan(\&amp;cb, original_order =&gt; 1, original_case =&gt; 1);<br/>&gt;&gt; $h-&gt;as_string(eol =&gt; &quot;\n&quot;, original_order =&gt; 1, original_case =&gt; 1);&#39;<br/>&gt;<br/>&gt; The attached patch uses the interface above and works towards the behavior<br/>&gt; outlined in the first message. Due to the headers being stored as a hash,<br/>&gt; pushing does not currently preserve previous values, second and subsequent<br/>&gt; pushes of the same header will overwrite the previous value. Supporting<br/>&gt; this would require a change in how the headers are stored within the module.<br/>&gt; Your thoughts?<br/><br/>I think it&#39;s better to just use your original approach and just keep<br/>the representation like used to be with the addition of an array that<br/>records the original field names and their order. This should lead to<br/>a smaller patch as the only thing that need to change is the code that<br/>sets headers and the scan method. I also like header lockups to be<br/>efficient and the representation compact.<br/><br/>&gt; Server: Fool/1.0<br/>&gt; content-encoding: gzip<br/>&gt; Content-Type: text/plain; charset=&quot;UTF-8&quot;<br/>&gt; Content-Encoding: base64<br/>&gt; Date: Fri Sep 5 10:24:37 CEST 2008<br/>&gt;<br/>&gt; Would be stored as (assuming push_header):<br/><br/>My suggestion would be:<br/><br/>bless {<br/> &quot;content-encoding&quot; =&gt; [&quot;\n gzip&quot;, &quot;base64&quot;],<br/> &quot;content-type&quot; =&gt; &quot;text/plain; charset=\&quot;UTF-8\&quot;&quot;,<br/> &quot;date&quot; =&gt; &quot;Fri Sep 5 10:24:37 CEST 2008&quot;,<br/> &quot;server&quot; =&gt; &quot;Fool/1.0&quot;,<br/> &quot;::original_fields&quot; =&gt; [<br/> &quot;Server&quot;,<br/> &quot;content-encoding&quot;,<br/> &quot;Content-Type&quot;,<br/> &quot;Content-Encoding&quot;,<br/> &quot;Date&quot;,<br/> ],<br/>}, &quot;HTTP::Headers&quot;;<br/><br/>The invariant that needs to hold is that there is the same number of<br/>elements in {&quot;::original_fields&quot;} as there are values for all the<br/>others keys.<br/><br/>Pushing a value is trivial; only change from what we have now is<br/>appending the original field name to {&quot;::original_fields&quot;}.<br/><br/>The only state modification operation that becomes more complex is<br/>setting of a value header value. It has to:<br/><br/> - update the values in the hash as before<br/> - locate the first occurence of the field name in<br/>{&quot;::original_fields&quot;} =&gt; $idx<br/> - remove all other occurrences of the field name<br/> - splice(@{&quot;::original_fields&quot;}, $idx, 1, ($orig_field_name) x<br/>$numbers_of_values_set);<br/><br/>When &#39;scan&#39; wants to iterate over the original headers it would have<br/>to keep an index into the values array for each field that repeat.<br/><br/>An more compact representation could be to store {&quot;::original_fields&quot;}<br/>as a &quot;:&quot;-separated string; but we can think about that optimization<br/>later.<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7218.html Sun, 07 Sep 2008 06:53:55 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Michael Greb <br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7217.html Sun, 07 Sep 2008 04:49:37 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Gisle Aas On Sat, Sep 6, 2008 at 1:43 AM, Michael Greb &lt;mgreb@linode.com&gt; wrote:<br/>&gt; Should wire order imply wire case as well?<br/><br/>I think it makes sense to be able to enable them separately.<br/>Suggested interface:<br/><br/> $h-&gt;scan(\&amp;cb, original_order =&gt; 1, original_case =&gt; 1);<br/> $h-&gt;as_string(eol =&gt; &quot;\n&quot;, original_order =&gt; 1, original_case =&gt; 1);&#39;<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7216.html Fri, 05 Sep 2008 23:55:32 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Michael Greb -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/>On Sep 5, 2008, at 7:23 PM, Gisle Aas wrote:<br/>&gt; On Fri, Sep 5, 2008 at 7:49 PM, Michael Greb &lt;mgreb@linode.com&gt; wrote:<br/>&gt; As I said above I would solve the problem by not changing<br/>&gt; &#39;header_field_names&#39; at all. Do you feel the scan interface isn&#39;t<br/>&gt; good enough for your use case?<br/><br/>This makes a lot of sense and scan will suit us just fine.<br/><br/>&gt;&gt; Writing code is easy, it&#39;s deciding how that code should behave <br/>&gt;&gt; that is the<br/>&gt;&gt; hard part.<br/>&gt;<br/>&gt; True; and in this case we need to define what happens when fields are<br/>&gt; modified with &#39;push&#39;, &#39;set&#39; or &#39;init&#39; and &#39;remove&#39; as that&#39;s the API<br/>&gt; that modify stuff. Let me suggest the following definition of the<br/>&gt; behaviour:<br/>&gt;<br/>&gt; - &#39;push&#39; always append the field at the end of all headers. multiple<br/>&gt; occurrences of a field name do not have to be consecutive.<br/>&gt;<br/>&gt; - &#39;init&#39; either does nothing or it works like &#39;push&#39;.<br/>&gt;<br/>&gt; - &#39;remove&#39; will always remove all concurrences of a field.<br/>&gt;<br/>&gt; - &#39;set&#39; will work like &#39;push&#39; if no other occurrence of the field <br/>&gt; exists.<br/>&gt;<br/>&gt; - &#39;set&#39; will update the first occurrence if the field exists (and<br/>&gt; remove all other occurrences). if multiple field values is provided<br/>&gt; with &#39;set&#39; they are basically all injected at the location of the<br/>&gt; first existing value.<br/>&gt;<br/>&gt; You want to try to implement this?<br/><br/>Yes. Have a good chance of losing net connectivity at home this <br/>weekend so this makes for a perfect no Internets required weekend <br/>project ;)<br/><br/>Should wire order imply wire case as well?<br/><br/>- --<br/>Michael Greb<br/>Linode.com<br/><br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.4.7 (Darwin)<br/><br/>iD8DBQFIwcQ90Qbp4bPZvesRAhgBAJ4tt5Gf4T6Pv+cjOA29nFRdkALrsQCg1er8<br/>njeuK0Lt4ZFAJZaIt13q8dY=<br/>=0L3l<br/>-----END PGP SIGNATURE-----<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7215.html Fri, 05 Sep 2008 16:44:35 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Gisle Aas On Fri, Sep 5, 2008 at 7:49 PM, Michael Greb &lt;mgreb@linode.com&gt; wrote:<br/>&gt; On Sep 5, 2008, at 4:29 AM, Gisle Aas wrote:<br/>&gt;&gt;<br/>&gt;&gt; Hi Michael,<br/>&gt;&gt;<br/>&gt;&gt; This seems like a very useful addition to libwww-perl. I have been<br/>&gt;&gt; wanting a mode where $response-&gt;as_string would show responses exactly<br/>&gt;&gt; as they where received without adding, or reordering of the headers<br/>&gt;&gt; or even fix up the casing for the header field names. A patch like<br/>&gt;&gt; yours should make this much easier.<br/>&gt;&gt;<br/>&gt;&gt; Your patch does not address the preserving-of-case for header filed<br/>&gt;&gt; names. Is that not required for your signing server?<br/>&gt;<br/>&gt; We join the values of the signed headers without the name of the header so<br/>&gt; case doesn&#39;t matter for us. That said, it certainly makes sense to store<br/>&gt; the headers in their original case in _wire_order rather than the normalized<br/>&gt; version. Should the header_field_names and the pass method both then return<br/>&gt; the headers in the original case when dont_sort is passed?<br/><br/>I think I would prefer to leave &#39;header_field_names&#39; alone and only<br/>support original field order and field name casing for the &#39;scan&#39; and<br/>&#39;as_string&#39; methods. This since &#39;header_field_names&#39; is documented to<br/>not repeat field names, while the others do.<br/><br/>&gt;&gt; It also seems your approach makes it hard to deal correctly with<br/>&gt;&gt; repeated headers mixed in with others; for instance something like<br/>&gt;&gt; this ugly response:<br/>&gt;&gt;<br/>&gt;&gt; 200 OK<br/>&gt;&gt; Server: Fool/1.0<br/>&gt;&gt; content-encoding :<br/>&gt;&gt; gzip<br/>&gt;&gt; Content-Type: text/plain; charset=&quot;UTF-8&quot;<br/>&gt;&gt; Content-Encoding: base64<br/>&gt;&gt; Date: Fri Sep 5 10:24:37 CEST 2008<br/>&gt;&gt;<br/>&gt;&gt; H4sICETrwEgAA3h4eADLSM3JyVcozy/KSVHkAgC0r9cBDQAAAA==<br/>&gt;&gt;<br/>&gt;&gt; Your thoughts?<br/>&gt;<br/>&gt;<br/>&gt; I&#39;m not sure exactly what the right way to handle this would be.<br/>&gt; header_field_names is speced in the docs as returning only the distinct<br/>&gt; header field names. Perhaps rather than an optional dont_sort argument this<br/>&gt; should be a new method, something like &#39;wire_header_fields&#39; that returns all<br/>&gt; headers in the original case and order including duplicates? This also<br/>&gt; relates to the as_string method and your desire to have a mode that returns<br/>&gt; things in thier original form.<br/><br/>As I said above I would solve the problem by not changing<br/>&#39;header_field_names&#39; at all. Do you feel the scan interface isn&#39;t<br/>good enough for your use case?<br/><br/>&gt; Writing code is easy, it&#39;s deciding how that code should behave that is the<br/>&gt; hard part.<br/><br/>True; and in this case we need to define what happens when fields are<br/>modified with &#39;push&#39;, &#39;set&#39; or &#39;init&#39; and &#39;remove&#39; as that&#39;s the API<br/>that modify stuff. Let me suggest the following definition of the<br/>behaviour:<br/><br/>- &#39;push&#39; always append the field at the end of all headers. multiple<br/>occurrences of a field name do not have to be consecutive.<br/><br/>- &#39;init&#39; either does nothing or it works like &#39;push&#39;.<br/><br/>- &#39;remove&#39; will always remove all concurrences of a field.<br/><br/>- &#39;set&#39; will work like &#39;push&#39; if no other occurrence of the field exists.<br/><br/>- &#39;set&#39; will update the first occurrence if the field exists (and<br/>remove all other occurrences). if multiple field values is provided<br/>with &#39;set&#39; they are basically all injected at the location of the<br/>first existing value.<br/><br/>You want to try to implement this?<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7214.html Fri, 05 Sep 2008 16:23:42 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Michael Greb -----BEGIN PGP SIGNED MESSAGE-----<br/>Hash: SHA1<br/><br/>On Sep 5, 2008, at 4:29 AM, Gisle Aas wrote:<br/>&gt; Hi Michael,<br/>&gt;<br/>&gt; This seems like a very useful addition to libwww-perl. I have been<br/>&gt; wanting a mode where $response-&gt;as_string would show responses exactly<br/>&gt; as they where received without adding, or reordering of the headers<br/>&gt; or even fix up the casing for the header field names. A patch like<br/>&gt; yours should make this much easier.<br/>&gt;<br/>&gt; Your patch does not address the preserving-of-case for header filed<br/>&gt; names. Is that not required for your signing server?<br/><br/>We join the values of the signed headers without the name of the <br/>header so case doesn&#39;t matter for us. That said, it certainly makes <br/>sense to store the headers in their original case in _wire_order <br/>rather than the normalized version. Should the header_field_names and <br/>the pass method both then return the headers in the original case when <br/>dont_sort is passed?<br/><br/>&gt; It also seems your approach makes it hard to deal correctly with<br/>&gt; repeated headers mixed in with others; for instance something like<br/>&gt; this ugly response:<br/>&gt;<br/>&gt; 200 OK<br/>&gt; Server: Fool/1.0<br/>&gt; content-encoding :<br/>&gt; gzip<br/>&gt; Content-Type: text/plain; charset=&quot;UTF-8&quot;<br/>&gt; Content-Encoding: base64<br/>&gt; Date: Fri Sep 5 10:24:37 CEST 2008<br/>&gt;<br/>&gt; H4sICETrwEgAA3h4eADLSM3JyVcozy/KSVHkAgC0r9cBDQAAAA==<br/>&gt;<br/>&gt; Your thoughts?<br/><br/><br/>I&#39;m not sure exactly what the right way to handle this would be. <br/>header_field_names is speced in the docs as returning only the <br/>distinct header field names. Perhaps rather than an optional <br/>dont_sort argument this should be a new method, something like <br/>&#39;wire_header_fields&#39; that returns all headers in the original case and <br/>order including duplicates? This also relates to the as_string method <br/>and your desire to have a mode that returns things in thier original <br/>form.<br/><br/>Writing code is easy, it&#39;s deciding how that code should behave that <br/>is the hard part.<br/><br/>Mike<br/><br/>- --<br/>Michael Greb<br/>Linode.com<br/>609-593-7103 ext 1205<br/><br/><br/><br/>-----BEGIN PGP SIGNATURE-----<br/>Version: GnuPG v1.4.7 (Darwin)<br/><br/>iD8DBQFIwXFH0Qbp4bPZvesRAn5GAJ9KmpEkjkbfWSPgkSp3ikR1htcNTwCfad0p<br/>ClhR1t38odclA0rpBtnXFTc=<br/>=nkoH<br/>-----END PGP SIGNATURE-----<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7213.html Fri, 05 Sep 2008 10:50:40 +0000 Re: [PATCH] FIFO header order support in HTTP::Headers by Gisle Aas Hi Michael,<br/><br/>This seems like a very useful addition to libwww-perl. I have been<br/>wanting a mode where $response-&gt;as_string would show responses exactly<br/>as they where received without adding, or reordering of the headers<br/>or even fix up the casing for the header field names. A patch like<br/>yours should make this much easier.<br/><br/>Your patch does not address the preserving-of-case for header filed<br/>names. Is that not required for your signing server?<br/><br/>It also seems your approach makes it hard to deal correctly with<br/>repeated headers mixed in with others; for instance something like<br/>this ugly response:<br/><br/> 200 OK<br/> Server: Fool/1.0<br/> content-encoding :<br/> gzip<br/> Content-Type: text/plain; charset=&quot;UTF-8&quot;<br/> Content-Encoding: base64<br/> Date: Fri Sep 5 10:24:37 CEST 2008<br/><br/> H4sICETrwEgAA3h4eADLSM3JyVcozy/KSVHkAgC0r9cBDQAAAA==<br/><br/>Your thoughts?<br/><br/>--Gisle<br/><br/><br/><br/><br/>On Thu, Sep 4, 2008 at 9:35 PM, Michael Greb &lt;mgreb@linode.com&gt; wrote:<br/>&gt; Greetings,<br/>&gt;<br/>&gt; We are currently using HTTP::Daemon to prototype a project and have a need<br/>&gt; to access headers in the order they were sent over the network. Our<br/>&gt; particular use case is cryptographically signing a subset of the headers and<br/>&gt; sending this signature as an additional header.<br/>&gt;<br/>&gt; A specified set of headers are to be included in the signature if present in<br/>&gt; the request. We join the content of these headers (with &quot;\n&quot;) then<br/>&gt; calculate the expected signature and compare it to the value submitted by<br/>&gt; the client. In order to get the same signature, we must join the header<br/>&gt; content in the same order as the client. If we only needed to support perl<br/>&gt; clients using LWP::UserAgent, this wouldn&#39;t be an issue as HTTP::Daemon and<br/>&gt; LWP::UserAgent both use HTTP::Headers and the order the headers will be<br/>&gt; presented to the consuming script is predictable. Unfortunately, we must<br/>&gt; support multiple languages.<br/>&gt;<br/>&gt; The HTTP client is allowed to join the headers in preparation for signing in<br/>&gt; any order it wishes so long as it then sends the headers in the same order<br/>&gt; over the network. The attached patch stores the order headers are added to<br/>&gt; the HTTP::Headers object in an arrayref ($self-&gt;{_wire_order}). The<br/>&gt; header_field_names and scan methods are extended to take an optional value<br/>&gt; that if present and true cause the headers to be returned/visited based on<br/>&gt; the order of elements in $self-&gt;{_wire_order} rather than the existing &#39;best<br/>&gt; practices&#39; order. The next logical step would be similar extension to the<br/>&gt; as_string method.<br/>&gt;<br/>&gt; This code has been tested and, thanks to great tests, I was able to catch<br/>&gt; missing the clear method in my first go at the functionality. All tests<br/>&gt; currently pass except for a few[1] that seem to be related to the new<br/>&gt; run_handler method[2]. I&#39;m a bit unsure that the push within the _header<br/>&gt; method does the right thing in all cases (particularly adding an additional<br/>&gt; value to an existing header and replacing an existing header with a new<br/>&gt; value).<br/>&gt;<br/>&gt; This patch does include an update to the relevant docs but does not include<br/>&gt; new tests. Should the functionality be deemed useful for inclusion in<br/>&gt; libwww-perl I can go ahead and extend the as_string method and add some new<br/>&gt; tests to match the new functionality.<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7212.html Fri, 05 Sep 2008 01:29:59 +0000 [PATCH] FIFO header order support in HTTP::Headers by Michael Greb <br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7211.html Thu, 04 Sep 2008 12:36:09 +0000 Re: HTTP/Cookies.pm bug? by Gisle Aas On Sep 4, 2008, at 07:06, Russ Schnapp wrote:<br/><br/>&gt; I&#39;m not sure whether you&#39;re still interested in this, but I think <br/>&gt; I&#39;ve come across a bug in HTTP::Cookies. If you&#39;re not the right <br/>&gt; person for me to handle this, please let me know who is.<br/><br/>I&#39;m the right one; but it&#39;s usually best to send requests like this <br/>to the libwww mailing list. Cc:-ed.<br/><br/>&gt; The problem is in add_cookie_header. If the cookie version is <br/>&gt; nonzero and the cookie contents include a non-alpha (\W) character, <br/>&gt; it escapes any quotes or slashes in the cookie value.<br/><br/>Why do you specify an nonzero version number without using the Set- <br/>Cookie2 header?<br/><br/>I&#39;m thinking that the right fix for this might be to just force <br/>&#39;version=0&#39; for any cookie set with &#39;Set-Cookie&#39;. This patch achieve <br/>that:<br/><br/>--- a/lib/HTTP/Cookies.pm<br/>+++ b/lib/HTTP/Cookies.pm<br/>@@ -237,6 +237,9 @@ sub extract_cookies<br/> $expires++;<br/> }<br/> }<br/>+ elsif (!$first_param &amp;&amp; lc($k) =~ /^(?:version| <br/>discard|ns-cookie)/) {<br/>+ # ignore<br/>+ }<br/> else {<br/> push(@cur, $k =&gt; $v);<br/> }<br/><br/>&gt;<br/>&gt; The problem arises when the server has delivered a cookie value <br/>&gt; that is ENCLOSED in quotes, i.e.,<br/>&gt; Set-Cookie: member=&quot;whatever&quot;; version=1; Path=/<br/>&gt;<br/>&gt; When it comes time for add_cookie_header to do its thing, it generates<br/>&gt; Cookie: member=&quot;\&quot;whatever\&quot;&quot;; $Path=&quot;/&quot;<br/>&gt; Cookie2: $Version=&quot;1&quot;<br/>&gt;<br/>&gt; I guess there are 2 bugs here:<br/>&gt; 1) The biggest problem is with the quoting. I think I&#39;ve fixed <br/>&gt; this by inserting one line in Cookies.pm:<br/>&gt;<br/>&gt; # do we need to quote the value<br/>&gt; if ($val =~ /\W/ &amp;&amp; $version) {<br/>&gt; $val =~ s/^&quot;(.*)&quot;$/$1/; ### RLS 9/3/08<br/>&gt; $val =~ s/([\\\&quot;])/\\$1/g;<br/>&gt; $val = qq(&quot;$val&quot;);<br/>&gt; }<br/>&gt;<br/>&gt; 2) The second problem is with the treatment of the Path and version <br/>&gt; fields. They appear to be treated as if they were cookie values. <br/>&gt; And yet they are transmitted with a prefix of &quot;$&quot;. I REALLY don&#39;t <br/>&gt; understand what&#39;s going on here, and I&#39;m not inclined to mess with it.<br/><br/>Read RFC 2965 if you want to understand the deal with $Path and <br/>$Version.<br/><br/>--Gisle<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7210.html Thu, 04 Sep 2008 01:22:22 +0000 Re: Effect of Namespaces in XHTML on Headers by Gisle Aas On Mon, Sep 1, 2008 at 11:15 AM, Phil Archer &lt;parcher@fosi.org&gt; wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; I&#39;ve used LWP in several apps in which the key bit of information I&#39;m after<br/>&gt; is the headers. I&#39;ve therefore got used to the fact that if the returned<br/>&gt; resource is HTML, one of the triggers for &quot;OK, that&#39;s all the headers and<br/>&gt; everything else must be content&quot; is the presence of anything in the &lt;head&gt;<br/>&gt; section of the document that LWP doesn&#39;t recognise.<br/>&gt;<br/>&gt; Take this, for example:<br/>&gt;<br/>&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;<br/>&gt; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br/>&gt; &lt;html<br/>&gt; xmlns:creativeCommons=&#39;http://backend.userland.com/creativeCommonsRssModule&#39;<br/>&gt; xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;ltr&quot; lang=&quot;en-US&quot;&gt;<br/>&gt;<br/>&gt; &lt;creativeCommons:license&gt;http://creativecommons.org/licenses/by-nc-nd/3.0/&lt;/creativeCommons:license&gt;<br/>&gt;<br/>&gt; &lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;<br/>&gt; ...<br/>&gt;<br/>&gt; Perfectly valid XHTML - but... LWP doesn&#39;t recognise the &lt;creativecommons...<br/>&gt; tag and so stops parsing the headers.<br/>&gt;<br/>&gt; The User Agent package I&#39;m using is version 2.31<br/>&gt;<br/>&gt; So, some questions:<br/>&gt;<br/>&gt; 1. Which modules need updating so that LWP can recognise this kind of thing<br/>&gt; as valid &lt;head&gt; content<br/><br/>It&#39;s the HTML::HeadParser module in the HTML-Parser dist.<br/><br/>&gt; 2. Has anyone written such a module?<br/><br/>Not that I know about.<br/><br/>&gt;<br/>&gt; As a demonstration, [1] and [2] show the status line, headers_as_string and<br/>&gt; content from two versions of the same document, the only difference between<br/>&gt; the two being that in [2], the &lt;creativecommons..&gt; tag is commented out. You<br/>&gt; can get this output from any URI using the form at [3].<br/>&gt;<br/>&gt; Thanks for any help<br/>&gt;<br/>&gt; Phil.<br/>&gt;<br/>&gt; [1]<br/>&gt; http://www.icra.org/cgi-bin/HTTP_Headers.cgi?url=http%3A%2F%2Fwww.icra.org%2Flabel%2FHTTP-Test%2Fspace.htm<br/>&gt; [2]<br/>&gt; http://www.icra.org/cgi-bin/HTTP_Headers.cgi?url=http%3A%2F%2Fwww.icra.org%2Flabel%2FHTTP-Test%2Fspace-mod.htm<br/>&gt; [3] http://www.icra.org/label/HTTP-Test/<br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7209.html Thu, 04 Sep 2008 00:01:37 +0000 Effect of Namespaces in XHTML on Headers by Phil Archer Hi,<br/><br/>I&#39;ve used LWP in several apps in which the key bit of information I&#39;m <br/>after is the headers. I&#39;ve therefore got used to the fact that if the <br/>returned resource is HTML, one of the triggers for &quot;OK, that&#39;s all the <br/>headers and everything else must be content&quot; is the presence of anything <br/>in the &lt;head&gt; section of the document that LWP doesn&#39;t recognise.<br/><br/>Take this, for example:<br/><br/>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; <br/>&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br/>&lt;html <br/>xmlns:creativeCommons=&#39;http://backend.userland.com/creativeCommonsRssModule&#39;<br/> xmlns=&quot;http://www.w3.org/1999/xhtml&quot; dir=&quot;ltr&quot; lang=&quot;en-US&quot;&gt;<br/><br/>&lt;creativeCommons:license&gt;http://creativecommons.org/licenses/by-nc-nd/3.0/&lt;/creativeCommons:license&gt;<br/><br/>&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;<br/>...<br/><br/>Perfectly valid XHTML - but... LWP doesn&#39;t recognise the <br/>&lt;creativecommons... tag and so stops parsing the headers.<br/><br/>The User Agent package I&#39;m using is version 2.31<br/><br/>So, some questions:<br/><br/>1. Which modules need updating so that LWP can recognise this kind of <br/>thing as valid &lt;head&gt; content<br/><br/>2. Has anyone written such a module?<br/><br/>As a demonstration, [1] and [2] show the status line, headers_as_string <br/>and content from two versions of the same document, the only difference <br/>between the two being that in [2], the &lt;creativecommons..&gt; tag is <br/>commented out. You can get this output from any URI using the form at [3].<br/><br/>Thanks for any help<br/><br/>Phil.<br/><br/>[1] <br/>http://www.icra.org/cgi-bin/HTTP_Headers.cgi?url=http%3A%2F%2Fwww.icra.org%2Flabel%2FHTTP-Test%2Fspace.htm<br/>[2] <br/>http://www.icra.org/cgi-bin/HTTP_Headers.cgi?url=http%3A%2F%2Fwww.icra.org%2Flabel%2FHTTP-Test%2Fspace-mod.htm<br/>[3] http://www.icra.org/label/HTTP-Test/<br/><br/>-- <br/>Phil Archer<br/>Chief Technical Officer,<br/>Family Online Safety Institute<br/>w. http://www.fosi.org/people/philarcher/<br/><br/>Register now for the annual Family Online Safety Institute Conference <br/>and Exhibition, December 11th, 2008, Washington, DC.<br/>See http://www.fosi.org/conference2008/<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/09/msg7208.html Mon, 01 Sep 2008 02:16:10 +0000 IPv6 & libwww by Andre-John Mas Hi,<br/><br/>I have made some changes to libwww to support IPv6, but in doing so I <br/>seem to have lost IPv4 capability. I am not an expert in Perl and <br/>would appreciate if someone could look at my code and work out what is <br/>wrong. The version I am working on is simply to allow people to have <br/>IPv6 access until people are ready to add IPv6 support to the official <br/>build.<br/><br/>If you think you can help, please could you let me know.<br/><br/>Andr&eacute; http://www.nntp.perl.org/group/perl.libwww/2008/08/msg7207.html Sun, 24 Aug 2008 09:04:55 +0000 Bug when sending 100 Continue header? by Rainer Johanni Hi<br/><br/>when chasing an interoperatibility problem between a SOAP::Lite server and a Microsoft .NET client I dedected that there is obviously a bug in HTTP::Daemon.pm:<br/><br/>When a request contains the &quot;Excpect: 100-continue&quot; header, the code in HTTP::Daemon.pm reacts with sending<br/><br/>100 Continue&lt;CRLF&gt; (with 1 CRLF)<br/><br/>This causes the Microsoft client to hang because it expects obiously 2 CRLFs after the 100 Continue header.<br/><br/>I don&#39;t know the RPC but shouldn&#39;t be there 2 CRLFs (i.e. a line &quot;100 Continue&quot; followed by an empty line)?<br/><br/>Can anybody fix this?<br/><br/>Regards<br/>Rainer<br/> http://www.nntp.perl.org/group/perl.libwww/2008/08/msg7206.html Sat, 23 Aug 2008 01:59:59 +0000 Re: Form parsing issue? by theevancarroll I&#39;ve just created a module that will help you with the task of<br/>automating ASP.NET sites. Please check out HTML::TreeBuilderX::ASP_NET<br/>and HTML::TreeBuilderX::ASP_NET::Roles::htmlElement and give some feed<br/>back.<br/><br/> HTML::TreeBuilderX::ASP_NET-&gt;new_with_traits( traits =&gt;<br/>[&#39;htmlElement&#39;] );<br/><br/> ## returns a HTTP::Request for the form<br/> $root-&gt;look_down( &#39;_tag&#39; =&gt; &#39;a&#39; )-&gt;httpRequest( $hashRef );<br/><br/>Evan Carroll<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/08/msg7205.html Fri, 22 Aug 2008 14:14:50 +0000 Mechanize Redirect by Merdinus <br/>Have seen this issue addressed on this board in the past, but can&#39;t<br/>figure out exactly what I need to do.<br/><br/>I&#39;m using WWW::Mechanize and a webpage seems to be redirecting me but<br/>Mechanize doesn&#39;t seem to follow it. I&#39;ve heard to &quot;Add the header<br/>&#39;Accept: text/html&#39;&quot; but alas I don&#39;t know how to add the header, or<br/>what that means.<br/><br/>I suspect the solution is simple belief - but alas I&#39;m not coming up<br/>with it. Any help would be much appreciated.<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/08/msg7204.html Sat, 09 Aug 2008 03:47:47 +0000 Re: Facing Problem HTML::Parser by Gisle Aas In order to build and install modules like HTML::Parser from source<br/>you basically need the same compiler environment that was used to<br/>build perl itself. The &#39;cl&#39; program that you are missing is the<br/>Microsoft C compiler.<br/><br/>Which perl are you using? Can I suggest that you just try ActivePerl<br/>since it comes LWP and releated modules ready to go.<br/><br/>Regards,<br/>Gisle<br/><br/>On Fri, Jul 18, 2008 at 10:37 AM, jeyasimhan m &lt;jai_dgl@yahoo.co.in&gt; wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; When I try to install HTML::Parser as well as Bundle::LWP I&#39;m getting this following error<br/>&gt;<br/>&gt; perl -MCPAN -e &quot;install Bundle::LWP&quot;<br/>&gt;<br/>&gt; C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils\xsubpp -typemap C:\Perl\lib\ExtUtils\typemap -typemap typemap Parser.xs &gt; Parser.xsc &amp;&amp; C:\Perl\bin\perl.exe -MExtUtils::Command -e mv Parser.xsc Parser.c<br/>&gt; cl -c -nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1 -DVERSION=\&quot;3.56\&quot; -DXS_VERSION=\&quot;3.56\&quot; &quot;-IC:\Perl\lib\CORE&quot; -DMARKED_SECTION Parser.c<br/>&gt; &#39;cl&#39; is not recognized as an internal or external command,<br/>&gt; operable program or batch file.<br/>&gt; NMAKE : fatal error U1077: &#39;C:\WINDOWS\system32\cmd.exe&#39; : return code &#39;0x1&#39;<br/>&gt;<br/>&gt;<br/>&gt; Please help me to install these modules<br/>&gt;<br/>&gt; Thanks<br/>&gt; Jey<br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7203.html Fri, 18 Jul 2008 11:01:26 +0000 Facing Problem HTML::Parser by jeyasimhan m Hi,<br/><br/>When I try to install HTML::Parser as well as Bundle::LWP I&#39;m getting this following error<br/><br/>perl -MCPAN -e &quot;install Bundle::LWP&quot;<br/><br/> C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils\xsubpp -typemap C:\Perl\lib\ExtUtils\typemap -typemap typemap Parser.xs &gt; Parser.xsc &amp;&amp; C:\Perl\bin\perl.exe -MExtUtils::Command -e mv Parser.xsc Parser.c<br/> cl -c -nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1 -DVERSION=\&quot;3.56\&quot; -DXS_VERSION=\&quot;3.56\&quot; &quot;-IC:\Perl\lib\CORE&quot; -DMARKED_SECTION Parser.c<br/>&#39;cl&#39; is not recognized as an internal or external command,<br/>operable program or batch file.<br/>NMAKE : fatal error U1077: &#39;C:\WINDOWS\system32\cmd.exe&#39; : return code &#39;0x1&#39;<br/><br/><br/>Please help me to install these modules<br/><br/>Thanks<br/>Jey<br/><br/><br/> <br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7202.html Fri, 18 Jul 2008 09:05:27 +0000 Re: Accept-Encoding defaults by Gisle Aas On Sun, Jul 6, 2008 at 7:06 PM, Bill Moseley &lt;moseley@hank.org&gt; wrote:<br/>&gt; On Sun, Jul 06, 2008 at 02:36:10PM +0200, Gisle Aas wrote:<br/>&gt;&gt; &gt; $req-&gt;set_default_accept_encoding;<br/>&gt;&gt;<br/>&gt;&gt; I don&#39;t like defaults to be set at that level given that we already<br/>&gt;&gt; have a $ua-&gt;default_header() method, so I think it should be something<br/>&gt;&gt; like:<br/>&gt;&gt;<br/>&gt;&gt; $ua-&gt;default_header(&quot;Accept-Encoding&quot;, join(&quot;,&quot;,<br/>&gt;&gt; HTTP::Message::decodable()));<br/>&gt;<br/>&gt; I saw this yesterday, too, about in the absence of an Accept-Encoding<br/>&gt; server &quot;MAY&quot; send any encoding.<br/>&gt;<br/>&gt; http://use.perl.org/~rhesa/journal/25952<br/>&gt;<br/>&gt; That may be one argument for having a default, but in practice I&#39;d<br/>&gt; expect it very rare for a server to compress w/o an Accept-Encoding<br/>&gt; header sent by the client.<br/><br/>I think it&#39;s correct to not have a default by default. The library<br/>can&#39;t really know what&#39;s acceptable without the app telling it. If<br/>the app for instance wants to mirror the file then the encoding does<br/>not matter. All it cares about is storing the bytes as sent from the<br/>server.<br/><br/>I&#39;ve now implemented a HTTP::Message::decodable() function with this patch:<br/><br/> http://gitorious.org/projects/libwww-perl/repos/mainline/commits/7721a0b0dbf4b4f8c2201c5e70b7c3762137a8dc<br/><br/>Please review.<br/><br/>&gt;&gt; &gt; I&#39;m not clear if there&#39;s a need to also specify a quality for the<br/>&gt;&gt; &gt; encodings in the Accept-Encoding header.<br/>&gt;&gt;<br/>&gt;&gt; I don&#39;t think we need to worry about this initially.<br/>&gt;<br/>&gt; And the RFC says qvalues are not permitted with x-gzip and z-compress.<br/><br/>Good.<br/><br/>&gt;<br/>&gt;&gt; &gt; I kind of wonder why $res-&gt;content is not decoded by default (and<br/>&gt;&gt; &gt; provide $res-&gt;raw_content for those that need it).<br/>&gt;&gt;<br/>&gt;&gt; It&#39;s mostly because of history and compatibility with the original<br/>&gt;&gt; content() method. Both are useful in different contexts. I don&#39;t<br/>&gt;&gt; find the current situation bad. Since decoded_content() can be<br/>&gt;&gt; expensive and can fail I think the longer name makes it obvious what&#39;s<br/>&gt;&gt; going on how you should use it.<br/>&gt;<br/>&gt; Agreed, it&#39;s not something that could change. I was just lamenting<br/>&gt; how often I see $res-&gt;content used in existing programs and modules.<br/>&gt;<br/>&gt; I don&#39;t see using $res-&gt;decoded_content as more expensive. If you<br/>&gt; need decoded content (which is likely the typical use) then you have<br/>&gt; to decode it -- no way around that.<br/><br/>Right. But there are apps that don&#39;t need this too. Also knowing<br/>that it might be expensive might give you the hint needed to<br/>understand that you might want to cache the result of decoded_content<br/>instead of calling it over and over for the same message. That is<br/>code like this might not be a good idea:<br/><br/> if ($res-&gt;decoded_content =~ /&lt;html&gt;/) {<br/> print $res-&gt;decoded_content<br/> }<br/> elsif ($res-&gt;decoded_content =~ /foo/) {<br/> #...<br/> }<br/> elsif ($res-&gt;decoded_content =~ /bar/) {<br/> # ...<br/> }<br/><br/><br/>&gt;<br/>&gt;<br/>&gt; I can only guess that the beginners are more likely to use<br/>&gt; $res-&gt;content directly (as that&#39;s the example in the SYNOPSIS) and<br/>&gt; they perhaps are on slower connections where compression would help<br/>&gt; both the server and client. But, it&#39;s not breaking anything to not<br/>&gt; use compression.<br/>&gt;<br/>&gt; Ignoring decoding (charset), on the other hand, is probably wrong in<br/>&gt; most cases -- even though it&#39;s easy to ignore.<br/>&gt;<br/>&gt;<br/>&gt; You have this in the SYNOPSIS of LWP::UserAgent:<br/>&gt;<br/>&gt; if ($response-&gt;is_success) {<br/>&gt; print $response-&gt;content; # or whatever<br/>&gt; }<br/>&gt;<br/>&gt; which is, perhaps accidentally, correct since you are printing<br/>&gt; un-decoded (charset) content. But, I doubt most users are just using<br/>&gt; LWP to print content out directly.<br/>&gt;<br/>&gt; How would you feel about providing new users with more guidance in the<br/>&gt; SYNOPSIS? That is, use decoded_content in the synopsis for those of<br/>&gt; us that often don&#39;t get past that section of the man page.<br/>&gt;<br/>&gt; if ($response-&gt;is_success) {<br/>&gt; $content = $response-&gt;decoded_content;<br/>&gt; }<br/><br/>I&#39;ve changed this occurence now. I also noticed that other places<br/>already used decoded_content in similar examples so this is just an<br/>oversight because these examples predates the decoded_content method.<br/><br/>&gt;<br/>&gt; Now, I suspect that LWP::Simple really should be returning<br/>&gt; decoded_content -- but again, I don&#39;t know how to to change that one<br/>&gt; without breaking a large number of existing scripts.<br/><br/>I&#39;m not sure either. Perhaps just document it better.<br/><br/>&gt;<br/>&gt;<br/>&gt; I think I asked about this some time ago, but might be good for<br/>&gt; HTTP::Message to have decoded_content wrap two methods for<br/>&gt; un-compressing and the charset decoding. There might be a case where<br/>&gt; we would want uncompressing but not decoding.<br/><br/>You get that by calling $mess-&gt;decoded_content(charset =&gt; &quot;none&quot;)<br/><br/>I don&#39;t think there is a use-case for trying to decode the charset<br/>without undoing the Content-Encoding first.<br/><br/>&gt; Hum, I&#39;m not clear about this, but I wonder if the response content is XML<br/>&gt; that will be passed to, say, XML::LibXML should it be passed decoded<br/>&gt; or not.<br/><br/>You just have to read the documentation for XML::LibXML to find out<br/>what kind of input it expects. Does it want Unicode strings or bytes?<br/> LWP can provide both.<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7201.html Tue, 15 Jul 2008 04:25:26 +0000 CPAN install fails on https test cases? by David Cortesi I am assisting someone at long distance who is attempting to do a cpan<br/>install Bundle::LWP.<br/><br/>Her make fails on just one test line, quote<br/><br/>live/https................FAILED tests 1-2<br/><br/>Failed 2/2 tests, 0.00% okay<br/><br/>Is there serious or trivial? Can I advise her to go ahead and force the<br/>install, or what should she look at to get the test to run?<br/><br/>Thanks for your advice,<br/><br/>Dave Cortesi<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7200.html Sun, 06 Jul 2008 11:49:17 +0000 Re: Accept-Encoding defaults by Bill Moseley On Sun, Jul 06, 2008 at 02:36:10PM +0200, Gisle Aas wrote:<br/>&gt; &gt; $req-&gt;set_default_accept_encoding;<br/>&gt; <br/>&gt; I don&#39;t like defaults to be set at that level given that we already<br/>&gt; have a $ua-&gt;default_header() method, so I think it should be something<br/>&gt; like:<br/>&gt; <br/>&gt; $ua-&gt;default_header(&quot;Accept-Encoding&quot;, join(&quot;,&quot;,<br/>&gt; HTTP::Message::decodable()));<br/><br/>I saw this yesterday, too, about in the absence of an Accept-Encoding<br/>server &quot;MAY&quot; send any encoding.<br/><br/> http://use.perl.org/~rhesa/journal/25952<br/><br/>That may be one argument for having a default, but in practice I&#39;d<br/>expect it very rare for a server to compress w/o an Accept-Encoding<br/>header sent by the client.<br/><br/>&gt; &gt; I&#39;m not clear if there&#39;s a need to also specify a quality for the<br/>&gt; &gt; encodings in the Accept-Encoding header.<br/>&gt; <br/>&gt; I don&#39;t think we need to worry about this initially.<br/><br/>And the RFC says qvalues are not permitted with x-gzip and z-compress.<br/><br/>&gt; &gt; I kind of wonder why $res-&gt;content is not decoded by default (and<br/>&gt; &gt; provide $res-&gt;raw_content for those that need it).<br/>&gt; <br/>&gt; It&#39;s mostly because of history and compatibility with the original<br/>&gt; content() method. Both are useful in different contexts. I don&#39;t<br/>&gt; find the current situation bad. Since decoded_content() can be<br/>&gt; expensive and can fail I think the longer name makes it obvious what&#39;s<br/>&gt; going on how you should use it.<br/><br/>Agreed, it&#39;s not something that could change. I was just lamenting<br/>how often I see $res-&gt;content used in existing programs and modules.<br/><br/>I don&#39;t see using $res-&gt;decoded_content as more expensive. If you<br/>need decoded content (which is likely the typical use) then you have<br/>to decode it -- no way around that.<br/><br/><br/>I can only guess that the beginners are more likely to use<br/>$res-&gt;content directly (as that&#39;s the example in the SYNOPSIS) and<br/>they perhaps are on slower connections where compression would help<br/>both the server and client. But, it&#39;s not breaking anything to not<br/>use compression.<br/><br/>Ignoring decoding (charset), on the other hand, is probably wrong in<br/>most cases -- even though it&#39;s easy to ignore.<br/><br/><br/>You have this in the SYNOPSIS of LWP::UserAgent:<br/><br/> if ($response-&gt;is_success) {<br/> print $response-&gt;content; # or whatever<br/> }<br/><br/>which is, perhaps accidentally, correct since you are printing<br/>un-decoded (charset) content. But, I doubt most users are just using<br/>LWP to print content out directly.<br/><br/>How would you feel about providing new users with more guidance in the<br/>SYNOPSIS? That is, use decoded_content in the synopsis for those of<br/>us that often don&#39;t get past that section of the man page.<br/><br/> if ($response-&gt;is_success) {<br/> $content = $response-&gt;decoded_content;<br/> }<br/><br/>Now, I suspect that LWP::Simple really should be returning<br/>decoded_content -- but again, I don&#39;t know how to to change that one<br/>without breaking a large number of existing scripts.<br/><br/><br/>I think I asked about this some time ago, but might be good for<br/>HTTP::Message to have decoded_content wrap two methods for<br/>un-compressing and the charset decoding. There might be a case where<br/>we would want uncompressing but not decoding.<br/><br/>Hum, I&#39;m not clear about this, but I wonder if the response content is XML<br/>that will be passed to, say, XML::LibXML should it be passed decoded<br/>or not.<br/><br/><br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7199.html Sun, 06 Jul 2008 10:06:38 +0000 Re: Accept-Encoding defaults by Gisle Aas On Sat, Jul 5, 2008 at 6:39 PM, Bill Moseley &lt;moseley@hank.org&gt; wrote:<br/>&gt; HTTP::Message has a decoded_content() method that will attempt<br/>&gt; to uncompress based on the Content-Encoding header in the response.<br/>&gt;<br/>&gt; It&#39;s wrapped in an eval which will trap exceptions when trying to<br/>&gt; require the modules used to uncompress the content.<br/>&gt;<br/>&gt; It would make sense that I would set Accept-Encoding based on if I<br/>&gt; have those modules installed.<br/><br/>RIght.<br/><br/>&gt; Since the list of modules (Compress::Zlib and Compress::Bzip2) is<br/>&gt; internal to HTTP::Message, would it make sense to provide a method<br/>&gt; that could set the Accept-Encoding based on what HTTP::Message uses?<br/>&gt; Something like:<br/>&gt;<br/>&gt; $req-&gt;set_default_accept_encoding;<br/><br/>I don&#39;t like defaults to be set at that level given that we already<br/>have a $ua-&gt;default_header() method, so I think it should be something<br/>like:<br/><br/> $ua-&gt;default_header(&quot;Accept-Encoding&quot;, join(&quot;,&quot;,<br/>HTTP::Message::decodable()));<br/><br/>&gt; I&#39;m not clear if there&#39;s a need to also specify a quality for the<br/>&gt; encodings in the Accept-Encoding header.<br/><br/>I don&#39;t think we need to worry about this initially.<br/><br/>&gt; This can&#39;t be the default as it would break existing users.<br/>&gt;<br/>&gt; I often notice code that uses $res-&gt;content instead of<br/>&gt; $res-&gt;decoded_content. Most of the time it seems like users really<br/>&gt; want the decoded content.<br/>&gt;<br/>&gt; I kind of wonder why $res-&gt;content is not decoded by default (and<br/>&gt; provide $res-&gt;raw_content for those that need it).<br/><br/>It&#39;s mostly because of history and compatibility with the original<br/>content() method. Both are useful in different contexts. I don&#39;t<br/>find the current situation bad. Since decoded_content() can be<br/>expensive and can fail I think the longer name makes it obvious what&#39;s<br/>going on how you should use it.<br/><br/>--Gisle<br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7198.html Sun, 06 Jul 2008 05:36:23 +0000 Accept-Encoding defaults by Bill Moseley HTTP::Message has a decoded_content() method that will attempt<br/>to uncompress based on the Content-Encoding header in the response.<br/><br/>It&#39;s wrapped in an eval which will trap exceptions when trying to<br/>require the modules used to uncompress the content.<br/><br/>It would make sense that I would set Accept-Encoding based on if I<br/>have those modules installed.<br/><br/>Since the list of modules (Compress::Zlib and Compress::Bzip2) is<br/>internal to HTTP::Message, would it make sense to provide a method<br/>that could set the Accept-Encoding based on what HTTP::Message uses?<br/>Something like:<br/><br/> $req-&gt;set_default_accept_encoding;<br/><br/>I&#39;m not clear if there&#39;s a need to also specify a quality for the<br/>encodings in the Accept-Encoding header.<br/><br/>This can&#39;t be the default as it would break existing users.<br/><br/>I often notice code that uses $res-&gt;content instead of<br/>$res-&gt;decoded_content. Most of the time it seems like users really<br/>want the decoded content.<br/><br/>I kind of wonder why $res-&gt;content is not decoded by default (and<br/>provide $res-&gt;raw_content for those that need it).<br/><br/><br/>-- <br/>Bill Moseley<br/>moseley@hank.org<br/>Sent from my iMutt<br/><br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7197.html Sat, 05 Jul 2008 09:39:42 +0000 Re: Form parsing issue? by Gisle Aas On Wed, Jul 2, 2008 at 5:44 PM, Duzenbury, Rich &lt;RDuz@biltd.com&gt; wrote:<br/>&gt; Hello all,<br/>&gt;<br/>&gt; I have mechanized a site using LWP and Mechanize that has been working<br/>&gt; for about a year, but now no longer does. The site owner has made some<br/>&gt; recent changes, but I think mechanize, or more precisely HTML::form<br/>&gt; might be having trouble parsing the page and I&#39;d like to find out why.<br/>&gt;<br/>&gt; In order to make the form work, I set the __EVENTTARGET hidden field to<br/>&gt; a certain value, but as of this week, the script dies with:<br/>&gt;<br/>&gt; $self-&gt;mech-&gt;field(&#39;__EVENTTARGET&#39;,<br/>&gt; &#39;ChangeViewControl1$ImpersonateCommand&#39;);<br/>&gt; No such field &#39;__EVENTTARGET&#39; at<br/>&gt; /usr/lib/perl5/site_perl/5.8.7/WWW/Mechanize.pm line 1247<br/>&gt;<br/>&gt; Sure enough, a form dump no longer shows the __EVENTTARGET field,<br/>&gt; however, the &#39;view source&#39; from firefox shows that there are several<br/>&gt; hidden fields created. Notably, the first three that are blank,<br/>&gt; __EVENTTARGET, __EVENTARGUMENT, and __LASTFOCUS are all missing from the<br/>&gt; form dump. __VIEWSTATE and __EVENTVALIDATION are both fine.<br/>&gt;<br/>&gt; Here is a sample of the page source causing the trouble:<br/><br/>If you feed the HTML below to HTML::Form-&gt;parse() it will pick up the<br/>fields just fine, so there must be something else going on. Perhaps<br/>your Mechanize script does not see the same page as Firefox (content<br/>switching based on User-Agent?). You need to verify that the page<br/>Mechanize gets has the right content first.<br/><br/>--Gisle<br/><br/>&gt;<br/>&gt; &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; &gt;<br/>&gt; &lt;HTML&gt;<br/>&gt; &lt;HEAD&gt;<br/>&gt; &lt;TITLE&gt;IIG - Commission &lt;/TITLE&gt;<br/>&gt; &lt;META CONTENT=&quot;Microsoft Visual Studio 7.0&quot;<br/>&gt; NAME=&quot;GENERATOR&quot;&gt;<br/>&gt; &lt;META CONTENT=&quot;C#&quot; NAME=&quot;CODE_LANGUAGE&quot;&gt;<br/>&gt; &lt;META CONTENT=&quot;JavaScript&quot;<br/>&gt; NAME=&quot;vs_defaultClientScript&quot;&gt;<br/>&gt; &lt;META<br/>&gt; CONTENT=&quot;http://schemas.microsoft.com/intellisense/ie5&quot;<br/>&gt; NAME=&quot;vs_targetSchema&quot;&gt;<br/>&gt; &lt;LINK rel=&quot;stylesheet&quot; type=&quot;text/css&quot;<br/>&gt; href=&quot;/iig/Includes/content.css&quot;&gt;<br/>&gt;<br/>&gt; &lt;LINK rel=&quot;stylesheet&quot; type=&quot;text/css&quot;<br/>&gt; href=&quot;/iig/Includes/design.css&quot;&gt;<br/>&gt; &lt;/HEAD&gt;<br/>&gt; &lt;BODY BACKGROUND=&quot;/IIG/images/graphics/LeftnavBG.gif&quot;&gt;<br/>&gt; &lt;form name=&quot;BM_COMMISSION&quot; method=&quot;post&quot;<br/>&gt; action=&quot;BM_Commission.aspx&quot; id=&quot;BM_COMMISSION&quot;&gt;<br/>&gt; &lt;div&gt;<br/>&gt; &lt;input type=&quot;hidden&quot; name=&quot;__EVENTTARGET&quot; id=&quot;__EVENTTARGET&quot; value=&quot;&quot; /&gt;<br/>&gt; &lt;input type=&quot;hidden&quot; name=&quot;__EVENTARGUMENT&quot; id=&quot;__EVENTARGUMENT&quot;<br/>&gt; value=&quot;&quot; /&gt;<br/>&gt; &lt;input type=&quot;hidden&quot; name=&quot;__LASTFOCUS&quot; id=&quot;__LASTFOCUS&quot; value=&quot;&quot; /&gt;<br/>&gt; &lt;input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; id=&quot;__VIEWSTATE&quot;<br/>&gt; value=&quot;/wEPDwUKMTk5OTEyOTc2OQ9kFgICAQ9kFgwCAw9kFgJmD2QWAmYPEGRkFgFmZAIFD<br/>&gt; 2QWBAIBDw9kFgIeB29uY2xpY2sFKHJldHVybiBwZXJzb25hbCBub3RlLi4uZGQCAw8PFgIfA<br/>&gt; QUuSGF2ZSBhIG5pY2UgZGF5ISAgVGhhbmsgeW91IGZvciB5b3VyIGJ1c2luZXNzLmRkZGnL0<br/>&gt; vBu6mpGya0ys5hHzxb2uD41&quot; /&gt;<br/>&gt; &lt;/div&gt;<br/>&gt;<br/>&gt; &lt;script type=&quot;text/javascript&quot;&gt;<br/>&gt; //&lt;![CDATA[<br/>&gt; var theForm = document.forms[&#39;BM_COMMISSION&#39;];<br/>&gt; if (!theForm) {<br/>&gt; theForm = document.BM_COMMISSION;<br/>&gt; }<br/>&gt; function __doPostBack(eventTarget, eventArgument) {<br/>&gt; if (!theForm.onsubmit || (theForm.onsubmit() != false)) {<br/>&gt; theForm.__EVENTTARGET.value = eventTarget;<br/>&gt; theForm.__EVENTARGUMENT.value = eventArgument;<br/>&gt; theForm.submit();<br/>&gt; }<br/>&gt; }<br/>&gt; //]]&gt;<br/>&gt; &lt;/script&gt;<br/>&gt;<br/>&gt;<br/>&gt; ... lots and lots of stuff ...<br/>&gt;<br/>&gt; &lt;input type=&quot;hidden&quot; name=&quot;__EVENTVALIDATION&quot;<br/>&gt; id=&quot;__EVENTVALIDATION&quot;<br/>&gt; value=&quot;/wEWCwL43P67BgKPhY63AQKvyf96AuGR/ZsLAt7k4+oBAr/7qI8CApDruZ4MArj/l<br/>&gt; YsOAqmWg8ABApLw8ekBAon9/ZAFbIsAYNVghSRuGVlbiVaPL3r23/U=&quot; /&gt;<br/>&gt; &lt;/div&gt;<br/>&gt; &lt;script language=&quot;javascript&quot;<br/>&gt; type=&quot;text/javascript&quot;&gt;xm_GetMenu(&#39;TopNav1$topMenu&#39;).xm_HK();&lt;/script&gt;&lt;/<br/>&gt; form&gt;<br/>&gt;<br/>&gt;<br/>&gt; If you can help out that would be great. One thought I had, can I force<br/>&gt; a new hidden field into the form?<br/>&gt;<br/>&gt; Thank you.<br/>&gt;<br/>&gt; Regards,<br/>&gt; Rich<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/><br/><br/>-- <br/>Gisle Aas<br/> http://www.nntp.perl.org/group/perl.libwww/2008/07/msg7196.html Thu, 03 Jul 2008 00:50:48 +0000