Skip to content

Commit

Permalink
Fix parser to be Ruby 1.9 compatible [Aman Gupta]
Browse files Browse the repository at this point in the history
  • Loading branch information
macournoyer committed Jan 5, 2008
1 parent 8478ecb commit dbfb071
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
== 0.5.1
* Fix parser to be Ruby 1.9 compatible [Aman Gupta]
* Set gemspec to use EventMachine version 0.8.1 as it's the latest one having precompiled windows binaries.
Recommended by Francis Cianfrocca.
[Francis Cianfrocca].
* Add -D option to thin script to set debugging on.
* Output incoming data and response when debugging is on.

Expand Down
14 changes: 7 additions & 7 deletions ext/thin_parser/thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s
f = rb_str_dup(global_http_prefix);
f = rb_str_buf_cat(f, field, flen);

for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) {
if(*ch == '-') {
*ch = '_';
} else {
Expand Down Expand Up @@ -176,12 +176,12 @@ void header_done(void *data, const char *at, size_t length)
rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
if((temp = rb_hash_aref(req, global_http_host)) != Qnil) {
/* ruby better close strings off with a '\0' dammit */
colon = strchr(RSTRING(temp)->ptr, ':');
colon = strchr(RSTRING_PTR(temp), ':');
if(colon != NULL) {
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr));
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));
rb_hash_aset(req, global_server_port,
rb_str_substr(temp, colon - RSTRING(temp)->ptr+1,
RSTRING(temp)->len));
rb_str_substr(temp, colon - RSTRING_PTR(temp)+1,
RSTRING_LEN(temp)));
} else {
rb_hash_aset(req, global_server_name, temp);
rb_hash_aset(req, global_server_port, global_port_80);
Expand Down Expand Up @@ -313,8 +313,8 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
DATA_GET(self, http_parser, http);

from = FIX2INT(start);
dptr = RSTRING(data)->ptr;
dlen = RSTRING(data)->len;
dptr = RSTRING_PTR(data);
dlen = RSTRING_LEN(data);

if(from >= dlen) {
rb_raise(eHttpParserError, "Requested start is after data buffer end.");
Expand Down

0 comments on commit dbfb071

Please sign in to comment.