Sha256: 54dce790ebf645b92fea205c9b4d71b6acefa8f91a9285491d2104522aa225c9
Contents?: true
Size: 715 Bytes
Versions: 1
Compression:
Stored size: 715 Bytes
Contents
class WorklessChecker def initialize(app) @app = app end def call(env) status, headers, response = @app.call(env) return [status, headers, response] if file?(headers) || empty?(response) Delayed::Job.scaler.up unless Delayed::Job.scaler.jobs.empty? [status, headers, response] end # fix issue if response's body is a Proc def empty?(response) # response may be ["Not Found"], ["Move Permanently"], etc. (response.is_a?(Array) && response.size <= 1) || !response.respond_to?(:body) || !response.body.respond_to?(:empty?) || response.body.empty? end # if send file? def file?(headers) headers['Content-Transfer-Encoding'] == 'binary' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
workless_revived-2.0.0 | lib/workless/middleware/workless_checker.rb |