Skip to content

Commit

Permalink
handling reset in on_headers_complete
Browse files Browse the repository at this point in the history
  • Loading branch information
spariev committed Apr 20, 2012
1 parent d69dac9 commit 2e11192
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ext/ruby_http_parser/org/ruby_http_parser/RubyHttpParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import http_parser.*;
import http_parser.lolevel.ParserSettings;
import http_parser.lolevel.HTTPCallback;
import http_parser.lolevel.HTTPHeadersCompleteCallback;
import http_parser.lolevel.HTTPDataCallback;

public class RubyHttpParser extends RubyObject {
Expand Down Expand Up @@ -127,6 +128,7 @@ public int cb (http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int le
final RubySymbol arraysSym = runtime.newSymbol("arrays");
final RubySymbol mixedSym = runtime.newSymbol("mixed");
final RubySymbol stopSym = runtime.newSymbol("stop");
final RubySymbol resetSym = runtime.newSymbol("reset");
this.settings.on_header_value = new HTTPDataCallback() {
public int cb (http_parser.lolevel.HTTPParser p, ByteBuffer buf, int pos, int len) {
byte[] data = fetchBytes(buf, pos, len);
Expand Down Expand Up @@ -227,7 +229,7 @@ public int cb (http_parser.lolevel.HTTPParser p) {
}
}
};
this.settings.on_headers_complete = new HTTPCallback() {
this.settings.on_headers_complete = new HTTPHeadersCompleteCallback() {
public int cb (http_parser.lolevel.HTTPParser p) {
IRubyObject ret = runtime.getNil();

Expand All @@ -243,7 +245,9 @@ public int cb (http_parser.lolevel.HTTPParser p) {

if (ret == stopSym) {
throw new StopException();
} else {
} else if (ret == resetSym) {
return 1;
}else {
return 0;
}
}
Expand Down

0 comments on commit 2e11192

Please sign in to comment.