in reply to "Unexpected end of stream while looking for line"

Hi msh210 :)

Can you provide your suspected code? (give only the essential)

Here is HTTP::Tiny where the code failed:

sub readline { @_ == 1 || die(q/Usage: $handle->readline()/ . "\n"); my ($self) = @_; while () { if ($self->{rbuf} =~ s/\A ([^\x0D\x0A]* \x0D?\x0A)//x) { return $1; } if (length $self->{rbuf} >= $self->{max_line_size}) { die(qq/Line size exceeds the maximum allowed size of $self +->{max_line_size}\n/); } $self->can_read or die(qq/Timed out while waiting for socket to become ready + for reading\n/); my $r = sysread($self->{fh}, $self->{rbuf}, BUFSIZE, length $s +elf->{rbuf}); if (defined $r) { last unless $r; } elsif ($! != EINTR) { if ($self->{fh}->can('errstr')){ my $err = $self->{fh}->errstr(); die (qq/Could not read from SSL socket: '$err'\n /); } else { die(qq/Could not read from socket: '$!'\n/); } } } #### Line 1126 die(qq/Unexpected end of stream while looking for line\n/); }


Peace

Replies are listed 'Best First'.
Re^2: "Unexpected end of stream while looking for line"
by msh210 (Monk) on Jan 07, 2016 at 19:58 UTC
    Can you provide your suspected code? (give only the essential)

    If I knew what was essential to be provided, I'd have done it in the first place. Here's some of my code:

    #!/usr/bin/perl use strict; use warnings; use HTTP::Tiny; use JSON; use Test::JSON; use utf8::all; use URI::Escape; use Smart::Comments '###'; use List::Util qw(min max); use Statistics::Basic qw(median mode); # ... my $http = HTTP::Tiny->new(timeout => 6000); # ... $response = $http->post($url, {headers=>{Authorization=>"token $access_token +"}, content=>$query}); die $! unless is_valid_json $response->{content}; # ...

      Essential means enough to demonstrate the problem. Sometimes the exercise of producing this reveals the source of the problem.

      But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

        As I said, this occurs only for a specific HTTP POST request, and not for others. Therefore, sufficient information to demonstrate the problem would mean including the POST request. I cannot do that, as it includes my employer's proprietary information. However, I can assure you that the HTTP requests that results in this error and those that don't are extremely similar, and the expected responses are, too.