thin 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of thin might be problematic. Click here for more details.

Files changed (51) hide show
  1. data/README +47 -5
  2. data/Rakefile +33 -2
  3. data/doc/rdoc/classes/Kernel.html +182 -0
  4. data/doc/rdoc/classes/Process.html +175 -0
  5. data/doc/rdoc/classes/Thin.html +184 -0
  6. data/doc/rdoc/classes/Thin/CGIWrapper.html +438 -0
  7. data/doc/rdoc/classes/Thin/Cluster.html +392 -0
  8. data/doc/rdoc/classes/Thin/Command.html +221 -0
  9. data/doc/rdoc/classes/Thin/CommandError.html +154 -0
  10. data/doc/rdoc/classes/Thin/Commands.html +145 -0
  11. data/doc/rdoc/classes/Thin/Daemonizable.html +250 -0
  12. data/doc/rdoc/classes/Thin/Daemonizable/ClassMethods.html +203 -0
  13. data/doc/rdoc/classes/Thin/DirHandler.html +250 -0
  14. data/doc/rdoc/classes/Thin/Handler.html +195 -0
  15. data/doc/rdoc/classes/Thin/Headers.html +244 -0
  16. data/doc/rdoc/classes/Thin/InvalidRequest.html +150 -0
  17. data/doc/rdoc/classes/Thin/Logging.html +214 -0
  18. data/doc/rdoc/classes/Thin/RailsHandler.html +234 -0
  19. data/doc/rdoc/classes/Thin/RailsServer.html +175 -0
  20. data/doc/rdoc/classes/Thin/Request.html +379 -0
  21. data/doc/rdoc/classes/Thin/Response.html +311 -0
  22. data/doc/rdoc/classes/Thin/Server.html +381 -0
  23. data/doc/rdoc/created.rid +1 -0
  24. data/doc/rdoc/files/README.html +260 -0
  25. data/doc/rdoc/files/bin/thin.html +188 -0
  26. data/doc/rdoc/files/bin/thin_cluster.html +175 -0
  27. data/doc/rdoc/files/lib/thin/cgi_rb.html +263 -0
  28. data/doc/rdoc/files/lib/thin/cluster_rb.html +263 -0
  29. data/doc/rdoc/files/lib/thin/command_rb.html +263 -0
  30. data/doc/rdoc/files/lib/thin/consts_rb.html +263 -0
  31. data/doc/rdoc/files/lib/thin/daemonizing_rb.html +263 -0
  32. data/doc/rdoc/files/lib/thin/handler_rb.html +263 -0
  33. data/doc/rdoc/files/lib/thin/headers_rb.html +263 -0
  34. data/doc/rdoc/files/lib/thin/logging_rb.html +263 -0
  35. data/doc/rdoc/files/lib/thin/mime_types_rb.html +263 -0
  36. data/doc/rdoc/files/lib/thin/rails_rb.html +263 -0
  37. data/doc/rdoc/files/lib/thin/recipes_rb.html +171 -0
  38. data/doc/rdoc/files/lib/thin/request_rb.html +171 -0
  39. data/doc/rdoc/files/lib/thin/response_rb.html +171 -0
  40. data/doc/rdoc/files/lib/thin/server_rb.html +171 -0
  41. data/doc/rdoc/files/lib/thin/statuses_rb.html +171 -0
  42. data/doc/rdoc/files/lib/thin/version_rb.html +171 -0
  43. data/doc/rdoc/index.html +10 -0
  44. data/doc/rdoc/logo.gif +0 -0
  45. data/doc/rdoc/rdoc-style.css +86 -0
  46. data/lib/thin/commands/cluster/config.rb +2 -0
  47. data/lib/thin/consts.rb +4 -0
  48. data/lib/thin/request.rb +30 -11
  49. data/lib/thin/server.rb +1 -1
  50. data/lib/thin/version.rb +1 -1
  51. metadata +52 -1
@@ -0,0 +1,184 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
+ <html>
4
+ <head>
5
+ <title>
6
+ thin &raquo; Module: Thin
7
+ </title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
10
+ <script language="JavaScript" type="text/javascript">
11
+ // <![CDATA[
12
+
13
+ function toggleSource( id )
14
+ {
15
+ var elem
16
+ var link
17
+
18
+ if( document.getElementById )
19
+ {
20
+ elem = document.getElementById( id )
21
+ link = document.getElementById( "l_" + id )
22
+ }
23
+ else if ( document.all )
24
+ {
25
+ elem = eval( "document.all." + id )
26
+ link = eval( "document.all.l_" + id )
27
+ }
28
+ else
29
+ return false;
30
+
31
+ if( elem.style.display == "block" )
32
+ {
33
+ elem.style.display = "none"
34
+ link.innerHTML = "show source"
35
+ }
36
+ else
37
+ {
38
+ elem.style.display = "block"
39
+ link.innerHTML = "hide source"
40
+ }
41
+ }
42
+
43
+ function openCode( url )
44
+ {
45
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
+ }
47
+ // ]]>
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <ul id="menu">
52
+ <li><a href="/thin/">home</a></li>
53
+ <li><a href="/thin/doc/">doc</a></li>
54
+ <li><a href="/thin/trac.fcgi/timeline">timeline</a></li>
55
+ <li><a href="/thin/trac.fcgi/browser">code</a></li>
56
+ <li><a href="/thin/trac.fcgi/report">tickets</a></li>
57
+ <li><a href="/thin/trac.fcgi/newticket">new ticket</a></li>
58
+ </ul>
59
+ <div id="sidebar">
60
+ <h2>Files</h2>
61
+ <ul class="list">
62
+ <li><a href="../files/README.html" value="File: README">README</a></li>
63
+ <li><a href="../files/lib/thin/cgi_rb.html" value="File: cgi.rb">lib/thin/cgi.rb</a></li>
64
+ <li><a href="../files/lib/thin/cluster_rb.html" value="File: cluster.rb">lib/thin/cluster.rb</a></li>
65
+ <li><a href="../files/lib/thin/command_rb.html" value="File: command.rb">lib/thin/command.rb</a></li>
66
+ <li><a href="../files/lib/thin/consts_rb.html" value="File: consts.rb">lib/thin/consts.rb</a></li>
67
+ <li><a href="../files/lib/thin/daemonizing_rb.html" value="File: daemonizing.rb">lib/thin/daemonizing.rb</a></li>
68
+ <li><a href="../files/lib/thin/handler_rb.html" value="File: handler.rb">lib/thin/handler.rb</a></li>
69
+ <li><a href="../files/lib/thin/headers_rb.html" value="File: headers.rb">lib/thin/headers.rb</a></li>
70
+ <li><a href="../files/lib/thin/logging_rb.html" value="File: logging.rb">lib/thin/logging.rb</a></li>
71
+ <li><a href="../files/lib/thin/mime_types_rb.html" value="File: mime_types.rb">lib/thin/mime_types.rb</a></li>
72
+ <li><a href="../files/lib/thin/rails_rb.html" value="File: rails.rb">lib/thin/rails.rb</a></li>
73
+ <li><a href="../files/lib/thin/recipes_rb.html" value="File: recipes.rb">lib/thin/recipes.rb</a></li>
74
+ <li><a href="../files/lib/thin/request_rb.html" value="File: request.rb">lib/thin/request.rb</a></li>
75
+ <li><a href="../files/lib/thin/response_rb.html" value="File: response.rb">lib/thin/response.rb</a></li>
76
+ <li><a href="../files/lib/thin/server_rb.html" value="File: server.rb">lib/thin/server.rb</a></li>
77
+ <li><a href="../files/lib/thin/statuses_rb.html" value="File: statuses.rb">lib/thin/statuses.rb</a></li>
78
+ <li><a href="../files/lib/thin/version_rb.html" value="File: version.rb">lib/thin/version.rb</a></li>
79
+ <li><a href="../files/bin/thin.html" value="File: thin">bin/thin</a></li>
80
+ <li><a href="../files/bin/thin_cluster.html" value="File: thin_cluster">bin/thin_cluster</a></li>
81
+ </ul>
82
+
83
+ <h2>Classes</h2>
84
+ <ul class="list">
85
+ <li><a href="../classes/Thin.html" title="Module: Thin">Thin</a></li>
86
+ <li><a href="../classes/Thin/Commands.html" title="Module: Thin::Commands">Thin::Commands</a></li>
87
+ <li><a href="../classes/Thin/Daemonizable.html" title="Module: Thin::Daemonizable">Thin::Daemonizable</a></li>
88
+ <li><a href="../classes/Thin/Daemonizable/ClassMethods.html" title="Module: Thin::Daemonizable::ClassMethods">Thin::Daemonizable::ClassMethods</a></li>
89
+ <li><a href="../classes/Thin/VERSION.html" title="Module: Thin::VERSION">Thin::VERSION</a></li>
90
+ <li><a href="../classes/Thin/Logging.html" title="Module: Thin::Logging">Thin::Logging</a></li>
91
+ <li><a href="../classes/Thin/DirHandler.html" title="Class: Thin::DirHandler">Thin::DirHandler</a></li>
92
+ <li><a href="../classes/Thin/InvalidRequest.html" title="Class: Thin::InvalidRequest">Thin::InvalidRequest</a></li>
93
+ <li><a href="../classes/Thin/CGIWrapper.html" title="Class: Thin::CGIWrapper">Thin::CGIWrapper</a></li>
94
+ <li><a href="../classes/Thin/Command.html" title="Class: Thin::Command">Thin::Command</a></li>
95
+ <li><a href="../classes/Thin/Response.html" title="Class: Thin::Response">Thin::Response</a></li>
96
+ <li><a href="../classes/Thin/Headers.html" title="Class: Thin::Headers">Thin::Headers</a></li>
97
+ <li><a href="../classes/Thin/Server.html" title="Class: Thin::Server">Thin::Server</a></li>
98
+ <li><a href="../classes/Thin/CommandError.html" title="Class: Thin::CommandError">Thin::CommandError</a></li>
99
+ <li><a href="../classes/Thin/Request.html" title="Class: Thin::Request">Thin::Request</a></li>
100
+ <li><a href="../classes/Thin/RailsServer.html" title="Class: Thin::RailsServer">Thin::RailsServer</a></li>
101
+ <li><a href="../classes/Thin/Cluster.html" title="Class: Thin::Cluster">Thin::Cluster</a></li>
102
+ <li><a href="../classes/Thin/RailsHandler.html" title="Class: Thin::RailsHandler">Thin::RailsHandler</a></li>
103
+ <li><a href="../classes/Thin/Handler.html" title="Class: Thin::Handler">Thin::Handler</a></li>
104
+ <li><a href="../classes/Process.html" title="Module: Process">Process</a></li>
105
+ <li><a href="../classes/Kernel.html" title="Module: Kernel">Kernel</a></li>
106
+ </ul>
107
+ </div>
108
+ <div id="container">
109
+ <div id="header">
110
+ <a href="/thin/" title="Home">
111
+ <img id="logo" src="../logo.gif" />
112
+ </a>
113
+ <h2 id="tag_line">A fast and very simple Ruby web server</h2>
114
+ </div>
115
+
116
+ <div id="content">
117
+ <h2>Module: Thin</h2>
118
+
119
+
120
+ <div id="Thin" class="page_shade">
121
+ <div class="page">
122
+ <h3>Module Thin</h3>
123
+
124
+ <span class="path">(in files
125
+ <a href="../files/lib/thin/cgi_rb.html">lib/thin/cgi.rb</a>
126
+ <a href="../files/lib/thin/cluster_rb.html">lib/thin/cluster.rb</a>
127
+ <a href="../files/lib/thin/command_rb.html">lib/thin/command.rb</a>
128
+ <a href="../files/lib/thin/consts_rb.html">lib/thin/consts.rb</a>
129
+ <a href="../files/lib/thin/daemonizing_rb.html">lib/thin/daemonizing.rb</a>
130
+ <a href="../files/lib/thin/handler_rb.html">lib/thin/handler.rb</a>
131
+ <a href="../files/lib/thin/headers_rb.html">lib/thin/headers.rb</a>
132
+ <a href="../files/lib/thin/logging_rb.html">lib/thin/logging.rb</a>
133
+ <a href="../files/lib/thin/mime_types_rb.html">lib/thin/mime_types.rb</a>
134
+ <a href="../files/lib/thin/rails_rb.html">lib/thin/rails.rb</a>
135
+ <a href="../files/lib/thin/request_rb.html">lib/thin/request.rb</a>
136
+ <a href="../files/lib/thin/response_rb.html">lib/thin/response.rb</a>
137
+ <a href="../files/lib/thin/server_rb.html">lib/thin/server.rb</a>
138
+ <a href="../files/lib/thin/statuses_rb.html">lib/thin/statuses.rb</a>
139
+ <a href="../files/lib/thin/version_rb.html">lib/thin/version.rb</a>
140
+ )</span>
141
+
142
+
143
+
144
+
145
+
146
+ <h2 class="ruled">Methods</h2>
147
+ <h4 class="ruled">
148
+ <span class="method-type" title="Public Class method">Public Class</span>
149
+ <strong><a name="M000001" href="#M000001" title="Permalink to Public Class method: define_commands">define_commands(&amp;block)</a></strong>
150
+ </h4>
151
+
152
+ <p>
153
+ Define a set of commands that can be parsed and executed. see bin/thin for
154
+ an example.
155
+ </p>
156
+
157
+ <div class="sourcecode">
158
+ <p class="source-link">[ <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show source</a> ]</p>
159
+ <div id="M000001_source" class="dyn-source">
160
+ <pre>
161
+ <span class="ruby-comment cmt"># File lib/thin/command.rb, line 6</span>
162
+ 6: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">define_commands</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
163
+ 7: <span class="ruby-keyword kw">begin</span>
164
+ 8: <span class="ruby-constant">Transat</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">parse_and_execute</span>(<span class="ruby-constant">ARGV</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
165
+ 9: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CommandError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
166
+ 10: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Error: #{e}&quot;</span>
167
+ 11: <span class="ruby-keyword kw">end</span>
168
+ 12: <span class="ruby-keyword kw">end</span>
169
+ </pre>
170
+ </div>
171
+ </div>
172
+
173
+ </div>
174
+ </div>
175
+
176
+
177
+ </div>
178
+ </div>
179
+ <div id="footer">
180
+ <hr />
181
+ &copy; <a href="http://macournoyer.com">Marc-Andr&eacute; Cournoyer</a>
182
+ </div>
183
+ </body>
184
+ </html>
@@ -0,0 +1,438 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
+ <html>
4
+ <head>
5
+ <title>
6
+ thin &raquo; Class: Thin::CGIWrapper
7
+ </title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+ <script language="JavaScript" type="text/javascript">
11
+ // <![CDATA[
12
+
13
+ function toggleSource( id )
14
+ {
15
+ var elem
16
+ var link
17
+
18
+ if( document.getElementById )
19
+ {
20
+ elem = document.getElementById( id )
21
+ link = document.getElementById( "l_" + id )
22
+ }
23
+ else if ( document.all )
24
+ {
25
+ elem = eval( "document.all." + id )
26
+ link = eval( "document.all.l_" + id )
27
+ }
28
+ else
29
+ return false;
30
+
31
+ if( elem.style.display == "block" )
32
+ {
33
+ elem.style.display = "none"
34
+ link.innerHTML = "show source"
35
+ }
36
+ else
37
+ {
38
+ elem.style.display = "block"
39
+ link.innerHTML = "hide source"
40
+ }
41
+ }
42
+
43
+ function openCode( url )
44
+ {
45
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
+ }
47
+ // ]]>
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <ul id="menu">
52
+ <li><a href="/thin/">home</a></li>
53
+ <li><a href="/thin/doc/">doc</a></li>
54
+ <li><a href="/thin/trac.fcgi/timeline">timeline</a></li>
55
+ <li><a href="/thin/trac.fcgi/browser">code</a></li>
56
+ <li><a href="/thin/trac.fcgi/report">tickets</a></li>
57
+ <li><a href="/thin/trac.fcgi/newticket">new ticket</a></li>
58
+ </ul>
59
+ <div id="sidebar">
60
+ <h2>Files</h2>
61
+ <ul class="list">
62
+ <li><a href="../../files/README.html" value="File: README">README</a></li>
63
+ <li><a href="../../files/lib/thin/cgi_rb.html" value="File: cgi.rb">lib/thin/cgi.rb</a></li>
64
+ <li><a href="../../files/lib/thin/cluster_rb.html" value="File: cluster.rb">lib/thin/cluster.rb</a></li>
65
+ <li><a href="../../files/lib/thin/command_rb.html" value="File: command.rb">lib/thin/command.rb</a></li>
66
+ <li><a href="../../files/lib/thin/consts_rb.html" value="File: consts.rb">lib/thin/consts.rb</a></li>
67
+ <li><a href="../../files/lib/thin/daemonizing_rb.html" value="File: daemonizing.rb">lib/thin/daemonizing.rb</a></li>
68
+ <li><a href="../../files/lib/thin/handler_rb.html" value="File: handler.rb">lib/thin/handler.rb</a></li>
69
+ <li><a href="../../files/lib/thin/headers_rb.html" value="File: headers.rb">lib/thin/headers.rb</a></li>
70
+ <li><a href="../../files/lib/thin/logging_rb.html" value="File: logging.rb">lib/thin/logging.rb</a></li>
71
+ <li><a href="../../files/lib/thin/mime_types_rb.html" value="File: mime_types.rb">lib/thin/mime_types.rb</a></li>
72
+ <li><a href="../../files/lib/thin/rails_rb.html" value="File: rails.rb">lib/thin/rails.rb</a></li>
73
+ <li><a href="../../files/lib/thin/recipes_rb.html" value="File: recipes.rb">lib/thin/recipes.rb</a></li>
74
+ <li><a href="../../files/lib/thin/request_rb.html" value="File: request.rb">lib/thin/request.rb</a></li>
75
+ <li><a href="../../files/lib/thin/response_rb.html" value="File: response.rb">lib/thin/response.rb</a></li>
76
+ <li><a href="../../files/lib/thin/server_rb.html" value="File: server.rb">lib/thin/server.rb</a></li>
77
+ <li><a href="../../files/lib/thin/statuses_rb.html" value="File: statuses.rb">lib/thin/statuses.rb</a></li>
78
+ <li><a href="../../files/lib/thin/version_rb.html" value="File: version.rb">lib/thin/version.rb</a></li>
79
+ <li><a href="../../files/bin/thin.html" value="File: thin">bin/thin</a></li>
80
+ <li><a href="../../files/bin/thin_cluster.html" value="File: thin_cluster">bin/thin_cluster</a></li>
81
+ </ul>
82
+
83
+ <h2>Classes</h2>
84
+ <ul class="list">
85
+ <li><a href="../../classes/Thin.html" title="Module: Thin">Thin</a></li>
86
+ <li><a href="../../classes/Thin/Commands.html" title="Module: Thin::Commands">Thin::Commands</a></li>
87
+ <li><a href="../../classes/Thin/Daemonizable.html" title="Module: Thin::Daemonizable">Thin::Daemonizable</a></li>
88
+ <li><a href="../../classes/Thin/Daemonizable/ClassMethods.html" title="Module: Thin::Daemonizable::ClassMethods">Thin::Daemonizable::ClassMethods</a></li>
89
+ <li><a href="../../classes/Thin/VERSION.html" title="Module: Thin::VERSION">Thin::VERSION</a></li>
90
+ <li><a href="../../classes/Thin/Logging.html" title="Module: Thin::Logging">Thin::Logging</a></li>
91
+ <li><a href="../../classes/Thin/DirHandler.html" title="Class: Thin::DirHandler">Thin::DirHandler</a></li>
92
+ <li><a href="../../classes/Thin/InvalidRequest.html" title="Class: Thin::InvalidRequest">Thin::InvalidRequest</a></li>
93
+ <li><a href="../../classes/Thin/CGIWrapper.html" title="Class: Thin::CGIWrapper">Thin::CGIWrapper</a></li>
94
+ <li><a href="../../classes/Thin/Command.html" title="Class: Thin::Command">Thin::Command</a></li>
95
+ <li><a href="../../classes/Thin/Response.html" title="Class: Thin::Response">Thin::Response</a></li>
96
+ <li><a href="../../classes/Thin/Headers.html" title="Class: Thin::Headers">Thin::Headers</a></li>
97
+ <li><a href="../../classes/Thin/Server.html" title="Class: Thin::Server">Thin::Server</a></li>
98
+ <li><a href="../../classes/Thin/CommandError.html" title="Class: Thin::CommandError">Thin::CommandError</a></li>
99
+ <li><a href="../../classes/Thin/Request.html" title="Class: Thin::Request">Thin::Request</a></li>
100
+ <li><a href="../../classes/Thin/RailsServer.html" title="Class: Thin::RailsServer">Thin::RailsServer</a></li>
101
+ <li><a href="../../classes/Thin/Cluster.html" title="Class: Thin::Cluster">Thin::Cluster</a></li>
102
+ <li><a href="../../classes/Thin/RailsHandler.html" title="Class: Thin::RailsHandler">Thin::RailsHandler</a></li>
103
+ <li><a href="../../classes/Thin/Handler.html" title="Class: Thin::Handler">Thin::Handler</a></li>
104
+ <li><a href="../../classes/Process.html" title="Module: Process">Process</a></li>
105
+ <li><a href="../../classes/Kernel.html" title="Module: Kernel">Kernel</a></li>
106
+ </ul>
107
+ </div>
108
+ <div id="container">
109
+ <div id="header">
110
+ <a href="/thin/" title="Home">
111
+ <img id="logo" src="../../logo.gif" />
112
+ </a>
113
+ <h2 id="tag_line">A fast and very simple Ruby web server</h2>
114
+ </div>
115
+
116
+ <div id="content">
117
+ <h2>Class: Thin::CGIWrapper</h2>
118
+
119
+
120
+ <div id="Thin::CGIWrapper" class="page_shade">
121
+ <div class="page">
122
+ <h3>Class Thin::CGIWrapper &lt; <a href="Handler.html">::CGI</a></h3>
123
+
124
+ <span class="path">(in files
125
+ <a href="../../files/lib/thin/cgi_rb.html">lib/thin/cgi.rb</a>
126
+ )</span>
127
+
128
+ <p>
129
+ Class largely based on Mongrel::CGIWrapper <a
130
+ href="http://mongrel.rubyforge.org">mongrel.rubyforge.org</a> by Zed A.
131
+ Shaw &lt;zedshaw at zedshaw dot com&gt;
132
+ </p>
133
+
134
+
135
+
136
+
137
+
138
+ <h2 class="ruled">Methods</h2>
139
+ <h4 class="ruled">
140
+ <span class="method-type" title="Public Class method">Public Class</span>
141
+ <strong><a name="M000014" href="#M000014" title="Permalink to Public Class method: new">new(request, response, *args)</a></strong>
142
+ </h4>
143
+
144
+ <p>
145
+ Takes an HttpRequest and HttpResponse object, plus any additional arguments
146
+ normally passed to CGI. These are used internally to create a wrapper
147
+ around the real CGI while maintaining Mongrel&#8216;s view of the world.
148
+ </p>
149
+
150
+ <div class="sourcecode">
151
+ <p class="source-link">[ <a href="javascript:toggleSource('M000014_source')" id="l_M000014_source">show source</a> ]</p>
152
+ <div id="M000014_source" class="dyn-source">
153
+ <pre>
154
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 20</span>
155
+ 20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
156
+ 21: <span class="ruby-ivar">@request</span> = <span class="ruby-identifier">request</span>
157
+ 22: <span class="ruby-ivar">@response</span> = <span class="ruby-identifier">response</span>
158
+ 23: <span class="ruby-ivar">@args</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
159
+ 24: <span class="ruby-ivar">@input</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span>
160
+ 25: <span class="ruby-ivar">@head</span> = {}
161
+ 26: <span class="ruby-ivar">@out_called</span> = <span class="ruby-keyword kw">false</span>
162
+ 27: <span class="ruby-ivar">@default_really_final</span> = <span class="ruby-keyword kw">true</span>
163
+ 28: <span class="ruby-keyword kw">super</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
164
+ 29: <span class="ruby-keyword kw">end</span>
165
+ </pre>
166
+ </div>
167
+ </div>
168
+ <h4 class="ruled">
169
+ <span class="method-type" title="Public Instance method">Public Instance</span>
170
+ <strong><a name="M000019" href="#M000019" title="Permalink to Public Instance method: args">args()</a></strong>
171
+ </h4>
172
+
173
+ <p>
174
+ Used to wrap the normal <a href="CGIWrapper.html#M000019">args</a> variable
175
+ used inside CGI.
176
+ </p>
177
+
178
+ <div class="sourcecode">
179
+ <p class="source-link">[ <a href="javascript:toggleSource('M000019_source')" id="l_M000019_source">show source</a> ]</p>
180
+ <div id="M000019_source" class="dyn-source">
181
+ <pre>
182
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 138</span>
183
+ 138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">args</span>
184
+ 139: <span class="ruby-ivar">@args</span>
185
+ 140: <span class="ruby-keyword kw">end</span>
186
+ </pre>
187
+ </div>
188
+ </div>
189
+ <h4 class="ruled">
190
+ <span class="method-type" title="Public Instance method">Public Instance</span>
191
+ <strong><a name="M000020" href="#M000020" title="Permalink to Public Instance method: env_table">env_table()</a></strong>
192
+ </h4>
193
+
194
+ <p>
195
+ Used to wrap the normal <a href="CGIWrapper.html#M000020">env_table</a>
196
+ variable used inside CGI.
197
+ </p>
198
+
199
+ <div class="sourcecode">
200
+ <p class="source-link">[ <a href="javascript:toggleSource('M000020_source')" id="l_M000020_source">show source</a> ]</p>
201
+ <div id="M000020_source" class="dyn-source">
202
+ <pre>
203
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 143</span>
204
+ 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env_table</span>
205
+ 144: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
206
+ 145: <span class="ruby-keyword kw">end</span>
207
+ </pre>
208
+ </div>
209
+ </div>
210
+ <h4 class="ruled">
211
+ <span class="method-type" title="Public Instance method">Public Instance</span>
212
+ <strong><a name="M000015" href="#M000015" title="Permalink to Public Instance method: header">header(options = &quot;text/html&quot;)</a></strong>
213
+ </h4>
214
+
215
+ <p>
216
+ The <a href="CGIWrapper.html#M000015">header</a> is typically called to
217
+ send back the <a href="CGIWrapper.html#M000015">header</a>. In our case we
218
+ collect it into a hash for later usage.
219
+ </p>
220
+ <p>
221
+ nph &#8212; Mostly ignored. It&#8216;ll output the date. connection &#8212;
222
+ Completely ignored. Why is CGI doing this? length &#8212; Ignored since
223
+ Mongrel figures this <a href="CGIWrapper.html#M000017">out</a> from what
224
+ you write to output.
225
+ </p>
226
+
227
+ <div class="sourcecode">
228
+ <p class="source-link">[ <a href="javascript:toggleSource('M000015_source')" id="l_M000015_source">show source</a> ]</p>
229
+ <div id="M000015_source" class="dyn-source">
230
+ <pre>
231
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 38</span>
232
+ 38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">header</span>(<span class="ruby-identifier">options</span> = <span class="ruby-value str">&quot;text/html&quot;</span>)
233
+ 39: <span class="ruby-comment cmt"># if they pass in a string then just write the Content-Type</span>
234
+ 40: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
235
+ 41: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">options</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>]
236
+ 42: <span class="ruby-keyword kw">else</span>
237
+ 43: <span class="ruby-comment cmt"># convert the given options into what Mongrel wants</span>
238
+ 44: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'type'</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;text/html&quot;</span>
239
+ 45: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Type'</span>] <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot;; charset=&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'charset'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-value str">&quot;charset&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'charset'</span>]
240
+ 46:
241
+ 47: <span class="ruby-comment cmt"># setup date only if they use nph</span>
242
+ 48: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Date'</span>] = <span class="ruby-constant">CGI</span><span class="ruby-operator">::</span><span class="ruby-identifier">rfc1123_date</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'nph'</span>]
243
+ 49:
244
+ 50: <span class="ruby-comment cmt"># setup the server to use the default or what they set</span>
245
+ 51: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Server'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'server'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">env_table</span>[<span class="ruby-value str">'SERVER_SOFTWARE'</span>]
246
+ 52:
247
+ 53: <span class="ruby-comment cmt"># remaining possible options they can give</span>
248
+ 54: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Status'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'status'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'status'</span>]
249
+ 55: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Content-Language'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'language'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'language'</span>]
250
+ 56: <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'Expires'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'expires'</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">'expires'</span>]
251
+ 57:
252
+ 58: <span class="ruby-comment cmt"># drop the keys we don't want anymore</span>
253
+ 59: <span class="ruby-constant">REMOVED_KEYS</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>) }
254
+ 60:
255
+ 61: <span class="ruby-comment cmt"># finally just convert the rest raw (which puts 'cookie' directly)</span>
256
+ 62: <span class="ruby-comment cmt"># 'cookie' is translated later as we write the header out</span>
257
+ 63: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@head</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>}
258
+ 64: <span class="ruby-keyword kw">end</span>
259
+ 65:
260
+ 66: <span class="ruby-comment cmt"># doing this fakes out the cgi library to think the headers are empty</span>
261
+ 67: <span class="ruby-comment cmt"># we then do the real headers in the out function call later</span>
262
+ 68: <span class="ruby-value str">&quot;&quot;</span>
263
+ 69: <span class="ruby-keyword kw">end</span>
264
+ </pre>
265
+ </div>
266
+ </div>
267
+ <h4 class="ruled">
268
+ <span class="method-type" title="Public Instance method">Public Instance</span>
269
+ <strong><a name="M000017" href="#M000017" title="Permalink to Public Instance method: out">out(options = &quot;text/html&quot;, really_final=@default_really_final) {||| &quot;&quot;)| ...}</a></strong>
270
+ </h4>
271
+
272
+ <p>
273
+ The dumb thing is people can call <a
274
+ href="CGIWrapper.html#M000015">header</a> or this or both and in any order.
275
+ So, we just reuse <a href="CGIWrapper.html#M000015">header</a> and then
276
+ finalize the HttpResponse the right way. Status is taken from the various
277
+ options and converted to what Mongrel needs via the <a
278
+ href="CGIWrapper.html#M000018">CGIWrapper.status</a> function.
279
+ </p>
280
+ <p>
281
+ We also prevent Rails from actually doing the final send by adding a second
282
+ parameter &quot;really_final&quot;. Only Mongrel calls this after Rails is
283
+ done. Since this will break other frameworks, it defaults to a different
284
+ setting for rails (false) and (true) for others.
285
+ </p>
286
+
287
+ <div class="sourcecode">
288
+ <p class="source-link">[ <a href="javascript:toggleSource('M000017_source')" id="l_M000017_source">show source</a> ]</p>
289
+ <div id="M000017_source" class="dyn-source">
290
+ <pre>
291
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 105</span>
292
+ 105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">out</span>(<span class="ruby-identifier">options</span> = <span class="ruby-value str">&quot;text/html&quot;</span>, <span class="ruby-identifier">really_final</span>=<span class="ruby-ivar">@default_really_final</span>)
293
+ 106: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@out_called</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-identifier">really_final</span>
294
+ 107: <span class="ruby-comment cmt"># don't do it more than once or if it's not the really final call</span>
295
+ 108: <span class="ruby-keyword kw">return</span>
296
+ 109: <span class="ruby-keyword kw">end</span>
297
+ 110:
298
+ 111: <span class="ruby-identifier">header</span>(<span class="ruby-identifier">options</span>)
299
+ 112:
300
+ 113: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">start</span> <span class="ruby-identifier">status</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>, <span class="ruby-identifier">body</span><span class="ruby-operator">|</span>
301
+ 114: <span class="ruby-identifier">send_cookies</span>(<span class="ruby-identifier">head</span>)
302
+ 115:
303
+ 116: <span class="ruby-ivar">@head</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">head</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>}
304
+ 117: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">write</span>(<span class="ruby-keyword kw">yield</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>)
305
+ 118: <span class="ruby-keyword kw">end</span>
306
+ 119:
307
+ 120: <span class="ruby-ivar">@out_called</span> = <span class="ruby-keyword kw">true</span>
308
+ 121: <span class="ruby-keyword kw">end</span>
309
+ </pre>
310
+ </div>
311
+ </div>
312
+ <h4 class="ruled">
313
+ <span class="method-type" title="Public Instance method">Public Instance</span>
314
+ <strong><a name="M000016" href="#M000016" title="Permalink to Public Instance method: send_cookies">send_cookies(to)</a></strong>
315
+ </h4>
316
+
317
+ <p>
318
+ Takes any &#8216;cookie&#8217; setting and sends it over the Mongrel <a
319
+ href="CGIWrapper.html#M000015">header</a>, then removes the setting from
320
+ the options. If cookie is an Array or Hash then it sends those on with
321
+ .to_s, otherwise it just calls .to_s on it and hopefully your
322
+ &quot;cookie&quot; can write itself correctly.
323
+ </p>
324
+
325
+ <div class="sourcecode">
326
+ <p class="source-link">[ <a href="javascript:toggleSource('M000016_source')" id="l_M000016_source">show source</a> ]</p>
327
+ <div id="M000016_source" class="dyn-source">
328
+ <pre>
329
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 76</span>
330
+ 76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_cookies</span>(<span class="ruby-identifier">to</span>)
331
+ 77: <span class="ruby-comment cmt"># convert the cookies based on the myriad of possible ways to set a cookie</span>
332
+ 78: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'cookie'</span>]
333
+ 79: <span class="ruby-identifier">cookie</span> = <span class="ruby-ivar">@head</span>[<span class="ruby-value str">'cookie'</span>]
334
+ 80: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">cookie</span>
335
+ 81: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
336
+ 82: <span class="ruby-identifier">cookie</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span> }
337
+ 83: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
338
+ 84: <span class="ruby-identifier">cookie</span>.<span class="ruby-identifier">each_value</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span>}
339
+ 85: <span class="ruby-keyword kw">else</span>
340
+ 86: <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">options</span>[<span class="ruby-value str">'cookie'</span>].<span class="ruby-identifier">to_s</span>
341
+ 87: <span class="ruby-keyword kw">end</span>
342
+ 88:
343
+ 89: <span class="ruby-ivar">@head</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'cookie'</span>)
344
+ 90: <span class="ruby-keyword kw">end</span>
345
+ 91:
346
+ 92: <span class="ruby-comment cmt"># @output_cookies seems to never be used, but we'll process it just in case</span>
347
+ 93: <span class="ruby-ivar">@output_cookies</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to</span>[<span class="ruby-value str">'Set-Cookie'</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@output_cookies</span>
348
+ 94: <span class="ruby-keyword kw">end</span>
349
+ </pre>
350
+ </div>
351
+ </div>
352
+ <h4 class="ruled">
353
+ <span class="method-type" title="Public Instance method">Public Instance</span>
354
+ <strong><a name="M000018" href="#M000018" title="Permalink to Public Instance method: status">status()</a></strong>
355
+ </h4>
356
+
357
+ <p>
358
+ Computes the <a href="CGIWrapper.html#M000018">status</a> once, but lazily
359
+ so that people who call <a href="CGIWrapper.html#M000015">header</a> twice
360
+ don&#8216;t get penalized. Because CGI insists on including the options <a
361
+ href="CGIWrapper.html#M000018">status</a> message in the <a
362
+ href="CGIWrapper.html#M000018">status</a> we have to do a bit of parsing.
363
+ </p>
364
+
365
+ <div class="sourcecode">
366
+ <p class="source-link">[ <a href="javascript:toggleSource('M000018_source')" id="l_M000018_source">show source</a> ]</p>
367
+ <div id="M000018_source" class="dyn-source">
368
+ <pre>
369
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 126</span>
370
+ 126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">status</span>
371
+ 127: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@status</span>
372
+ 128: <span class="ruby-identifier">stat</span> = <span class="ruby-ivar">@head</span>[<span class="ruby-value str">&quot;Status&quot;</span>]
373
+ 129: <span class="ruby-identifier">stat</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">' '</span>)[<span class="ruby-value">0</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">stat</span>
374
+ 130:
375
+ 131: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">stat</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;200&quot;</span>
376
+ 132: <span class="ruby-keyword kw">end</span>
377
+ 133:
378
+ 134: <span class="ruby-ivar">@status</span>
379
+ 135: <span class="ruby-keyword kw">end</span>
380
+ </pre>
381
+ </div>
382
+ </div>
383
+ <h4 class="ruled">
384
+ <span class="method-type" title="Public Instance method">Public Instance</span>
385
+ <strong><a name="M000021" href="#M000021" title="Permalink to Public Instance method: stdinput">stdinput()</a></strong>
386
+ </h4>
387
+
388
+ <p>
389
+ Used to wrap the normal <a href="CGIWrapper.html#M000021">stdinput</a>
390
+ variable used inside CGI.
391
+ </p>
392
+
393
+ <div class="sourcecode">
394
+ <p class="source-link">[ <a href="javascript:toggleSource('M000021_source')" id="l_M000021_source">show source</a> ]</p>
395
+ <div id="M000021_source" class="dyn-source">
396
+ <pre>
397
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 148</span>
398
+ 148: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdinput</span>
399
+ 149: <span class="ruby-ivar">@input</span>
400
+ 150: <span class="ruby-keyword kw">end</span>
401
+ </pre>
402
+ </div>
403
+ </div>
404
+ <h4 class="ruled">
405
+ <span class="method-type" title="Public Instance method">Public Instance</span>
406
+ <strong><a name="M000022" href="#M000022" title="Permalink to Public Instance method: stdoutput">stdoutput()</a></strong>
407
+ </h4>
408
+
409
+ <p>
410
+ The <a href="CGIWrapper.html#M000022">stdoutput</a> should be completely
411
+ bypassed but we&#8216;ll drop a warning just in case
412
+ </p>
413
+
414
+ <div class="sourcecode">
415
+ <p class="source-link">[ <a href="javascript:toggleSource('M000022_source')" id="l_M000022_source">show source</a> ]</p>
416
+ <div id="M000022_source" class="dyn-source">
417
+ <pre>
418
+ <span class="ruby-comment cmt"># File lib/thin/cgi.rb, line 153</span>
419
+ 153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdoutput</span>
420
+ 154: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;WARNING: Your program is doing something not expected. Please tell Zed that stdoutput was used and what software you are running. Thanks.&quot;</span>
421
+ 155: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span>
422
+ 156: <span class="ruby-keyword kw">end</span>
423
+ </pre>
424
+ </div>
425
+ </div>
426
+
427
+ </div>
428
+ </div>
429
+
430
+
431
+ </div>
432
+ </div>
433
+ <div id="footer">
434
+ <hr />
435
+ &copy; <a href="http://macournoyer.com">Marc-Andr&eacute; Cournoyer</a>
436
+ </div>
437
+ </body>
438
+ </html>