Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
attempt to fix $socket.get with non-ASCII characters
  • Loading branch information
moritz committed Jan 24, 2013
1 parent 7707e42 commit 0b5899a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/IO/Socket/INET.pm
Expand Up @@ -92,7 +92,9 @@ my class IO::Socket::INET does IO::Socket {

method get() {
++$!ins;
my str $line = nqp::getattr(self, $?CLASS, '$!PIO').readline(nqp::unbox_s($!input-line-separator));
my Mu $PIO := nqp::getattr(self, $?CLASS, '$!PIO');
$PIO.encoding(nqp::unbox_s(PARROT_ENCODING(self.encoding)));
my str $line = $PIO.readline(nqp::unbox_s($!input-line-separator));
my str $sep = $!input-line-separator;
my int $len = nqp::chars($line);
my int $sep-len = nqp::chars($sep);
Expand Down

1 comment on commit 0b5899a

@drKreso
Copy link

@drKreso drKreso commented on 0b5899a Mar 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. I am having issues with this method. I am using get() from HTTP::Easy module.

  use HTTP::Easy::PSGI;
  my $http = HTTP::Easy::PSGI.new(:port(8080));

  my $app = sub (%env)
  {
    my $name = %env<QUERY_STRING> || "World";
    return [ 200, [ 'Content-Type' => 'text/plain' ], [ "Hello $name" ] ];
  }

  $http.handle($app);

With this version it just hangs after cookie get parsed. (The next line is supposed to be blank line - but it never get's there).

If I revert it, the process goes one step further.

Finished parsing headers.

But then this error occurs:

Invalid operation on binary string
in method uc at src/gen/CORE.setting:2280
in method dispatch:<.=> at src/gen/CORE.setting:1014
in block at lib/HTTP/Easy.pm6:93
in method reify at src/gen/CORE.setting:5591
in method reify at src/gen/CORE.setting:5492
in method gimme at src/gen/CORE.setting:5882
in method sink at src/gen/CORE.setting:6158
in method run at lib/HTTP/Easy.pm6:88
in method handle at lib/HTTP/Easy/PSGI.pm6:89
in block at http.pl:10

That line :93 in Easy.pm is trying to uppercase $key with value "Host"

  $key .= uc;

This is already reported raku-community-modules/HTTP-Easy#6 and this commit is fix for that, but for some reason now it hangs.

If I use fix suggested there:

  $key = $key.encode("binary").decode.uc;

it works just fine (raku-community-modules/HTTP-Easy#7)

Please sign in to comment.