D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby18
/
lib64
/
ruby
/
gems
/
1.8
/
doc
/
rack-1.6.1
/
rdoc
/
classes
/
Rack
/
ShowStatus.src
/
Filename :
M000283.html
back
Copy
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>call (Rack::ShowStatus)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> <pre><span class="ruby-comment cmt"># File lib/rack/showstatus.rb, line 19</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>) <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>) <span class="ruby-identifier">headers</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">headers</span>) <span class="ruby-identifier">empty</span> = <span class="ruby-identifier">headers</span>[<span class="ruby-constant">CONTENT_LENGTH</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span> <span class="ruby-comment cmt"># client or server error, or explicit message</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">>=</span> <span class="ruby-value">400</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">empty</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">"rack.showstatus.detail"</span>] <span class="ruby-comment cmt"># This double assignment is to prevent an "unused variable" warning on</span> <span class="ruby-comment cmt"># Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me.</span> <span class="ruby-identifier">req</span> = <span class="ruby-identifier">req</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>) <span class="ruby-identifier">message</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-comment cmt"># This double assignment is to prevent an "unused variable" warning on</span> <span class="ruby-comment cmt"># Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me.</span> <span class="ruby-identifier">detail</span> = <span class="ruby-identifier">detail</span> = <span class="ruby-identifier">env</span>[<span class="ruby-value str">"rack.showstatus.detail"</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">message</span> <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@template</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>) <span class="ruby-identifier">size</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">bytesize</span>(<span class="ruby-identifier">body</span>) [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-constant">CONTENT_TYPE</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"text/html"</span>, <span class="ruby-constant">CONTENT_LENGTH</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>), [<span class="ruby-identifier">body</span>]] <span class="ruby-keyword kw">else</span> [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>] <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span></pre> </body> </html>