|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
* Copyright (c) 2005 Zed A. Shaw
|
|
|
|
|
* You can redistribute it and/or modify it under the same terms as Ruby.
|
|
|
|
|
*/
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "ruby.h"
|
|
|
|
|
#include "ext_help.h"
|
|
|
|
|
#include <assert.h>
|
|
|
|
@ -74,7 +75,11 @@ 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++) {
|
|
|
|
|
#ifdef HAVE_OLD_RUBY
|
|
|
|
|
for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
|
|
|
|
|
#else
|
|
|
|
|
for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) {
|
|
|
|
|
#endif
|
|
|
|
|
if(*ch == '-') {
|
|
|
|
|
*ch = '_';
|
|
|
|
|
} else {
|
|
|
|
@ -157,12 +162,25 @@ 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) {
|
|
|
|
|
colon = strchr(RSTRING(temp)->ptr, ':');
|
|
|
|
|
#ifdef HAVE_OLD_RUBY
|
|
|
|
|
colon = strchr(RSTRING(temp)->ptr, ':');
|
|
|
|
|
#else
|
|
|
|
|
colon = strchr(RSTRING_PTR(temp), ':');
|
|
|
|
|
#endif
|
|
|
|
|
if(colon != NULL) {
|
|
|
|
|
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr));
|
|
|
|
|
#ifdef HAVE_OLD_RUBY
|
|
|
|
|
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr));
|
|
|
|
|
#else
|
|
|
|
|
rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));
|
|
|
|
|
#endif
|
|
|
|
|
rb_hash_aset(req, global_server_port,
|
|
|
|
|
rb_str_substr(temp, colon - RSTRING(temp)->ptr+1,
|
|
|
|
|
RSTRING(temp)->len));
|
|
|
|
|
#ifdef HAVE_OLD_RUBY
|
|
|
|
|
rb_str_substr(temp, colon - RSTRING(temp)->ptr+1,
|
|
|
|
|
RSTRING(temp)->len));
|
|
|
|
|
#else
|
|
|
|
|
rb_str_substr(temp, colon - RSTRING_PTR(temp)+1,
|
|
|
|
|
RSTRING_LEN(temp)));
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
rb_hash_aset(req, global_server_name, temp);
|
|
|
|
|
rb_hash_aset(req, global_server_port, global_port_80);
|
|
|
|
@ -281,8 +299,13 @@ 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;
|
|
|
|
|
#ifdef HAVE_OLD_RUBY
|
|
|
|
|
dptr = RSTRING(data)->ptr;
|
|
|
|
|
dlen = RSTRING(data)->len;
|
|
|
|
|
#else
|
|
|
|
|
dptr = RSTRING_PTR(data);
|
|
|
|
|
dlen = RSTRING_LEN(data);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if(from >= dlen) {
|
|
|
|
|
rb_raise(eHttpParserError, "Requested start is after data buffer end.");
|
|
|
|
@ -512,7 +535,11 @@ VALUE URIClassifier_resolve(VALUE self, VALUE uri)
|
|
|
|
|
if(pref_len == 1 && uri_str[0] == '/') {
|
|
|
|
|
rb_ary_push(result, uri);
|
|
|
|
|
} else {
|
|
|
|
|
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len));
|
|
|
|
|
#ifdef HAVE_OLD_RUBY
|
|
|
|
|
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len));
|
|
|
|
|
#else
|
|
|
|
|
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING_LEN(uri)));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rb_ary_push(result, (VALUE)handler);
|
|
|
|
|