Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Length: handle body w/ UTF8 characters for Ruby 1.9+ to avoid Rack::Lint::LintError #2

Merged
merged 1 commit into from
Feb 9, 2017

Conversation

erikj
Copy link
Contributor

@erikj erikj commented Feb 9, 2017

Thanks to cloudhead/toto#93, I have uncovered why our Rails application that uses stopwatch was producing Rack::Lint::LintErrors, e.g.:

ERROR -- : app error: Content-Length header was 48738, but should be 48748 (Rack::Lint::LintError)

This is a result of how Ruby handles lengths of UTF8 strings differently between 1.8 and 1.9.

This pull request uses String#bytesize() if body responds to it, otherwise falls back to String#length and eliminates these Rack::Lint::LintErrors in our Rails app.

The stopwatch gem is very useful for Rails application development, and we have been using it for many years, thank you!

@bittersweet
Copy link
Owner

Hey @erikj , thanks a lot for the pull request :-) I had no idea this was happening! Awesome stuff.

I'll pull in this change and freshen up the codebase for a bit, I'll report back when there's a new version available :-)

@bittersweet bittersweet merged commit 413b527 into bittersweet:master Feb 9, 2017
@bittersweet
Copy link
Owner

I just released version v1.0.0, I thought it was time :-) Not much has changed or will change.

I also added a spec for this fix in 71c6695.

Thanks again!

@erikj
Copy link
Contributor Author

erikj commented Feb 9, 2017

Cool, thanks @bittersweet ! Woo hoo, v1.0.0! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants