Class: Rack::WebProfiler::Request
- Inherits:
-
Request
- Object
- Request
- Rack::WebProfiler::Request
- Defined in:
- lib/rack/web_profiler/request.rb
Instance Method Summary collapse
-
#body_string ⇒ String
Get body has a String.
-
#freeze ⇒ Object
:nodoc:.
-
#http_headers ⇒ Hash
Get HTTP headers.
-
#raw ⇒ String
Get full HTTP request in HTTP format.
Instance Method Details
#body_string ⇒ String
Get body has a String.
16 17 18 |
# File 'lib/rack/web_profiler/request.rb', line 16 def body_string @body.to_s end |
#freeze ⇒ Object
:nodoc:
28 29 30 31 |
# File 'lib/rack/web_profiler/request.rb', line 28 def freeze # :nodoc: @body = body.read super end |
#http_headers ⇒ Hash
Get HTTP headers.
7 8 9 10 11 |
# File 'lib/rack/web_profiler/request.rb', line 7 def http_headers env.select { |k, _v| (k.start_with?("HTTP_") && k != "HTTP_VERSION") || k == "CONTENT_TYPE" } .collect { |k, v| [k.sub(/^HTTP_/, ""), v] } .collect { |k, v| [k.split("_").collect(&:capitalize).join("-"), v] } end |
#raw ⇒ String
Get full HTTP request in HTTP format.
23 24 25 26 |
# File 'lib/rack/web_profiler/request.rb', line 23 def raw headers = http_headers.map { |k, v| "#{k}: #{v}\r\n" }.join format "%s %s %s\r\n%s\r\n%s", request_method.upcase, fullpath, env["SERVER_PROTOCOL"], headers, body_string end |