instiki/vendor/plugins/rack/doc/classes/Rack/Handler/LSWS.html
Jacques Distler 4e14ccc74d Instiki 0.16.3: Rails 2.3.0
Instiki now runs on the Rails 2.3.0 Candidate Release.
Among other improvements, this means that it now 
automagically selects between WEBrick and Mongrel.

Just run

    ./instiki --daemon
2009-02-04 14:26:08 -06:00

250 lines
12 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::LSWS</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::LSWS</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/lsws_rb.html">
lib/rack/handler/lsws.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000058">run</a>&nbsp;&nbsp;
<a href="#M000061">send_body</a>&nbsp;&nbsp;
<a href="#M000060">send_headers</a>&nbsp;&nbsp;
<a href="#M000059">serve</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000058" class="method-detail">
<a name="M000058"></a>
<div class="method-heading">
<a href="#M000058" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000058-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 6</span>
6: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>=<span class="ruby-keyword kw">nil</span>)
7: <span class="ruby-keyword kw">while</span> <span class="ruby-constant">LSAPI</span>.<span class="ruby-identifier">accept</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
8: <span class="ruby-identifier">serve</span> <span class="ruby-identifier">app</span>
9: <span class="ruby-keyword kw">end</span>
10: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000061" class="method-detail">
<a name="M000061"></a>
<div class="method-heading">
<a href="#M000061" class="method-signature">
<span class="method-name">send_body</span><span class="method-args">(body)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000061-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 44</span>
44: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_body</span>(<span class="ruby-identifier">body</span>)
45: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
46: <span class="ruby-identifier">print</span> <span class="ruby-identifier">part</span>
47: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">flush</span>
48: }
49: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000060" class="method-detail">
<a name="M000060"></a>
<div class="method-heading">
<a href="#M000060" class="method-signature">
<span class="method-name">send_headers</span><span class="method-args">(status, headers)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000060-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 34</span>
34: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_headers</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>)
35: <span class="ruby-identifier">print</span> <span class="ruby-node">&quot;Status: #{status}\r\n&quot;</span>
36: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
37: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
38: <span class="ruby-identifier">print</span> <span class="ruby-node">&quot;#{k}: #{v}\r\n&quot;</span>
39: }
40: }
41: <span class="ruby-identifier">print</span> <span class="ruby-value str">&quot;\r\n&quot;</span>
42: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">flush</span>
43: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000059" class="method-detail">
<a name="M000059"></a>
<div class="method-heading">
<a href="#M000059" class="method-signature">
<span class="method-name">serve</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000059-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 11</span>
11: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">serve</span>(<span class="ruby-identifier">app</span>)
12: <span class="ruby-identifier">env</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span>
13: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_LENGTH&quot;</span>
14: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
15: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
16: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDIN</span>,
17: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDERR</span>,
18: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
19: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
20: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
21: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;yes&quot;</span>, <span class="ruby-value str">&quot;on&quot;</span>, <span class="ruby-value str">&quot;1&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HTTPS&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;https&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;http&quot;</span>
22: })
23: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
24: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PROTOCOL&quot;</span>]
25: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;/&quot;</span>
26: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
27: <span class="ruby-keyword kw">begin</span>
28: <span class="ruby-identifier">send_headers</span> <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>
29: <span class="ruby-identifier">send_body</span> <span class="ruby-identifier">body</span>
30: <span class="ruby-keyword kw">ensure</span>
31: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
32: <span class="ruby-keyword kw">end</span>
33: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>