-
-
Save tmm1/1971394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/ruby_http_parser/ruby_http_parser.c b/ext/ruby_http_parser/ruby_http_parser.c | |
index 119d7e1..5650652 100644 | |
--- a/ext/ruby_http_parser/ruby_http_parser.c | |
+++ b/ext/ruby_http_parser/ruby_http_parser.c | |
@@ -320,6 +320,9 @@ VALUE Parser_execute(VALUE self, VALUE data) { | |
size_t nparsed = ryah_http_parser_execute(&wrapper->parser, &settings, ptr, len); | |
if (wrapper->parser.upgrade) { | |
+ if (RTEST(wrapper->stopped)) | |
+ nparsed += 1; | |
+ | |
rb_str_cat(wrapper->upgrade_data, ptr + nparsed, len - nparsed); | |
} else if (nparsed != (size_t)len) { | |
diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb | |
index 80369dd..d863060 100644 | |
--- a/spec/parser_spec.rb | |
+++ b/spec/parser_spec.rb | |
@@ -281,6 +281,8 @@ describe HTTP::Parser do | |
@parser.on_headers_complete = proc { |e| :stop } | |
offset = (@parser << request) | |
+ @parser.upgrade?.should be_true | |
+ @parser.upgrade_data.should == '' | |
offset.should == request.length | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment