Module: RestClient

Defined in:
lib/couchrest/monkeypatches.rb

Overview

# Monkey patch for faster net/http io if RUBY_VERSION.to_f < 1.9

class Net::BufferedIO #:nodoc:
  alias :old_rbuf_fill :rbuf_fill
  def rbuf_fill
    if @io.respond_to?(:read_nonblock)
      begin
        @rbuf << @io.read_nonblock(65536)
      rescue Errno::EWOULDBLOCK
        if IO.select([@io], nil, nil, @read_timeout)
          retry
        else
          raise Timeout::TimeoutError
        end
      end
    else
      timeout(@read_timeout) do
        @rbuf << @io.sysread(65536)
      end
    end
  end
end

end

Class Method Summary collapse

Class Method Details

.copy(url, headers = {}) ⇒ Object



54
55
56
57
58
# File 'lib/couchrest/monkeypatches.rb', line 54

def self.copy(url, headers={})
  Request.execute(:method => :copy,
    :url => url,
    :headers => headers)
end

.move(url, headers = {}) ⇒ Object



60
61
62
63
64
# File 'lib/couchrest/monkeypatches.rb', line 60

def self.move(url, headers={})
  Request.execute(:method => :move,
  :url => url,
  :headers => headers)
end