Class: Rack::WebProfiler::Request

Inherits:
Request
  • Object
show all
Defined in:
lib/rack/web_profiler/request.rb

Instance Method Summary collapse

Instance Method Details

#body_stringString

Get body has a String.

Returns:

  • (String)


16
17
18
# File 'lib/rack/web_profiler/request.rb', line 16

def body_string
  @body.to_s
end

#freezeObject

:nodoc:



28
29
30
31
# File 'lib/rack/web_profiler/request.rb', line 28

def freeze # :nodoc:
  @body = body.read
  super
end

#http_headersHash

Get HTTP headers.

Returns:

  • (Hash)


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

#rawString

Get full HTTP request in HTTP format.

Returns:

  • (String)


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