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 bug of Rack::NotFound #143

Closed
znz opened this issue Nov 30, 2017 · 0 comments · Fixed by #145
Closed

Content-Length bug of Rack::NotFound #143

znz opened this issue Nov 30, 2017 · 0 comments · Fixed by #145

Comments

@znz
Copy link
Contributor

znz commented Nov 30, 2017

@length = @content.size.to_s
uses size. I think it should be bytesize or use File.binread instead of File.read.

How to reproduce:

config.ru:

# config.ru
require 'rack/contrib'
require 'tempfile'
Tempfile.open do |f|
  f.write '<!DOCTYPE html>'
  f.write '<meta charset=utf-8>'
  f.write '☃ snowman'
  f.close
  run Rack::NotFound.new(f.path)
end

Run rackup and open browser, it shows ☃ snowm (missing last an) in browser, and Read error: #<Rack::Lint::LintError: Content-Length header was 44, but should be 46> in console.

BTW F = ::File is still need instead of using ::File directly? F is used in 1 place now.

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

Successfully merging a pull request may close this issue.

2 participants