Hello guys,
I'm facing to an encoding issue with Sinatra (maybe Rack related).
Example:
# Client side
curl -XPOST -H 'Content-type: text/plain; charset=UTF-8' localhost:4567 -d
'héllo'
# Server side
body = request.body.read
puts body # "h\xC3\xA9llo"
puts body.encoding # ASCII-8BIT
The body encoding format is always ASCII-8BIT even with a charset specified
to UTF-8. Do you know if this is a normal behavior ?
After some digging, i found that issue about URI encoding
https://github.com/rack/rack/issues/732 but nothing about the body format.
Best regards,
···
--
Sébastien Puyet
Possibly related: rack request environment variables are allways encoded in ascii-8bit regardless of default_external Encoding · Issue #1328 · phusion/passenger · GitHub
Regards,
Paul
···
On Tue, May 30, 2017 at 4:37 PM, Sébastien Puyet <sebastienpuyet@gmail.com> wrote:
Hello guys,
I'm facing to an encoding issue with Sinatra (maybe Rack related).
Example:
# Client side
curl -XPOST -H 'Content-type: text/plain; charset=UTF-8' localhost:4567 -d
'héllo'
# Server side
body = request.body.read
puts body # "h\xC3\xA9llo"
puts body.encoding # ASCII-8BIT
The body encoding format is always ASCII-8BIT even with a charset
specified to UTF-8. Do you know if this is a normal behavior ?
After some digging, i found that issue about URI encoding
Encoding::UndefinedConversionError · Issue #732 · rack/rack · GitHub but nothing about the body format.
Best regards,
--
Sébastien Puyet
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>