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