Thread Net::HTTP interner Puffer
(14 answers)
Opened by rosti at 2011-03-19 23:01
Ich glaube, die Pufferung kann man in diesem Falle nicht abstellen. Für den Fall, dass einzelne Records nicht auf einmal gelesen werden können, wäre es möglich, dass man den Körper mit einer Schleife einlesen muss, etwa so (ungestestet):
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 use 5.012; use warnings; use Errno qw/EINTR EAGAIN/; # ... initialization stuff ... RECORD_LOOP: while (1) { my $record = ""; READ_LOOP: while (length($record) < 794) { my $_; given ($nh->read_entity(my $chunk, 794 - length($record))) { last RECORD_LOOP when ($_ == 0 and length($record) == 0); next READ_LOOP when ($_ ~~ [ undef, -1 ] and $! ~~ [ EINTR, EAGAIN ]); die "I/O error: $!" when ([ undef, -1 ]); die "Unexpected end of file" when (0); default { $record .= $chunk; } } } # ... record processing ... } When C++ is your hammer, every problem looks like your thumb.
|