raku-community-modules / HTTP-Easy

Make HTTP servers (with PSGI support) easily with Raku
Artistic License 2.0
16 stars 19 forks source link

Closing connection without returning any data back / POSTDATA questions. #3

Closed bbkr closed 11 years ago

bbkr commented 11 years ago

I'm trying to replace HTTP transport in my JSON::RPC module with HTTP::Easy, to do so I need to resolve two issues:

use of uninitialized value of type Any in string context  in method handler at /home/ppabian/rakudo/install/lib/parrot/4.6.0/languages/perl6/lib/HTTP/Easy/PSGI.pm6:40

error.

I found that in HTTP::Easy content is available in "psgi.input" env key. Is it something that I can rely on or it may change in the future into something like POSTDATA (like the one described in P5 CGI POD )?

supernovus commented 11 years ago

I don't think HTTP::Easy will support the former. The PSGI specification, and indeed, from my reading of it, the HTTP specification, deems that a response must be sent for every request, even if the response is simply an HTTP status code with no content.

The psgi.input is a part of the PSGI specification, and will not change, however, querying the psgi.input to determine if it is a Str, Buf or IO object is recommended, as the exact nature of the object is not set in stone (and indeed will likely be changing in a future update to HTTP::Easy when I enable Buf.)

bbkr commented 11 years ago

Thanks for answering my questions.

I switched to HTTP::Easy - https://github.com/bbkr/jsonrpc/blob/master/lib/JSON/RPC/Server.pm#L12-36 Buf and IO psgi.input cases are also handled.

As for notifications and closing connection without sending any data back - I asked on JSON-RPC group what is the "most correct" behavior when transport layer must return something and I'm sure they ran into this issue many times on many frameworks so I'll implement their suggestion later when they respond.

Thanks again :)

supernovus commented 11 years ago

I'm glad it worked out for you. On top of updates coming to HTTP::Easy, I'm planning to update HTTP::Client to fix some outstanding bugs. Then it may be a match for your JSON::RPC::Client library.