Skip to content

Commit

Permalink
fix content length access
Browse files Browse the repository at this point in the history
  • Loading branch information
copiousfreetime committed Jul 12, 2009
1 parent 34bbd8a commit 9231100
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/http-parser/http-parser_ext.c
Expand Up @@ -339,7 +339,7 @@ VALUE hpe_parser_content_length( VALUE self )

Data_Get_Struct( self, http_parser, parser );
content_length = parser->content_length;
rc = UULL2NUM( content_length );
rc = ULL2NUM( content_length );

return rc;
}
Expand Down Expand Up @@ -500,7 +500,7 @@ void Init_http_parser_ext()
rb_define_method( cHttpParser, "chunked_encoding?" ,hpe_parser_chunked_encoding , 0 );
rb_define_method( cHttpParser, "version" ,hpe_parser_version , 0 );
rb_define_method( cHttpParser, "keep_alive?" ,hpe_parser_keep_alive , 0 );
rb_define_method( cHttpParser, "content_length?" ,hpe_parser_content_length , 0 );
rb_define_method( cHttpParser, "content_length" ,hpe_parser_content_length , 0 );
rb_define_method( cHttpParser, "reset" ,hpe_parser_reset , 0 );
rb_define_method( cHttpParser, "parse_chunk" ,hpe_parser_parse_chunk , 1 );

Expand Down
10 changes: 10 additions & 0 deletions spec/response_parser_spec.rb
Expand Up @@ -61,4 +61,14 @@
end
end
end

it "knows the content length" do
cl = nil
@parser.on_headers_complete do |p|
cl = p.content_length
end
@parser.parse_chunk( IO.read( http_res_file( "google" ) ) )
cl.should == 219
end

end

0 comments on commit 9231100

Please sign in to comment.