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?