faraday

Omniauth + Google + Faraday + Behind the proxy = how setup proxy?

社会主义新天地 提交于 2019-12-06 05:28:01
My production server is Ubuntu 12 . I'm using Devise + OmniAuth to handle the Google authentication. But when Google returns a control to my application I get an error "Network is unreachable" . I assume it's because of server is behind the proxy. Here's error description: ------------------------------- Request: ------------------------------- * URL : http://efiling.uipv.org/users/auth/google_oauth2/callback?state=f4eaca9fbed2a77c0baac50cdbdccab7eee671179bb8fc43&code=4/YRcyYZzkrfNh8mEBbenxaxyx5EjN.4snirEA-93MXOl05ti8ZT3a9mXdIcgI * IP address: 213.160.144.239 * Parameters: {"state"=>

What is the Ruby equivalent to this curl request?

笑着哭i 提交于 2019-12-03 16:25:46
I'm tring to post to an api. This example from the docs works in curl: curl -k -w %{http_code} -H "Content-Type:text/plain" -u user:pass --data-binary @filename https://server/url/here This is what I have tried with faraday: require 'rubygems' require 'faraday' require 'pp' conn = Faraday.new(:url => 'https://server/url/here' , :ssl => {:verify => false} ) do |faraday| faraday.response :logger faraday.basic_auth('user', 'pass') faraday.adapter Faraday.default_adapter end data = File.read('teste.txt') res=conn.post '/' , data pp res It posts, I receive a 200 code but something goes wrong. The

How do I debug HTTP of Ruby google-api-client

一曲冷凌霜 提交于 2019-11-29 15:22:41
I'm trying to integrate with Google Drive, using the google-api-client. Since there's a lot of stuff going on, I would like to be able to see what's going over the wire (http level). It seems that the client uses Faraday for http connectivity. How would I get a wiredump out of Faraday for debugging? Google api client uses Faraday.default_connection by default. It is thus possible to manipulate this object, which can be done simply with the following line of code: Faraday.default_connection.response :logger Took me a while to figure out. 来源: https://stackoverflow.com/questions/13900195/how-do-i

Upload files using Faraday

核能气质少年 提交于 2019-11-29 07:43:44
I'm having issues attempting to upload a file to a web service using Faraday. My code: conn = Faraday.new('http://myapi') do |f| f.request :multipart end payload = { :file => Faraday::UploadIO.new('...', 'image/jpeg') } conn.post('/', payload) Nothing seems to happen after attempting the post. When I inspect the response this is what I'm seeing: #<Faraday::Response:0x007fd9e5903870 @env={:method=>:post, :body=>#<Faraday::CompositeReadIO:0x007fd9e5903a50 @parts=[#<Parts::FilePart:0x007fd9e5903e38 @head="-------------RubyMultipartPost\r\nContent-Disposition: form-data; name=\"file\"; filename=\

Upload files using Faraday

*爱你&永不变心* 提交于 2019-11-28 01:16:24
问题 I'm having issues attempting to upload a file to a web service using Faraday. My code: conn = Faraday.new('http://myapi') do |f| f.request :multipart end payload = { :file => Faraday::UploadIO.new('...', 'image/jpeg') } conn.post('/', payload) Nothing seems to happen after attempting the post. When I inspect the response this is what I'm seeing: #<Faraday::Response:0x007fd9e5903870 @env={:method=>:post, :body=>#<Faraday::CompositeReadIO:0x007fd9e5903a50 @parts=[#<Parts::FilePart