Class: Rack::CanonicalHost::Request
- Inherits:
-
Object
- Object
- Rack::CanonicalHost::Request
- Defined in:
- lib/rack/canonical_host/request.rb
Constant Summary collapse
- BAD_REQUEST =
<<-HTML.gsub(/^\s+/, '') <!DOCTYPE html> <html lang="en-US"> <head><title>400 Bad Request</title></head> <body> <h1>Bad Request</h1> </body> </html> HTML
Instance Method Summary collapse
- #bad_request_response ⇒ Object
-
#initialize(env) ⇒ Request
constructor
A new instance of Request.
- #valid? ⇒ Boolean
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
17 18 19 |
# File 'lib/rack/canonical_host/request.rb', line 17 def initialize(env) self.env = env end |
Instance Method Details
#bad_request_response ⇒ Object
28 29 30 |
# File 'lib/rack/canonical_host/request.rb', line 28 def bad_request_response [400, { 'content-type' => 'text/html' }, [BAD_REQUEST]] end |
#valid? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/rack/canonical_host/request.rb', line 21 def valid? Addressable::URI.parse(Rack::Request.new(env).url) true rescue Addressable::URI::InvalidURIError false end |