You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
The following program called mine returns the following error :
Type check failed in binding $str; expected 'Str' but got 'Array'
in sub unbase at src/gen/m-CORE.setting:6857
in block at lib/HTTP/Client/Response.pm6:113
in method dechunk at lib/HTTP/Client/Response.pm6:106
in method contents at lib/HTTP/Client/Response.pm6:140
in method content at lib/HTTP/Client/Response.pm6:146
in sub slurp at mine:9
in block at mine:15
use HTTP::Client;
proto sub slurp(|) { * }
multi sub slurp($filename, :$bin = False, :$enc = 'utf8') {
if $filename.index: '://' -> $i {
require HTTP::Client;
my $client = HTTP::Client.new;
my $response = $client.get($filename);
return $response.content if $response.success ;
fail;
}
$filename.IO.slurp(:$bin, :$enc);
There is several problems with "Transfer-Encoding: chunked" management with this library:
method content() insert erroneous CRLF in result of chunked encoding
method dechunk() erase @!content impeding to get content a second time
if there is CRLF in the chunked content itself we're screwed
working with Str and chars() method is a recipe for more subtle and complex error in certain cases
My opinion is that as chunked Transfer-Encoding is a MUST in RFC7230 (A recipient MUST be able to parse the chunked transfer coding) and is really used in the Internet, HTTP::Client not suitable for use anymore.
I would like to modify the README to add a message prescribing use of HTTP::UserAgent instead.
The following program called mine returns the following error :
Type check failed in binding $str; expected 'Str' but got 'Array'
in sub unbase at src/gen/m-CORE.setting:6857
in block at lib/HTTP/Client/Response.pm6:113
in method dechunk at lib/HTTP/Client/Response.pm6:106
in method contents at lib/HTTP/Client/Response.pm6:140
in method content at lib/HTTP/Client/Response.pm6:146
in sub slurp at mine:9
in block at mine:15
use HTTP::Client;
proto sub slurp(|) { * }
multi sub slurp($filename, :$bin = False, :$enc = 'utf8') {
if $filename.index: '://' -> $i {
require HTTP::Client;
}
say slurp("http://paris.mongueurs.net");
For info, the page acceded with wget with the header printed
wget -S mongueurs.net
--2014-06-16 11:48:03-- http://mongueurs.net/
Resolving mongueurs.net... 91.216.186.189
Connecting to mongueurs.net|91.216.186.189|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Server: Apache/1.3.42 (Unix)
Last-Modified: Mon, 16 Jun 2014 09:45:05 GMT
ETag: "1bc3f8b-3e95-539ebca1"
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 16 Jun 2014 09:48:01 GMT
X-Varnish: 768907453
Age: 0
Via: 1.1 varnish
Connection: keep-alive
Length: unspecified [text/html]
Saving to: ‘index.html.2’
2014-06-16 11:48:04 (70.7 KB/s) - ‘index.html.’ saved [16021]
The text was updated successfully, but these errors were encountered: