Class: Faraday::Adapter

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/adapter/libuv.rb

Direct Known Subclasses

Libuv

Defined Under Namespace

Classes: Libuv

Instance Method Summary collapse

Instance Method Details

#perform_request(env, opts) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/faraday/adapter/libuv.rb', line 66

def perform_request(env, opts)
  conn = ::UV::HttpEndpoint.new(env[:url].to_s, opts.merge!(@connection_options))
  resp = co conn.request(env[:method].to_s.downcase.to_sym,
    headers: env[:request_headers],
    path: "/#{env[:url].to_s.split('/', 4)[-1]}",
    keepalive: false,
    body: read_body(env))

  save_response(env, resp.status.to_i, resp.body, resp) #, resp.reason_phrase)
  nil
rescue Exception => e
  e
end