boazsegev / iodine

iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

null strings returns

waghanza opened this issue · comments

System Information

  • OS: macOS 11.2.2
  • Ruby: ruby 2.7.2p137
  • Version: 0.7.43
  • OpenSSL: LibreSSL 2.8.3

Description

Returning an empty string

Rack App to Reproduce

APP = { |env| [200, {}, ['']]  }
run APP

Testing code

curl http://localhost:3000/

Expected behavior

The above code is expected to return a string, at least for a consumer

Actual behavior

The above code returns null, assuming it is a string null

/cc @adam12

commented

Hi @waghanza ,

Thank you for opening this issue. I released a fix with version 0.7.44.

Apparently, I optimized away the String creation for an empty String responses but forgot to set a "no-response" flag. This routed the "NULL" C pointer to the server's (internal) auto-JSON-formatting engine where the NULL pointer response was converted to the String "null"... 😅

Anyway, this shouldn't happen now. Thanks again for opening the issue (you're credited in the CHANGELOG).

Cheers,
Bo.

commented

@waghanza ,

It could be that some frameworks returned an empty Array rather than an Array with an empty String. This could explain why some frameworks failed and others passed with no issue.

The new tests look okay.

Cheers,
Bo.