Skip to content

Commit

Permalink
Merge pull request #178 from andrykonchin/minor-fixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
ioquatix authored May 5, 2020
2 parents c1a6025 + 9fb9e3f commit bee849e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rack/contrib/backstage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(app, path)
def call(env)
if File.exists?(@file)
content = File.read(@file)
length = "".respond_to?(:bytesize) ? content.bytesize.to_s : content.size.to_s
length = content.bytesize.to_s
[503, {'Content-Type' => 'text/html', 'Content-Length' => length}, [content]]
else
@app.call(env)
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/contrib/jsonp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def call(env)

# Set new Content-Length, if it was set before we mutated the response body
if headers['Content-Length']
length = response.to_ary.inject(0) { |len, part| len + part.bytesize }
length = response.map(&:bytesize).reduce(0, :+)
headers['Content-Length'] = length.to_s
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/contrib/mailexceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def send_notification(exception, env)

def extract_body(env)
if io = env['rack.input']
io.rewind if io.respond_to?(:rewind)
io.rewind
io.read
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/contrib/nested_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def call(env)
post_body = env[POST_BODY]
env[FORM_INPUT] = post_body
env[FORM_HASH] = Rack::Utils.parse_nested_query(post_body.read)
post_body.rewind if post_body.respond_to?(:rewind)
post_body.rewind
end
@app.call(env)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rack/contrib/signals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def each(&block)
@body.each(&block)
@callback.call
end

def close
@body.close if @body.respond_to?(:close)
end
end

def initialize(app, &block)
Expand Down

0 comments on commit bee849e

Please sign in to comment.