Class: RestCore::RestClient
- Defined in:
- lib/rest-core/engine/rest-client.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
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rest-core/engine/rest-client.rb', line 7 def request promise, env open_timeout, read_timeout = calculate_timeout(env[TIMER]) payload, headers = payload_and_headers(env) res = ::RestClient::Request.execute(:method => env[REQUEST_METHOD], :url => request_uri(env) , :payload => payload , :headers => headers , :max_redirects => 0 , :open_timeout => open_timeout , :timeout => read_timeout ) promise.fulfill(res.body, res.code, normalize_headers(res.raw_headers)) rescue ::RestClient::Exception => e if res = e.response # we don't want to raise an exception for 404 requests promise.fulfill(res.body, res.code, normalize_headers(res.raw_headers)) else promise.reject(e) end rescue Exception => e promise.reject(e) end |