lib/nestful/connection.rb
# Makes a request to the remote service.
Makes a request to the remote service.
Makes a request to the remote service .
def request(method, path, *arguments)
        body    = nil
        body    = arguments.shift if [:put, :post].include?(method)
        headers = arguments.shift || {}
        method = Net::HTTP.const_get(method.to_s.capitalize)
        method = method.new(path)
        if body
          if body.respond_to?(:read)
            method.body_stream = body
          else
            method.body = body
          end
          if body.respond_to?(:size)
            headers['Content-Length'] ||= body.size
          end
        end
        headers.each {|name, value|
          next unless value
          method.add_field(name, value)
        }
        http.start do |stream|
          stream.request(method) {|rsp|
            handle_response(rsp)
            yield(rsp) if block_given?
            rsp
          }
        end
      rescue Timeout::Error => e
        raise TimeoutError.new(e.message)
      rescue OpenSSL::SSL::SSLError => e
        raise SSLError.new(e.message)
      end
def request ( method , path , * arguments ) body = nil body = arguments . shift if [ :put , :post ] . include? ( method ) headers = arguments . shift || { } method = Net :: HTTP . const_get ( method . to_s . capitalize ) method = method . new ( path ) if body if body . respond_to? ( :read ) method . body_stream = body else method . body = body end if body . respond_to? ( :size ) headers [ 'Content-Length' ] ||= body . size end end headers . each { | name , value | next unless value method . add_field ( name , value ) } http . start do | stream | stream . request ( method ) { | rsp | handle_response ( rsp ) yield ( rsp ) if block_given? rsp } end rescue Timeout :: Error => e raise TimeoutError . new ( e . message ) rescue OpenSSL :: SSL :: SSLError => e raise SSLError . new ( e . message ) end
Makes a request to the remote service.
Makes a request to the remote service .
method
<not_specific>
path
<not_specific>
arguments
<not_specific>