Sha256: 6ddc11eb52a6e8ac599978e4bb53c6dd4deec01934c534cdc687f7a88e1980cc

Contents?: true

Size: 637 Bytes

Versions: 1

Compression:

Stored size: 637 Bytes

Contents

require 'net/http/persistent'
require 'rest-core/engine'

class RestCore::NetHttpPersistent < RestCore::Engine
  def request promise, env
    http = ::Net::HTTP::Persistent.new
    http.open_timeout, http.read_timeout = calculate_timeout(env[TIMER])
    payload, headers = payload_and_headers(env)

    uri = ::URI.parse(request_uri(env))
    req = ::Net::HTTP.const_get(env[REQUEST_METHOD].to_s.capitalize).
            new(uri, headers)
    req.body_stream = payload
    res = http.request(uri, req)

    promise.fulfill(res.body, res.code.to_i, normalize_headers(res.to_hash))
  rescue Exception => e
    promise.reject(e)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest-core-3.0.0 lib/rest-core/engine/net-http-persistent.rb