doc/rdoc/classes/RFuzz/HttpClient.src/M000014.html in rfuzz-0.6 vs doc/rdoc/classes/RFuzz/HttpClient.src/M000014.html in rfuzz-0.7

- old
+ new

@@ -8,50 +8,50 @@ <title>read_response (RFuzz::HttpClient)</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/rfuzz/client.rb, line 323</span> -323: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_response</span>(<span class="ruby-identifier">sock</span>) -324: <span class="ruby-identifier">data</span>, <span class="ruby-identifier">resp</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-keyword kw">nil</span> -325: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpClientParser</span>.<span class="ruby-identifier">new</span> -326: <span class="ruby-identifier">resp</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span> -327: -328: <span class="ruby-identifier">notify</span> <span class="ruby-identifier">:read_header</span> <span class="ruby-keyword kw">do</span> -329: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-value">1024</span>) -330: <span class="ruby-identifier">nread</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span>, <span class="ruby-value">0</span>) -331: -332: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span> -333: <span class="ruby-identifier">data</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-value">1024</span>) -334: <span class="ruby-identifier">nread</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">nread</span>) -335: <span class="ruby-keyword kw">end</span> -336: <span class="ruby-keyword kw">end</span> -337: -338: <span class="ruby-identifier">notify</span> <span class="ruby-identifier">:read_body</span> <span class="ruby-keyword kw">do</span> -339: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">TRANSFER_ENCODING</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">TRANSFER_ENCODING</span>].<span class="ruby-identifier">index</span>(<span class="ruby-value str">&quot;chunked&quot;</span>) -340: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span> = <span class="ruby-identifier">read_chunked_encoding</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">parser</span>) -341: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">CONTENT_LENGTH</span>] -342: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-constant">CONTENT_LENGTH</span>].<span class="ruby-identifier">to_i</span> -343: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cl</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> -344: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">cl</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span>) -345: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cl</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span> -346: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Web site sucks, they said Content-Length: #{cl}, but sent a longer body length: #{resp.http_body.length}&quot;</span> -347: <span class="ruby-keyword kw">end</span> -348: <span class="ruby-keyword kw">else</span> -349: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span> -350: <span class="ruby-keyword kw">end</span> -351: <span class="ruby-keyword kw">end</span> -352: -353: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">SET_COOKIE</span>] -354: <span class="ruby-identifier">cookies</span> = <span class="ruby-identifier">query_parse</span>(<span class="ruby-identifier">resp</span>[<span class="ruby-constant">SET_COOKIE</span>], <span class="ruby-value str">';,'</span>) -355: <span class="ruby-ivar">@cookies</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">cookies</span> -356: <span class="ruby-ivar">@cookies</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;path&quot;</span> -357: <span class="ruby-keyword kw">end</span> -358: -359: <span class="ruby-identifier">notify</span> <span class="ruby-identifier">:close</span> <span class="ruby-keyword kw">do</span> -360: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">close</span> -361: <span class="ruby-keyword kw">end</span> -362: -363: <span class="ruby-identifier">resp</span> -364: <span class="ruby-keyword kw">end</span></pre> + <pre> <span class="ruby-comment cmt"># File lib/rfuzz/client.rb, line 328</span> +328: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_response</span>(<span class="ruby-identifier">sock</span>) +329: <span class="ruby-identifier">data</span>, <span class="ruby-identifier">resp</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-keyword kw">nil</span> +330: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpClientParser</span>.<span class="ruby-identifier">new</span> +331: <span class="ruby-identifier">resp</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span> +332: +333: <span class="ruby-identifier">notify</span> <span class="ruby-identifier">:read_header</span> <span class="ruby-keyword kw">do</span> +334: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-value">1024</span>) +335: <span class="ruby-identifier">nread</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span>, <span class="ruby-value">0</span>) +336: +337: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span> +338: <span class="ruby-identifier">data</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-value">1024</span>) +339: <span class="ruby-identifier">nread</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">nread</span>) +340: <span class="ruby-keyword kw">end</span> +341: <span class="ruby-keyword kw">end</span> +342: +343: <span class="ruby-identifier">notify</span> <span class="ruby-identifier">:read_body</span> <span class="ruby-keyword kw">do</span> +344: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">TRANSFER_ENCODING</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">TRANSFER_ENCODING</span>].<span class="ruby-identifier">index</span>(<span class="ruby-value str">&quot;chunked&quot;</span>) +345: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span> = <span class="ruby-identifier">read_chunked_encoding</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-identifier">sock</span>, <span class="ruby-identifier">parser</span>) +346: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">CONTENT_LENGTH</span>] +347: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-constant">CONTENT_LENGTH</span>].<span class="ruby-identifier">to_i</span> +348: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cl</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> +349: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">cl</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span>) +350: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cl</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>.<span class="ruby-identifier">length</span> +351: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Web site sucks, they said Content-Length: #{cl}, but sent a longer body length: #{resp.http_body.length}&quot;</span> +352: <span class="ruby-keyword kw">end</span> +353: <span class="ruby-keyword kw">else</span> +354: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span> +355: <span class="ruby-keyword kw">end</span> +356: <span class="ruby-keyword kw">end</span> +357: +358: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>[<span class="ruby-constant">SET_COOKIE</span>] +359: <span class="ruby-identifier">cookies</span> = <span class="ruby-identifier">query_parse</span>(<span class="ruby-identifier">resp</span>[<span class="ruby-constant">SET_COOKIE</span>], <span class="ruby-value str">';,'</span>) +360: <span class="ruby-ivar">@cookies</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">cookies</span> +361: <span class="ruby-ivar">@cookies</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;path&quot;</span> +362: <span class="ruby-keyword kw">end</span> +363: +364: <span class="ruby-identifier">notify</span> <span class="ruby-identifier">:close</span> <span class="ruby-keyword kw">do</span> +365: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">close</span> +366: <span class="ruby-keyword kw">end</span> +367: +368: <span class="ruby-identifier">resp</span> +369: <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file