Permalink
Browse files

Checking that the FCGI::Stream class exists, before trying to overrid…

…e the read method. The FCGI::Stream class does not exist in the pure ruby version of the FCGI module. FCGI will use pure ruby if:

1. FCGI_PURE_RUBY = true
2. The C version of FCGI doesn't load (lib not found or the like)

Signed-off-by: Christian Neukirchen <chneukirchen@gmail.com>
  • Loading branch information...
1 parent 503130e commit 38f205e975d3e540cc81a71a639f4bebc3c2a293 @dmann dmann committed with chneukirchen Aug 11, 2009
Showing with 8 additions and 6 deletions.
  1. +8 −6 lib/rack/handler/fastcgi.rb
@@ -3,13 +3,15 @@
require 'rack/content_length'
require 'rack/rewindable_input'
-class FCGI::Stream
- alias _rack_read_without_buffer read
+if defined? FCGI::Stream
+ class FCGI::Stream
+ alias _rack_read_without_buffer read
- def read(n, buffer=nil)
- buf = _rack_read_without_buffer n
- buffer.replace(buf.to_s) if buffer
- buf
+ def read(n, buffer=nil)
+ buf = _rack_read_without_buffer n
+ buffer.replace(buf.to_s) if buffer
+ buf
+ end
end
end

0 comments on commit 38f205e

Please sign in to comment.