in reply to Re^2: Load large(ish) files with YAML?
in thread Load large(ish) files with YAML?

Puppet doesn't do base64, it sends a long string of \x123\x321 etc (this is the actual string it sends, those are not hex chars but their readable form).
Wow, what a terrible piece of software -- though I suppose it's pretty typical for Ruby, with its mix of historical ignorance and inefficiency. We've known how to encode binary data as ASCII text with reasonable line lengths for a long time: it's called "uuencode," and pack and unpack handle it just fine.

Replies are listed 'Best First'.
Re^4: Load large(ish) files with YAML?
by rgcosma (Beadle) on Apr 28, 2011 at 10:05 UTC

    While you are right that they don't encode properly, it seems there was an existing solution: the puppet app recognizes an 'Accept: s' header that means it'll return the file as-is.

    The working example would be:
    my $ua = LWP::UserAgent->new(); my $ay = HTTP::Headers->new; $ay->head +er('Accept' => 'YAML'); my $as = HTTP::Headers->new; $as->header('Acc +ept' => 's'); my @osini; my @partini; my $req = HTTP::Request->new('GET', "https://$server/production/file_m +etadata/test/hm.jpg", $ay); my $res = $ua->request($req); die "Something went wrong: $res->status_line" unless $res->is_su +ccess; @osini = YAML::Load($res->content."\n"); my $md5 = $osini[0]->{checksum}; $md5 =~ s/^{md5}//; $req = HTTP::Request->new('GET', "https://$server/production/fil +e_bucket_file/md5/$md5", $as); $res = $ua->request($req); open AAA,'>aaa.jpg'; binmode AAA; print AAA $res->content;