doc/rdoc/classes/Mongrel/HttpRequest.src/M000133.html in mongrel-0.3.13.4 vs doc/rdoc/classes/Mongrel/HttpRequest.src/M000133.html in mongrel-1.0

- old
+ new

@@ -3,18 +3,48 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> - <title>escape (Mongrel::HttpRequest)</title> + <title>new (Mongrel::HttpRequest)</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/mongrel.rb, line 269</span> -269: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">s</span>) -270: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([^ a-zA-Z0-9_.-]+)/n</span>) { -271: <span class="ruby-value str">'%'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'H2'</span><span class="ruby-operator">*</span><span class="ruby-identifier">$1</span>.<span class="ruby-identifier">size</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">'%'</span>).<span class="ruby-identifier">upcase</span> -272: }.<span class="ruby-identifier">tr</span>(<span class="ruby-value str">' '</span>, <span class="ruby-value str">'+'</span>) -273: <span class="ruby-keyword kw">end</span></pre> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 198</span> +198: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">socket</span>, <span class="ruby-identifier">dispatchers</span>) +199: <span class="ruby-ivar">@params</span> = <span class="ruby-identifier">params</span> +200: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span> +201: <span class="ruby-ivar">@dispatchers</span> = <span class="ruby-identifier">dispatchers</span> +202: <span class="ruby-identifier">content_length</span> = <span class="ruby-ivar">@params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_LENGTH</span>].<span class="ruby-identifier">to_i</span> +203: <span class="ruby-identifier">remain</span> = <span class="ruby-identifier">content_length</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span> +204: +205: <span class="ruby-comment cmt"># tell all dispatchers the request has begun</span> +206: <span class="ruby-ivar">@dispatchers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dispatcher</span><span class="ruby-operator">|</span> +207: <span class="ruby-identifier">dispatcher</span>.<span class="ruby-identifier">request_begins</span>(<span class="ruby-ivar">@params</span>) +208: <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@dispatchers</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@dispatchers</span>.<span class="ruby-identifier">empty?</span> +209: +210: <span class="ruby-comment cmt"># Some clients (like FF1.0) report 0 for body and then send a body. This will probably truncate them but at least the request goes through usually.</span> +211: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">remain</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span> +212: <span class="ruby-comment cmt"># we've got everything, pack it up</span> +213: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span> +214: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">write</span> <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">http_body</span> +215: <span class="ruby-identifier">update_request_progress</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">content_length</span>) +216: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">remain</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> +217: <span class="ruby-comment cmt"># must read more data to complete body</span> +218: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">remain</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">MAX_BODY</span> +219: <span class="ruby-comment cmt"># huge body, put it in a tempfile</span> +220: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">MONGREL_TMP_BASE</span>) +221: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">binmode</span> +222: <span class="ruby-keyword kw">else</span> +223: <span class="ruby-comment cmt"># small body, just use that</span> +224: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span> +225: <span class="ruby-keyword kw">end</span> +226: +227: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">write</span> <span class="ruby-ivar">@params</span>.<span class="ruby-identifier">http_body</span> +228: <span class="ruby-identifier">read_body</span>(<span class="ruby-identifier">remain</span>, <span class="ruby-identifier">content_length</span>) +229: <span class="ruby-keyword kw">end</span> +230: +231: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body</span> +232: <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file