Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update lib/LWP/Simple.pm #14

Merged
merged 1 commit into from

2 participants

ronaldxs Cosimo Streppone
ronaldxs

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.

ronaldxs ronaldxs 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.
5c040e0
Cosimo Streppone cosimo merged commit cd484d8 into from
Cosimo Streppone
Owner

I can understand this better :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 29, 2012
  1. ronaldxs

    Update lib/LWP/Simple.pm

    ronaldxs authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/LWP/Simple.pm
4 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);
Something went wrong with that request. Please try again.