Class PhusionPassenger::Utils::UnseekableSocket
In: lib/phusion_passenger/utils/unseekable_socket.rb
Parent: Object

Some frameworks (e.g. Merb) call `seek` and `rewind` on the input stream if it responds to these methods. In case of Phusion Passenger, the input stream is a socket, and altough socket objects respond to `seek` and `rewind`, calling these methods will raise an exception. We don‘t want this to happen so in AbstractRequestHandler we wrap the client socket into an UnseekableSocket wrapper, which doesn‘t respond to these methods.

We used to dynamically undef `seek` and `rewind` on sockets, but this blows the Ruby interpreter‘s method cache and made things slower. Wrapping a socket is faster despite extra method calls.

Furthermore, all exceptions originating from the wrapped socket will be annotated. One can check whether a certain exception originates from the wrapped socket by calling source_of_exception?

Methods

addr   binmode   close   close_read   close_write   closed?   each   eof?   fileno   flush   gets   puts   read   read_nonblock   readline   readpartial   recv   recvfrom   recvfrom_nonblock   send   sendmsg   sendmsg_nonblock   source_of_exception?   sync=   to_io   wrap   wrap   write   write_nonblock   writev   writev2   writev3  

Public Class methods

Public Instance methods

Already set to binary mode.

Socket is sync‘ed so flushing shouldn‘t do anything.

Don‘t allow disabling of sync.

This makes select() work.

[Validate]