boazsegev / iodine

iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
MIT License
908 stars 51 forks source link

null strings returns #103

Closed waghanza closed 3 years ago

waghanza commented 3 years ago

System Information

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

boazsegev commented 3 years ago

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.

waghanza commented 3 years ago

what is weird is that I detect this on some frameworks, not all ;-)

btw, hope https://the-benchmarker.semaphoreci.com/workflows/c5d10c31-6b74-4254-9747-bf7f1ea82562?pipeline_id=755523b3-73c4-45e2-a7cc-53fbae8cf736 will be OK

boazsegev commented 3 years ago

@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.