Class: RestCore::NetHttpPersistent
- Defined in:
- lib/rest-core/engine/net-http-persistent.rb
Constant Summary
Constants included from Middleware
Constants included from RestCore
ASYNC, CLIENT, DRY, FAIL, HIJACK, LOG, PROMISE, REQUEST_HEADERS, REQUEST_METHOD, REQUEST_PATH, REQUEST_PAYLOAD, REQUEST_QUERY, RESPONSE_BODY, RESPONSE_HEADERS, RESPONSE_SOCKET, RESPONSE_STATUS, Simple, TIMER, Universal, VERSION
Instance Method Summary collapse
Methods inherited from Engine
Methods included from Middleware
#call, #contain_binary?, contain_binary?, #escape, escape, #fail, #id, included, #log, percent_encode, #percent_encode, #request_uri, request_uri, #run, #string_keys, string_keys
Methods included from RestCore
Instance Method Details
#request(promise, env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rest-core/engine/net-http-persistent.rb', line 6 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 |