Permalink
Browse files

Update lib/LWP/Simple.pm

Had an IRC chat with moritz.  He thought my coding wasn't so bad but didn't fit with the surrounding code and suggested this instead.  During the discussion it also came up that recv doesn't support binary very well yet but $socket.read(nnnn) does.  It occurs to me that since HTTP headers often have a Content-length the read solution may be good in the nearish future.
  • Loading branch information...
1 parent 5701072 commit 5c040e0daa73b1b254b9beaff40b9d66a84b367c @ronaldxs ronaldxs committed Jul 29, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/LWP/Simple.pm
View
@@ -154,7 +154,9 @@ method make_request (
$sock.send($req_str);
# a bit crude w respect to err handling and blocking but ok for now
- my $resp = ~ gather for $sock.recv() xx * { .bytes ?? take $_ !! last };
+ my $resp = join '', gather loop {
+ my $s = $sock.recv; last unless $s.chars; take $s
+ };
$sock.close();
my ($status, $resp_headers, $resp_content) = self.parse_response($resp);

0 comments on commit 5c040e0

Please sign in to comment.