diff --git a/ext/passenger/native_support.c b/ext/passenger/native_support.c index 52e0c29685..55fea2fa86 100644 --- a/ext/passenger/native_support.c +++ b/ext/passenger/native_support.c @@ -34,6 +34,12 @@ #ifndef RARRAY_LEN #define RARRAY_LEN(ary) RARRAY(ary)->len #endif +#ifndef RSTRING_PTR + #define RSTRING_PTR(str) RSTRING(str)->ptr +#endif +#ifndef RSTRING_LEN + #define RSTRING_LEN(str) RSTRING(str)->len +#endif static VALUE mPassenger; static VALUE mNativeSupport; @@ -178,7 +184,8 @@ create_unix_socket(VALUE self, VALUE filename, VALUE backlog) { char *filename_str; long filename_length; - filename_str = rb_str2cstr(filename, &filename_length); + filename_str = RSTRING_PTR(filename); + filename_length = RSTRING_LEN(filename); fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd == -1) { diff --git a/lib/passenger/rack/request_handler.rb b/lib/passenger/rack/request_handler.rb index e718aea74d..abe742a918 100644 --- a/lib/passenger/rack/request_handler.rb +++ b/lib/passenger/rack/request_handler.rb @@ -66,13 +66,13 @@ def process_request(env, input, output) begin output.write("Status: #{status}#{CRLF}") headers[X_POWERED_BY] = PASSENGER_HEADER - headers.each do |k, vs| - vs.each do |v| - output.write("#{k}: #{v}#{CRLF}") - end + headers.each_pair do |k, v| + output.write("#{k}: #{v}#{CRLF}") end output.write(CRLF) - if body + if body.is_a?(String) + output.write(body) + elsif body body.each do |s| output.write(s) end diff --git a/lib/passenger/utils.rb b/lib/passenger/utils.rb index 01514037ee..b9deb5948a 100644 --- a/lib/passenger/utils.rb +++ b/lib/passenger/utils.rb @@ -18,7 +18,7 @@ require 'rubygems' require 'thread' -if RUBY_PLATFORM != "java" && RUBY_VERSION < "1.8.7" +if (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") && RUBY_VERSION < "1.8.7" require 'fastthread' end require 'pathname' @@ -26,7 +26,7 @@ require 'fcntl' require 'tempfile' require 'passenger/exceptions' -if RUBY_PLATFORM != "java" +if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" require 'passenger/native_support' end