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

- old
+ new

@@ -8,42 +8,42 @@ <title>read_chunked_encoding (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 281</span> -281: <span class="ruby-keyword kw">def</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>) -282: <span class="ruby-identifier">out</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span> -283: <span class="ruby-identifier">input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>) -284: -285: <span class="ruby-comment cmt"># read from the http body first, then continue at the socket</span> -286: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">read_chunks</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">parser</span>) -287: -288: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">status</span> -289: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:incomplete_trailer</span> -290: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> -291: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">2</span>) -292: <span class="ruby-keyword kw">else</span> -293: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>) -294: <span class="ruby-keyword kw">end</span> -295: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:incomplete_body</span> -296: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">result</span>)) <span class="ruby-comment cmt"># read the remaining</span> -297: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">2</span>) -298: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:incomplete_header</span> -299: <span class="ruby-comment cmt"># push what we read back onto the socket, but backwards</span> -300: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">reverse!</span> -301: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">each_byte</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">ungetc</span>(<span class="ruby-identifier">b</span>) } -302: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:finished</span> -303: <span class="ruby-comment cmt"># all done, get out</span> -304: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>; <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">read</span> -305: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:eof_error</span> -306: <span class="ruby-comment cmt"># read everything we could, ignore</span> -307: <span class="ruby-keyword kw">end</span> -308: -309: <span class="ruby-comment cmt"># then continue reading them from the socket</span> -310: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">read_chunks</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">parser</span>) -311: -312: <span class="ruby-comment cmt"># and now the http_body is the chunk</span> -313: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>; <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">read</span> -314: <span class="ruby-keyword kw">end</span></pre> + <pre> <span class="ruby-comment cmt"># File lib/rfuzz/client.rb, line 286</span> +286: <span class="ruby-keyword kw">def</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>) +287: <span class="ruby-identifier">out</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span> +288: <span class="ruby-identifier">input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">http_body</span>) +289: +290: <span class="ruby-comment cmt"># read from the http body first, then continue at the socket</span> +291: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">read_chunks</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">parser</span>) +292: +293: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">status</span> +294: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:incomplete_trailer</span> +295: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> +296: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">2</span>) +297: <span class="ruby-keyword kw">else</span> +298: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>((<span class="ruby-identifier">result</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>).<span class="ruby-identifier">abs</span>) +299: <span class="ruby-keyword kw">end</span> +300: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:incomplete_body</span> +301: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">result</span>)) <span class="ruby-comment cmt"># read the remaining</span> +302: <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">2</span>) +303: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:incomplete_header</span> +304: <span class="ruby-comment cmt"># push what we read back onto the socket, but backwards</span> +305: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">reverse!</span> +306: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">each_byte</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sock</span>.<span class="ruby-identifier">ungetc</span>(<span class="ruby-identifier">b</span>) } +307: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:finished</span> +308: <span class="ruby-comment cmt"># all done, get out</span> +309: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>; <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">read</span> +310: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:eof_error</span> +311: <span class="ruby-comment cmt"># read everything we could, ignore</span> +312: <span class="ruby-keyword kw">end</span> +313: +314: <span class="ruby-comment cmt"># then continue reading them from the socket</span> +315: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">result</span> = <span class="ruby-identifier">read_chunks</span>(<span class="ruby-identifier">sock</span>, <span class="ruby-identifier">out</span>, <span class="ruby-identifier">parser</span>) +316: +317: <span class="ruby-comment cmt"># and now the http_body is the chunk</span> +318: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>; <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">read</span> +319: <span class="ruby-keyword kw">end</span></pre> </body> </html> \ No newline at end of file