Class: BreachMitigation::LengthHiding
- Inherits:
-
Object
- Object
- BreachMitigation::LengthHiding
- Defined in:
- lib/breach_mitigation/length_hiding.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ LengthHiding
constructor
A new instance of LengthHiding.
Constructor Details
#initialize(app) ⇒ LengthHiding
Returns a new instance of LengthHiding.
5 6 7 |
# File 'lib/breach_mitigation/length_hiding.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/breach_mitigation/length_hiding.rb', line 9 def call(env) status, headers, body = @app.call(env) # Only pad HTML/XHTML documents if headers['Content-Type'] =~ /text\/x?html/ && Rack::Request.new(env).ssl? # Copy the existing response to a new object response = Rack::Response.new(body, status, headers) # Append to that response response.write random_html_comment body.close if body.respond_to? :close response.finish else [status, headers, body] end end |