Closed parallel588 closed 10 years ago
Same here with Unicorn 4.8.2.
E, [2014-04-09T09:03:41.869236 #5] ERROR -- : app error: undefined method `reopen' for #<Unicorn::TeeInput:0x007fc9c435f350> (NoMethodError) Heroku/some-app
E, [2014-04-09T09:03:41.869602 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/utf8-cleaner-0.0.7/lib/utf8-cleaner/middleware.rb:40:in `sanitize_env_rack_input'
E, [2014-04-09T09:03:41.869842 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/utf8-cleaner-0.0.7/lib/utf8-cleaner/middleware.rb:25:in `sanitize_env'
E, [2014-04-09T09:03:41.870068 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/utf8-cleaner-0.0.7/lib/utf8-cleaner/middleware.rb:18:in `call'
E, [2014-04-09T09:03:41.870220 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:511:in `call'
E, [2014-04-09T09:03:41.870350 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/application.rb:97:in `call'
E, [2014-04-09T09:03:41.869602 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/utf8-cleaner-0.0.7/lib/utf8-cleaner/middleware.rb:40:in `sanitize_env_rack_input' Heroku/some-app Context
E, [2014-04-09T09:03:41.869842 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/utf8-cleaner-0.0.7/lib/utf8-cleaner/middleware.rb:25:in `sanitize_env' Heroku/some-app Context
E, [2014-04-09T09:03:41.870068 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/utf8-cleaner-0.0.7/lib/utf8-cleaner/middleware.rb:18:in `call' Heroku/some-app Context
E, [2014-04-09T09:03:41.870220 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:511:in `call' Heroku/some-app Context
E, [2014-04-09T09:03:41.870350 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/application.rb:97:in `call' Heroku/some-app Context
E, [2014-04-09T09:03:41.870477 #5] ERROR -- : /app/vendor/bundle/ruby/2.1.0/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:30:in `method_missing' Heroku/some-app Context
This problem introduced by 893fadb50b17b540a215411b0391df90ea3cda5c.
That commit assumes that env['rack.input']
has interface like StringIO.
But I think that we should it treat as a Rack::Lint::InputWrapper.
same issue
Sorry about the error, folks! Sticking to v0.0.6 is probably a good idea for now.
From the Rack docs http://rack.rubyforge.org/doc/SPEC.html: "The input
stream must respond to gets
, each
, read
and rewind
." reopen
is
not in that list. It's not clear how we go about modifying the input stream
in other Rack servers. Any ideas?
Tagging @salrepe, the original author.
On Wed, Apr 9, 2014 at 8:32 AM, Andrey Morskov notifications@github.comwrote:
same issue
Reply to this email directly or view it on GitHubhttps://github.com/singlebrook/utf8-cleaner/issues/13#issuecomment-39958036 .
Uops, you are right, maybe as @juno comments, Rack::Lint::InputWrapper can be used to wrapper it. Server wrappers are based on that.
def sanitize_env_rack_input(env)
if value = env['rack.input'].read
cleaned_value = cleaned_uri_string(value)
env['rack.input'] = Rack::Lint::InputWrapper.new(StringIO.new(cleaned_value)) if cleaned_value
end
env['rack.input'].rewind
end
The fact is that, with this solution, the wrapper class will be changed, but it would respond to gets
, each
, read
and rewind
.
What do you think?
@salrepe I think can do without Rack::Lint::InputWrapper
and use only StringIO
Yes, it works, but with Rack::Lint::InputWrapper we maintain what rack docs points http://rack.rubyforge.org/doc/SPEC.html: "The input
stream must respond to gets
, each
, read
and rewind
.
What do you think?
Sorry for the confusion.
I just wanted to say that we can expect rack.input
has methods defined in Rack::Lint::InputWrapper
, but not required to use or wrap with it.
@salrepe your solution is reasonable and worked with Unicorn. :smiley:
Maybe it's not required to wrap within Rack::Lint::InputWrapper
.
Can anyone else confirm that #14 works for them? If so, I'll merge it.
Hi guys, I'm checking last version (0.0.7) and I'm receiving the following error: