Closed hmdne closed 3 years ago
Yes, i meet same issue too, following is my solution, replace Rack::Lint with a empty middleware.
# For disable Rack::Lint
module Rack
class Lint
def call(env = nil)
@app.call(env)
end
end
end
Anyway, i propose this issue can be resolved from gem, thank you.
you can check my sample repo here, maybe can help on resolve this.
https://github.com/zw963/marketbet_crawler
you need set following ENV to make this repo run.
export DEVELOPMENT_DATABASE_URL="sqlite://db/files/marketbet_crawler_development.db"
export APP_SESSION_SECRET="909f017cc94c96f8a1aff843d95920485376f4c997143cc3c39ca945c883ec88e310a2177a69b8b714d22af1b5fd7864833568b6bf93fc3bc811bcf6e112"
This is a problem I can't reliably locate as of now, I assume it's a problem located somewhere in Roda. I will look into it today.
The error comes from a 304 response with a Content-Type
header. Roda automatically deletes the Content-Type
header if the response body is empty. However, it looks like roda-sprockets is returning a non-empty body (it may be returning an empty string as the body, but that is not treated the same as an empty body). You could try having https://github.com/hmdne/roda-sprockets/blob/master/lib/roda/plugins/sprockets.rb#L149 return nil for 304 responses.
If that doesn't work, you could consider using the Roda drop_body plugin, which will automatically drop the body and remove Content-Type
header for 304 responses.
@jeremyevans Thank you! I took a very long time to try to debug this problem, but your suggestion shown exactly what's the problem here.
@hmdne , this issue seem like not fixed.
i test on newest master in development.
127.0.0.1 - - [21/Aug/2021:13:54:02 +0800] "GET /stocks HTTP/1.1" 200 4098 19.6698
127.0.0.1 - - [21/Aug/2021:13:54:03 +0800] "GET /assets/app.debug.css HTTP/1.1" 200 164560 1.0283
Rack::Lint::LintError: Content-Length header found in 304 response, not allowed
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:21:in `assert'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:724:in `block in check_content_length'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:720:in `each'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:720:in `check_content_length'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:71:in `_call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:38:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/content_length.rb:17:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/configuration.rb:249:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/request.rb:77:in `block in handle_request'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/thread_pool.rb:338:in `with_force_shutdown'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/request.rb:76:in `handle_request'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/server.rb:438:in `process_client'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/thread_pool.rb:145:in `block in spawn_thread'
127.0.0.1 - - [21/Aug/2021:13:54:03 +0800] "GET /assets/app.debug.js HTTP/1.1" 500 56261 0.0577
BTW: i test use drop_body
plugin yesterday, it works quite well.
I can't reproduce this behavior though. Seems like it's related to Sass yet still I can't reproduce it neither here nor in my app.
I still can reproduce this when development. (though, not every time)
127.0.0.1 - - [22/Aug/2021:13:12:49 +0800] "GET /latest-institutions?days=60 HTTP/1.1" 200 372733 18.1439
Rack::Lint::LintError: Content-Length header found in 304 response, not allowed
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:21:in `assert'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:724:in `block in check_content_length'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:720:in `each'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:720:in `check_content_length'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:71:in `_call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:38:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/content_length.rb:17:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/configuration.rb:249:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/request.rb:77:in `block in handle_request'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/thread_pool.rb:338:in `with_force_shutdown'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/request.rb:76:in `handle_request'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/server.rb:438:in `process_client'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/thread_pool.rb:145:in `block in spawn_thread'
127.0.0.1 - - [22/Aug/2021:13:12:49 +0800] "GET /assets/app.debug.css HTTP/1.1" 500 56307 0.0155
Rack::Lint::LintError: Content-Length header found in 304 response, not allowed
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:21:in `assert'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:724:in `block in check_content_length'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:720:in `each'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:720:in `check_content_length'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:71:in `_call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/lint.rb:38:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/rack-2.2.3/lib/rack/content_length.rb:17:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/configuration.rb:249:in `call'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/request.rb:77:in `block in handle_request'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/thread_pool.rb:338:in `with_force_shutdown'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/request.rb:76:in `handle_request'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/server.rb:438:in `process_client'
/home/zw963/.rvm/gems/ruby-3.0.2@marketbet_crawler/gems/puma-5.3.2/lib/puma/thread_pool.rb:145:in `block in spawn_thread'
127.0.0.1 - - [22/Aug/2021:13:12:50 +0800] "GET /assets/app.debug.js HTTP/1.1" 500 56282 0.0498
maybe you want test use my app, following is a development database, you can unzip it throw it to 'db/files' folder.
you need set env like this too:
export DEVELOPMENT_DATABASE_URL="sqlite://db/files/marketbet_crawler_development.db"
export TEST_DATABASE_URL="sqlite://db/files/marketbet_crawler_test.db"
export DATABASE_URL="sqlite://db/files/marketbet_crawler_production.db"
export APP_SESSION_SECRET="909f017cc94c96f8a1aff843d95920485376f4c997143cc3c39ca945c883ec88e310a2177a69b8b714d22af1b5fd7864833568b6bf93fc3bc811bcf6e112"
And test it with: (if port is 9393)
BTW: if you want reproduce, please use branch test_304 instead.
https://github.com/zw963/marketbet_crawler/tree/test_304
i disable drop_body plugin in this branch.
This is the reason for the issue:
https://github.com/zw963/marketbet_crawler/blob/master/app/app.rb#L17
So I will close this bug now and release v1.1.0 tonight.
sorry for confusing, that works, thank you!
To trigger this bug, one must trigger a 304 response for any (CSS/JS) asset in development mode.
There exists a workaround:
Then, it outputs the following: