--- AnyEvent-HTTP/HTTP.pm 2011/01/03 00:23:25 1.89 +++ AnyEvent-HTTP/HTTP.pm 2011/01/03 01:03:29 1.91 @@ -171,6 +171,10 @@ (this can be suppressed by using C for these headers in which case they won't be sent at all). +You really should provide your own C header value that is +appropriate for your program - I wouldn't be surprised if the default +AnyEvent string gets blocked by webservers sooner or later. + =item timeout => $seconds The time-out to use for various stages - each connect attempt will reset @@ -331,6 +335,7 @@ http_request GET => "https://www.google.com", + headers => { "user-agent" => "MySearchClient 1.0" }, timeout => 30, sub { my ($body, $hdr) = @_; @@ -781,7 +786,9 @@ $ae_error = 597; # body phase - my $len = $hdr{"content-length"}; + my $chunked = $hdr{"transfer-encoding"} =~ /\bchunked\b/i; # not quite correct... + + my $len = $chunked ? undef : $hdr{"content-length"}; # body handling, many different code paths # - no body expected @@ -806,7 +813,7 @@ $finish->(delete $state{handle}); - } elsif ($hdr{"transfer-encoding"} =~ /\bchunked\b/i) { + } elsif ($chunked) { my $cl = 0; my $body = undef; my $on_body = $arg{on_body} || sub { $body .= shift; 1 };