|
Lines 2-7
Link Here
|
| 2 |
* Copyright (c) 2005 Zed A. Shaw |
2 |
* Copyright (c) 2005 Zed A. Shaw |
| 3 |
* You can redistribute it and/or modify it under the same terms as Ruby. |
3 |
* You can redistribute it and/or modify it under the same terms as Ruby. |
| 4 |
*/ |
4 |
*/ |
|
|
5 |
#include "config.h" |
| 5 |
#include "ruby.h" |
6 |
#include "ruby.h" |
| 6 |
#include "ext_help.h" |
7 |
#include "ext_help.h" |
| 7 |
#include <assert.h> |
8 |
#include <assert.h> |
|
Lines 74-80
Link Here
|
| 74 |
f = rb_str_dup(global_http_prefix); |
75 |
f = rb_str_dup(global_http_prefix); |
| 75 |
f = rb_str_buf_cat(f, field, flen); |
76 |
f = rb_str_buf_cat(f, field, flen); |
| 76 |
|
77 |
|
|
|
78 |
#ifdef HAVE_OLD_RUBY |
| 77 |
for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) { |
79 |
for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) { |
|
|
80 |
#else |
| 81 |
for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) { |
| 82 |
#endif |
| 78 |
if(*ch == '-') { |
83 |
if(*ch == '-') { |
| 79 |
*ch = '_'; |
84 |
*ch = '_'; |
| 80 |
} else { |
85 |
} else { |
|
Lines 157-168
Link Here
|
| 157 |
|
162 |
|
| 158 |
rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value); |
163 |
rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value); |
| 159 |
if((temp = rb_hash_aref(req, global_http_host)) != Qnil) { |
164 |
if((temp = rb_hash_aref(req, global_http_host)) != Qnil) { |
|
|
165 |
#ifdef HAVE_OLD_RUBY |
| 160 |
colon = strchr(RSTRING(temp)->ptr, ':'); |
166 |
colon = strchr(RSTRING(temp)->ptr, ':'); |
|
|
167 |
#else |
| 168 |
colon = strchr(RSTRING_PTR(temp), ':'); |
| 169 |
#endif |
| 161 |
if(colon != NULL) { |
170 |
if(colon != NULL) { |
|
|
171 |
#ifdef HAVE_OLD_RUBY |
| 162 |
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr)); |
172 |
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr)); |
|
|
173 |
#else |
| 174 |
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp))); |
| 175 |
#endif |
| 163 |
rb_hash_aset(req, global_server_port, |
176 |
rb_hash_aset(req, global_server_port, |
|
|
177 |
#ifdef HAVE_OLD_RUBY |
| 164 |
rb_str_substr(temp, colon - RSTRING(temp)->ptr+1, |
178 |
rb_str_substr(temp, colon - RSTRING(temp)->ptr+1, |
| 165 |
RSTRING(temp)->len)); |
179 |
RSTRING(temp)->len)); |
|
|
180 |
#else |
| 181 |
rb_str_substr(temp, colon - RSTRING_PTR(temp)+1, |
| 182 |
RSTRING_LEN(temp))); |
| 183 |
#endif |
| 166 |
} else { |
184 |
} else { |
| 167 |
rb_hash_aset(req, global_server_name, temp); |
185 |
rb_hash_aset(req, global_server_name, temp); |
| 168 |
rb_hash_aset(req, global_server_port, global_port_80); |
186 |
rb_hash_aset(req, global_server_port, global_port_80); |
|
Lines 281-288
Link Here
|
| 281 |
DATA_GET(self, http_parser, http); |
299 |
DATA_GET(self, http_parser, http); |
| 282 |
|
300 |
|
| 283 |
from = FIX2INT(start); |
301 |
from = FIX2INT(start); |
|
|
302 |
#ifdef HAVE_OLD_RUBY |
| 284 |
dptr = RSTRING(data)->ptr; |
303 |
dptr = RSTRING(data)->ptr; |
| 285 |
dlen = RSTRING(data)->len; |
304 |
dlen = RSTRING(data)->len; |
|
|
305 |
#else |
| 306 |
dptr = RSTRING_PTR(data); |
| 307 |
dlen = RSTRING_LEN(data); |
| 308 |
#endif |
| 286 |
|
309 |
|
| 287 |
if(from >= dlen) { |
310 |
if(from >= dlen) { |
| 288 |
rb_raise(eHttpParserError, "Requested start is after data buffer end."); |
311 |
rb_raise(eHttpParserError, "Requested start is after data buffer end."); |
|
Lines 512-518
Link Here
|
| 512 |
if(pref_len == 1 && uri_str[0] == '/') { |
535 |
if(pref_len == 1 && uri_str[0] == '/') { |
| 513 |
rb_ary_push(result, uri); |
536 |
rb_ary_push(result, uri); |
| 514 |
} else { |
537 |
} else { |
|
|
538 |
#ifdef HAVE_OLD_RUBY |
| 515 |
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len)); |
539 |
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len)); |
|
|
540 |
#else |
| 541 |
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING_LEN(uri))); |
| 542 |
#endif |
| 516 |
} |
543 |
} |
| 517 |
|
544 |
|
| 518 |
rb_ary_push(result, (VALUE)handler); |
545 |
rb_ary_push(result, (VALUE)handler); |