lostisland / faraday Goto Github PK
View Code? Open in Web Editor NEWSimple, but flexible HTTP client library, with support for multiple backends.
Home Page: https://lostisland.github.io/faraday
License: MIT License
Simple, but flexible HTTP client library, with support for multiple backends.
Home Page: https://lostisland.github.io/faraday
License: MIT License
I'd love to add this line:
arg = ENV['http_proxy'] if arg.nil?
to connection.rb:146 so you could transparently support the http_proxy environment variable.
Problem: I'm dammed if I know how to test environment variables?!
Dunc
Replication is quite simple. I have come up with a narrowed step-by-step procedure:
The issue could be with the way the Twitter gem uses the Faraday gem which somewhat uses /net/http.rb
I am using:
Using Rails 3.0.3
Using twitter (1.1.2) from http://github.com/jnunemaker/twitter.git (at master)
Using faraday (0.5.4)
Using faraday_middleware (0.3.2)
Ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
I get the following error:
/Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677: [BUG] Segmentation fault ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
-- control frame ---------- c:0098 p:---- s:0522 b:0522 l:000521 d:000521 CFUNC :connect
c:0097 p:0440 s:0519 b:0519 l:001108 d:001108 METHOD /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677
c:0096 p:0011 s:0512 b:0512 l:000511 d:000511 METHOD /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:637
c:0095 p:0048 s:0509 b:0509 l:000508 d:000508 METHOD /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:626
c:0094 p:0025 s:0506 b:0506 l:000505 d:000505 METHOD /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:1160
c:0093 p:0504 s:0499 b:0499 l:000498 d:000498 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/adapter/net_http.rb:45
c:0092 p:0053 s:0487 b:0487 l:000486 d:000486 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/faraday/multipart.rb:16
c:0091 p:0041 s:0483 b:0483 l:000482 d:000482 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/request.rb:84
c:0090 p:0044 s:0476 b:0476 l:000475 d:000475 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/request.rb:26
c:0089 p:0065 s:0470 b:0470 l:000469 d:000469 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/connection.rb:169
c:0088 p:0026 s:0463 b:0463 l:000462 d:000462 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/connection.rb:64
c:0087 p:0021 s:0457 b:0457 l:002550 d:002550 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/twitter/request.rb:28
c:0086 p:0027 s:0449 b:0449 l:000448 d:000448 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/twitter/request.rb:6
c:0085 p:0084 s:0443 b:0443 l:000442 d:000442 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/twitter/client/user.rb:90
c:0084 p:0013 s:0435 b:0435 l:000413 d:000434 BLOCK /Users/Chris/Sites/site_name/app/controllers/pages_controller.rb:63
c:0083 p:0005 s:0433 b:0433 l:000422 d:000432 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache.rb:297
c:0082 p:0114 s:0430 b:0430 l:000429 d:000429 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache.rb:519
c:0081 p:0268 s:0423 b:0423 l:000422 d:000422 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache.rb:296
c:0080 p:0291 s:0414 b:0414 l:000413 d:000413 METHOD /Users/Chris/Sites/site_name/app/controllers/pages_controller.rb:63
c:0079 p:0012 s:0407 b:0407 l:000406 d:000406 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/implicit_render.rb:4
c:0078 p:0015 s:0402 b:0402 l:000401 d:000401 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151
c:0077 p:0041 s:0397 b:0397 l:000396 d:000396 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/rendering.rb:11
c:0076 p:0010 s:0393 b:0393 l:001970 d:000392 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:18
c:0075 p:0153 s:0391 b:0391 l:000390 d:000390 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:450
c:0074 p:0113 s:0385 b:0385 l:000384 d:000384 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:409
c:0073 p:0024 s:0376 b:0376 l:000375 d:000375 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93
c:0072 p:0015 s:0370 b:0370 l:001970 d:001970 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:17
c:0071 p:0012 s:0366 b:0366 l:000347 d:000365 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:30
c:0070 p:0017 s:0362 b:0362 l:000352 d:000361 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52
c:0069 p:0032 s:0360 b:0360 l:000359 d:000359 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21
c:0068 p:0036 s:0353 b:0353 l:000352 d:000352 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52
c:0067 p:0152 s:0348 b:0348 l:000347 d:000347 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:29
c:0066 p:0012 s:0342 b:0342 l:000341 d:000341 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/rescue.rb:17
c:0065 p:0093 s:0337 b:0337 l:000336 d:000336 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:120
c:0064 p:0084 s:0331 b:0331 l:000330 d:000330 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:40
c:0063 p:0048 s:0326 b:0326 l:000325 d:000325 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal.rb:138
c:0062 p:0086 s:0321 b:0321 l:000320 d:000320 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/rack_delegation.rb:14
c:0061 p:0030 s:0315 b:0315 l:0020a8 d:000314 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal.rb:178
c:0060 p:---- s:0312 b:0312 l:000311 d:000311 FINISH
c:0059 p:---- s:0310 b:0310 l:000309 d:000309 CFUNC :call
c:0058 p:0022 s:0306 b:0306 l:000305 d:000305 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62
c:0057 p:0094 s:0300 b:0300 l:000299 d:000299 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:27
c:0056 p:0097 s:0294 b:0294 l:000266 d:000293 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:148
c:0055 p:0014 s:0288 b:0288 l:000272 d:000287 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:93
c:0054 p:0142 s:0283 b:0283 l:000282 d:000282 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:68
c:0053 p:0198 s:0273 b:0273 l:000272 d:000272 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:92
c:0052 p:0092 s:0267 b:0267 l:000266 d:000266 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:139
c:0051 p:0025 s:0261 b:0261 l:000260 d:000260 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:492
c:0050 p:0100 s:0257 b:0257 l:000256 d:000256 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50
c:0049 p:0168 s:0254 b:0254 l:000253 d:000253 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32
c:0048 p:0019 s:0250 b:0250 l:000249 d:000249 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19
c:0047 p:0100 s:0246 b:0246 l:000245 d:000245 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50
c:0046 p:0168 s:0243 b:0243 l:000242 d:000242 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32
c:0045 p:0019 s:0239 b:0239 l:000238 d:000238 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19
c:0044 p:0100 s:0235 b:0235 l:000234 d:000234 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50
c:0043 p:0168 s:0232 b:0232 l:000231 d:000231 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32
c:0042 p:0019 s:0228 b:0228 l:000227 d:000227 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19
c:0041 p:0044 s:0224 b:0224 l:000223 d:000223 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/builder.rb:30
c:0040 p:0014 s:0220 b:0220 l:000211 d:000219 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/warden-1.0.3/lib/warden/manager.rb:35
c:0039 p:---- s:0218 b:0218 l:000217 d:000217 FINISH
c:0038 p:---- s:0216 b:0216 l:000215 d:000215 CFUNC :catch
c:0037 p:0086 s:0212 b:0212 l:000211 d:000211 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/warden-1.0.3/lib/warden/manager.rb:34
c:0036 p:0015 s:0207 b:0207 l:000206 d:000206 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/best_standards_support.rb:17
c:0035 p:0093 s:0200 b:0200 l:000199 d:000199 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/head.rb:14
c:0034 p:0155 s:0193 b:0193 l:000192 d:000192 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/methodoverride.rb:24
c:0033 p:0046 s:0187 b:0187 l:000186 d:000186 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/params_parser.rb:21
c:0032 p:0054 s:0182 b:0182 l:000181 d:000181 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/flash.rb:182
c:0031 p:0027 s:0175 b:0175 l:000174 d:000174 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/session/abstract_store.rb:149
c:0030 p:0015 s:0164 b:0164 l:000163 d:000163 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/cookies.rb:295
c:0029 p:0014 s:0156 b:0156 l:0023d0 d:000155 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:32
c:0028 p:0019 s:0154 b:0154 l:000153 d:000153 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:28
c:0027 p:0051 s:0150 b:0150 l:000149 d:000149 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:12
c:0026 p:0019 s:0146 b:0146 l:0023d0 d:0023d0 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:31
c:0025 p:0015 s:0142 b:0142 l:000141 d:000141 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.r
c:0024 p:0029 s:0138 b:0138 l:0008f0 d:000137 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:46
c:0023 p:0155 s:0136 b:0136 l:000135 d:000135 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:415
c:0022 p:0011 s:0126 b:0126 l:0008f0 d:0008f0 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:44
c:0021 p:0015 s:0122 b:0122 l:000121 d:000121 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/sendfile.rb:107
c:0020 p:0049 s:0112 b:0112 l:000111 d:000111 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/remote_ip.rb:48
c:0019 p:0015 s:0108 b:0108 l:000107 d:000107 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:46
c:0018 p:0027 s:0100 b:0100 l:000099 d:000099 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/rack/logger.rb:13
c:0017 p:0032 s:0096 b:0096 l:000095 d:000095 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/runtime.rb:17
c:0016 p:0052 s:0087 b:0087 l:000086 d:000086 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:72
c:0015 p:0014 s:0083 b:0083 l:000077 d:000082 BLOCK /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/lock.rb:11
c:0014 p:0019 s:0081 b:0081 l:000080 d:000080 METHOD internal:prelude:10
c:0013 p:0054 s:0078 b:0078 l:000077 d:000077 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/lock.rb:11
c:0012 p:0193 s:0073 b:0073 l:000072 d:000072 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/static.rb:30
c:0011 p:0032 s:0066 b:0066 l:000065 d:000065 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:168
c:0010 p:0021 s:0062 b:0062 l:000061 d:000061 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:77
c:0009 p:---- s:0057 b:0057 l:000056 d:000056 FINISH
c:0008 p:0015 s:0055 b:0055 l:000054 d:000054 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/rack/log_tailer.rb:14
c:0007 p:0015 s:0050 b:0050 l:000049 d:000049 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/content_length.rb:13
c:0006 p:0338 s:0042 b:0042 l:000041 d:000041 METHOD /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/handler/webrick.rb:52
c:0005 p:0257 s:0030 b:0030 l:000029 d:000029 METHOD /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/httpserver.rb:111
c:0004 p:0393 s:0020 b:0020 l:000019 d:000019 METHOD /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/httpserver.rb:70
c:0003 p:0126 s:0009 b:0009 l:001398 d:000008 BLOCK /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/server.rb:183
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP
-- Ruby level backtrace information ---------------------------------------- /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/server.rb:183:in block in start_thread' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/httpserver.rb:70:inrun' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/webrick/httpserver.rb:111:in service' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/handler/webrick.rb:52:inservice' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/content_length.rb:13:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/rack/log_tailer.rb:14:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:77:in method_missing' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:168:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/static.rb:30:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/lock.rb:11:incall' internal:prelude:10:in synchronize' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/lock.rb:11:inblock in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache/strategy/local_cache.rb:72:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/runtime.rb:17:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/rack/logger.rb:13:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/show_exceptions.rb:46:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/remote_ip.rb:48:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/sendfile.rb:107:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:44:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:415:inrun_call_callbacks' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/callbacks.rb:46:in block in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:353:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:31:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:12:incache' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in cache' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/query_cache.rb:32:inblock in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/cookies.rb:295:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/session/abstract_store.rb:149:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/flash.rb:182:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/params_parser.rb:21:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.1/lib/rack/methodoverride.rb:24:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/head.rb:14:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/best_standards_support.rb:17:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/warden-1.0.3/lib/warden/manager.rb:34:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/warden-1.0.3/lib/warden/manager.rb:34:in catch' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/warden-1.0.3/lib/warden/manager.rb:35:inblock in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/builder.rb:30:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:in call!' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:incall_app!' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:incall!' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:in call_app!' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:19:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:32:in call!' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/oa-core-0.1.6/lib/omniauth/strategy.rb:50:incall_app!' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:492:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:139:incall' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:92:in recognize' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:68:inoptimized_each' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/code_generation.rb:93:in block in recognize' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/rack-mount-0.6.13/lib/rack/mount/route_set.rb:148:inblock in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:27:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62:indispatch' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:62:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal.rb:178:inblock in action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/rack_delegation.rb:14:in dispatch' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal.rb:138:indispatch' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:40:in process' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:120:inprocess' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/rescue.rb:17:in process_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:29:inprocess_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in instrument' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:ininstrument' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in block in instrument' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/instrumentation.rb:30:inblock in process_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:17:in process_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:93:inrun_callbacks' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:409:in _run_process_action_callbacks' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:450:inrun2267956389060468203process_action4235457985283276613callbacks' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/callbacks.rb:18:in block in process_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/rendering.rb:11:inprocess_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151:in process_action' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_controller/metal/implicit_render.rb:4:insend_action' /Users/Chris/Sites/site_name/app/controllers/pages_controller.rb:63:in home' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache.rb:296:infetch' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache.rb:519:in instrument' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/cache.rb:297:inblock in fetch' /Users/Chris/Sites/site_name/app/controllers/pages_controller.rb:63:in block in home' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/twitter/client/user.rb:90:insuggestions' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/twitter/request.rb:6:in get' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/twitter/request.rb:28:inrequest' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/connection.rb:64:in get' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/connection.rb:169:inrun_request' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/request.rb:26:in run' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/request.rb:84:inrun' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/twitter-1.0.0/lib/faraday/multipart.rb:16:in call' /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/faraday-0.5.3/lib/faraday/adapter/net_http.rb:45:incall' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:1160:in request' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:626:instart' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:637:in do_start' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677:inconnect' /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:677:in `connect'
-- C level backtrace information -------------------------------------------
[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap
Hey guys,
I didn't see any examples in faraday or faraday_middleware projects for how to POST an XML request. It seems fairly simply with middleware to handle a response in XML format, but I didn't see any way of sending off a POST request in XML. Supported? If not, any pointers on what I could do to contribute?
Thanks!
Ryan
Is there a particular reason for that or could you lower it to 1.3.5?
cause I can't make it work on Heroku.
Cheers,
Vivien
All Ruby tests frameworks treats stubs as something that, after you define it, you can call it several times and it won't complain. This is an example from Mocha:
object = mock()
object.stubs(:method1)
object.method1
object.method1
# no error raised
This is not the behavior I observe in Faraday and I want to discuss a solution for such issue. One proposal could be to allow bang versions of the http verbs, like get! which it would mean that the stub is sticky (won't be deleted after it is used). What do you think?
It turns out that Facebook, in some cases, expects nested parameters with [](e.g. properties[][name]=foo) to have those two characters escaped. I've filed a bug to see if they're open to changing that, but technically open and close brackets are on at least the most general reserved characters list and need to be %-encoded (this is a complicated topic, though, and I'm not sure what I read is fully applicable to URLs).
Would you be open to a patch to build_nested_query that used %5B and %5D instead of [ and ]? If so, I'll put one together; it doesn't look like utils has tests, but if it does I'd be happy to write them.
Thanks!
Hi guys! I'm trying to make Faraday log on Rails.logger and not only on STDOUT
.
Reading here and here, it seems legit to do this:
conn = Faraday.new(url: "http://example.com") do |builder|
builder.use Faraday::Response::Logger, Rails.logger
# builder.use Faraday::Response::ParseJson
# builder.use Faraday::Adapter::Typhoeus
end
But it only logs this:
request
Status
response
Clearly, the issue is here: it only displays the key of the message.
Is this a bug or am I stupid?
I've seen that this requires rack ~> 1.1.0
The problem is that this conflicts with actionpack-2.3.5
I am using the oauth2 gem (which requires faraday) but it causes incompatibiliteis with rack (cannot load 1.0.1 for actionpack because 1.1.0 was already loaded for faraday)
Is it possible to set the requirement to 1.x? because I do not see any reason why 1.1 is required.
I think this would solve some headaches for people trying to implement oauth2 in rails 2..3.5 apps.
I've found that it would be really great if the argument that was passed back to the block when creating a new connection was a Connection
object to allow for calling methods like #basic_auth
instead of having to use tap
or some other mechanism to set those outside the block.
For more context see: technoweenie@692199b#commitcomment-417599
One change that I wanted to get in 0.6, but forgot, was to stop rebuilding the whole middleware stack on each request.
Right now, this is the Request.run method:
def run(connection, request_method)
app = lambda { |env|
response = Response.new
response.finish(env) unless env[:parallel_manager]
env[:response] = response
}
env = to_env_hash(connection, request_method)
connection.builder.to_app(app).call(env)
end
I'd like Faraday to memoize the stack built by connection.builder.to_app(app)
. However, this would mean that you cannot modify the middleware after you started making requests. I don't know if this is intuitive or not.
I'd like to gather more thoughts on this.
I see you're using TPW's little Rake thingy now, which is cool, but it'd be nice to have consistent tags for the previous releases, especially since you don't do a curated changelog.
Hey there,
I'm getting several warnings when I use any especial characters like "é ç ã â".
/home/melquic/.rvm/gems/ruby-1.9.2-p180/gems/faraday-0.7.5/lib/faraday/utils.rb:128: warning: regexp match /.../n against to UTF-8 string
Thanks,
Melquisedeque
I've created a gist demonstrating this bug. Here's the relavant output:
$ ruby client.rb net_http: "foo, bar" typhoeus: "bar" patron: ["foo", "bar"] em_synchrony: nil excon: "bar"
As you can see, each adapter treats the header a bit differently. I think that faraday should provide a consistent interface for this and abstract away the differences of the underlying adapters. I think I like the behavior of patron the best (i.e. returning an array of values), but the net_http behavior of a single comma-separated string would work as well.
hi,
we are 4 developers experiencing problems with your gem. is it because we are using 1.8 in this project or why the hell does rake mess with this date format? we changed it manually to 2011-06-27 to fix this...
ty!
Invalid gemspec in [/Library/Ruby/Gems/1.8/specifications/faraday-0.7.3.gemspec]: invalid date format in specification: "2011-06-27 00:00:00.000000000Z"
/Library/Ruby/Site/1.8/rubygems/specification.rb:277:in _resort!': undefined method
name' for nil:NilClass (NoMethodError)
One of my biggest gripes with Faraday is that it's awkward to pass in parameters to get()
. Just look at how easy it is with post
:
conn.post "/create", name: "Mislav"
And now get
:
conn.get "/search" do |req|
req.params = {name: "Mislav"}
end
That's a lot of work for something simple. I want the 2nd argument for get
to match post
. Trouble is, the 2nd argument now is request headers, and that means breaking backwards compatibility. There's no reliable way to detect whether some hash should be request headers or query values.
One thing against changing this is that 2nd argument to post
is really called body
, which indicates it can take anything that represents a body for the request. We accept a hash and then encode it in middleware, but that's kind of a feature we did there. The argument really is body
, and if get
accepts query params as 2nd argument that would definitely not be called body
since GET doesn't have a body.
What do you say guys? Break backwards compat for a noble cause? Not worth it? Speak up.
(Changing get
arguments would also mean changing head
and delete
to match it.)
From your README:
test = Faraday.new do |builder|
builder.adapter :test, stubs do |stub|
stub.get('/ebi') {[ 200, {}, 'shrimp' ]}
end
end
When I paste that into irb I get NoMethodError: undefined method 'new' for #<Faraday::Connection:0x960ad84>
To use basic auth when the username (or password) contains a character not valid in a URL, the character has to be escaped. For example, assume your username was '[email protected]', then you would have to construct your URL like:
http://foo%40bar.com:[email protected]/somepath
In Faraday::Connection::url_prefix=
, it will set up basic authentication if it parses the username and password from the URL. However, it doesn't unescape them, so there's no way to correctly do basic auth with the URL above. If you don't escape the @, the URL fails to parse.
Faraday::Connection::url_prefix=
should unescape the username and password before constructing the auth header.
Faraday should allow you to set array parameters using the following syntax:
Faraday.new(:url => 'http://localhost:1234').get do |request|
request.url('foo', 'bar' => ['baz', 'qux'])
end
Currently, doing this makes the following request:
GET /foo?bar=baz&bar=qux
I propose it should make this request instead, in keeping with Rack:
GET /foo?bar[]=baz&bar[]=qux
Currently, to get this result, you must construct your request like this, which is a bit ugly ugly:
Faraday.new(:url => 'http://localhost:1234').get do |request|
request.url('foo', 'bar[]' => ['baz', 'qux'])
# ^ eww, gross
end
Discuss.
The following is the API call to a remote service that executes successfully when I use with HTTParty.
require 'httparty'
class TheAPI
include HTTParty
base_uri 'https://someapp.com'
# headers "Content-Type" => "application/json"
def self.create_job
post( '/jobs.json', :query => {:apikey => "kOrROwbVPNC34VZYhbET", :job => {:method => "PUT", :at => '2012-01-31T18:36:21', :uri => "http://kasko.com"}})
end
end
puts TheAPI.create_job
But when I try to make the same call using Faraday, I get this unknown error:
require 'faraday_stack'
conn = Faraday.new 'https://someapp.com', ssl: {verify: false} do |builder|
builder.use FaradayStack::ResponseJSON, content_type: 'application/json'
builder.use Faraday::Response::Logger#, Logger.new('faraday.log')
# builder.use FaradayStack::FollowRedirects, limit: 3
builder.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
builder.use Faraday::Adapter::NetHttp
end
# conn.headers[:user_agent] = 'MyLib v1.2'
resp = conn.post "jobs.json", {:apikey => "kOrROwbVPNC34VZYhbET", :job => {:method => "PUT", :at => '2012-01-31T18:36:21', :uri => "http://kasko.com"}}
puts resp
The error raised is:
NoMethodError: undefined method ‘bytesize’ for #<Hash:0x000001011ab8f8>
method send_request_with_body in http.rb at line 1735
method exec in http.rb at line 1724
method transport_request in http.rb at line 1189
method request in http.rb at line 1177
method block in request in http.rb at line 1170
method start in http.rb at line 627
method request in http.rb at line 1168
method call in net_http.rb at line 51
method call in response.rb at line 8
method call in response.rb at line 8
method call in logger.rb at line 20
method call in response.rb at line 8
method run_request in connection.rb at line 203
method post in connection.rb at line 90
method <main> in test.rb at line 33
For background, see issue 43.
Currently header values are strings. When the response contains multiple values for the same header, it is a comma separated string (as of the fix for issue 43).
I think it'd be nice if the header values were arrays so that multiple values are explicit. Using a comma-separated string has potential encoding issues: how does a user distinguish between a single value of a string containing a comma, and a header of multiple values?
As @mislav pointed out, changing mutli-value headers to an array could create confusion for the user if the values are strings sometimes (i.e. for singel values) and arrays other times. I'm not sure of the best idea for that, but one idea is to keep the current behavior for env[:response_headers], with a deprecation warning, and add a new hash entry (maybe env[:response_header_hash] or something) that returns a hash with arrays for all values. That would make things consistent (use all arrays), while not breaking existing users who depend on header values being strings.
GET methods can have bodies.
For instance, ElasticSearch uses the GET body to search.
Faraday::Connection
supports two forms of authentication — basic and token. They are implemented as configuration options. I suggest that it would be in keeping with Faraday's overall design to implement them as middleware instead.
I've implemented this in the API client I'm building on top of Faraday. I'd be happy to submit a patch if it is something you would consider.
conn = Faraday::Connection.new # ... stuff
conn.basic_auth("A"*255, "")
conn.get "/"
This will generate an invalid HTTP request since Base64.encode64 adds new lines every 60 chars
I am not sure how you want to handle proxy support but it is not currently addressed. Do you want to have a proxy option in initialize or do you want to set it using ENV['http_proxy']. I can put something together but interested in your thoughts
Hello,
Since this commit, this response parser is broken.
I do the following :
Faraday::Connection.new(:url => 'http://api.bit.ly') do |builder|
builder.adapter Faraday.default_adapter
builder.response :yajl
end
But the response is not parsed with yajl (the json is not parsed at all).
I'm looking to replace the guts of the aws gem with Faraday, but we need this feature to do that completely.
I found dependency problem with usage faraday 0.5.0 and data-mapper 1.0.2 because faraday used addressable only 2.1.1 but data-mapper used 2.2.
Could you please update dependency addressable version?
env[:response_headers]
should always return a Hash.
This may be a problem with request_headers as well, I'm not sure.
Hello,
When using faraday locally and making calls to an application launched locally, I get the following error :
ERROR HTTPRequest#fixup: WEBrick::HTTPStatus::LengthRequired occured
Note : this error appears on the application which is called by faraday.
Until now, I was using unicorn for that application and it works. But now, I get the same one on heroku when doing a put request.
My request is very basic and I don't think it comes from there.
datas = connection.put do |req|
req.url "/v1/clients/#{client}/projects/#{project_id}/publications/#{id}.json", {'some' => 'parameters'}
req["Content-Type"] = 'application/json'
end
I'm having issues with using content_type in my connection.
Env:
ruby 1.8.7
faraday 0.4.6
Following the example on the README, I tried setting context_type as a symbol and got this error
conn.get {|x| x.url "/"; x[:content_type] = 'applicaiton/json' }
NoMethodError: undefined method downcase' for :content_type:Symbol from /Users/aaronw/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/net/http.rb:1258:in
key?'
from /Users/aaronw/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/net/http.rb:1147:in initialize_http_header' from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/rack-1.2.1/lib/rack/utils.rb:305:in
each'
from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/rack-1.2.1/lib/rack/utils.rb:304:in each' from /Users/aaronw/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/net/http.rb:1146:in
initialize_http_header'
from /Users/aaronw/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/net/http.rb:1480:in initialize' from /Users/aaronw/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/net/http.rb:1016:in
new'
from /Users/aaronw/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/net/http.rb:1016:in send_request' from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/faraday-0.4.6/lib/faraday/adapter/net_http.rb:33:in
call'
from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/faraday-0.4.6/lib/faraday/request.rb:84:in run' from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/faraday-0.4.6/lib/faraday/request.rb:26:in
run'
from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/faraday-0.4.6/lib/faraday/connection.rb:155:in run_request' from /Users/aaronw/.rvm/gems/ruby-1.8.7-head@pb/gems/faraday-0.4.6/lib/faraday/connection.rb:53:in
get'
from (irb):21
1) Error:
test_default(TestEnv):
Addressable::URI::InvalidURIError: Cannot have a relative path with an authority set: '//sushi.comfoo.json'
/usr/lib64/ruby/gems/1.8/gems/addressable-2.1.2/lib/addressable/uri.rb:2048:in `validate'
/usr/lib64/ruby/gems/1.8/gems/addressable-2.1.2/lib/addressable/uri.rb:906:in `host='
/media/repos/flame/ruby/faraday/test/../lib/faraday/connection.rb:177:in `build_url'
/media/repos/flame/ruby/faraday/test/../lib/faraday/request.rb:73:in `to_env_hash'
./test/env_test.rb:54:in `env_for'
./test/env_test.rb:13:in `setup'
This error was added to 2.1.2 and was not present in 2.1.1.
Example:
conn.params[:client_id] = 'hi'
Because of some black magic in current params merging code (needs refactoring), the "client_id" gets duplicated (i.e. appended to the URL twice).
Running the tests for faraday 0.5.7 with jruby (jruby 1.5.2 (ruby 1.8.7 patchlevel 249) (2010-09-05 6586) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [amd64-java]) I'm getting the following failure:
1) Failure: test_use_rails_json_to_raise_Faraday_Error_Parsing_with_no_json_content(ResponseMiddlewareTest) [./test/response_middleware_test.rb:27]: exception expected but none was thrown.
The tests run fine with ruby 1.8.7 and ruby enterprise edition. Please let me know if you need more information.
If I'm understanding what's going on here, this seems like a pretty serious bug in 0.6...
I created a faraday-0.6 branch for the twitter gem and made all the necessary changes but 230 specs are failing because the Faraday::Response::Mashify
middleware is being called before the Faraday::Response::ParseJson
(or Faraday::Response::ParseXml
) middleware despite the fact that the Faraday::Response::Mashify
middleware is specified last.
What the heck is going on here?
I realize (especially for testing, but some other times as well) that I would really like to be able to insert and replace handler based on the class name instead of by the index.
It would be great to be able to say:
test = Faraday::Adapter::Test.new do |stub|
stub.post('/') { [ 200, nil, '' ] }
end
connection.builder.replace(Faraday.default_adapter, test)
and
connection.builder.insert_before(Faraday::Response::MultiJson, Faraday::Response::RaiseError)
Does this make sense to everyone else?
Faraday automatically escapes urls before a request, but that does not happen with test stubs. Or we can automatically escape URLs in test mode or at least provide the escaping facility in a module.
eg:
response = request.run(connection, 'GET')
It works, but that response is actually the request. How do you get the response object?
/home/mdupont/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -I"lib:lib:test" -I"/home/mdupont/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib" "/home/mdupont/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb"
/home/mdupont/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
warning: test server not specified; skipping live server tests
Loaded suite /home/mdupont/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
...............................................................EE......................................
Finished in 1.572946 seconds.
1) Error:
test_auto_parses_basic_auth_from_url(TestConnection):
NameError: uninitialized constant Faraday::Connection::CGI
/home/mdupont/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing'
/home/mdupont/experiments/diaspora/deps/faraday/lib/faraday/connection.rb:181:in `url_prefix='
/home/mdupont/experiments/diaspora/deps/faraday/lib/faraday/connection.rb:35:in `initialize'
/home/mdupont/experiments/diaspora/deps/faraday/test/connection_test.rb:72:in `new'
/home/mdupont/experiments/diaspora/deps/faraday/test/connection_test.rb:72:in `test_auto_parses_basic_auth_from_url'
2) Error:
test_auto_parses_basic_auth_from_url_and_unescapes(TestConnection):
NameError: uninitialized constant Faraday::Connection::CGI
/home/mdupont/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing'
/home/mdupont/experiments/diaspora/deps/faraday/lib/faraday/connection.rb:181:in `url_prefix='
/home/mdupont/experiments/diaspora/deps/faraday/lib/faraday/connection.rb:35:in `initialize'
/home/mdupont/experiments/diaspora/deps/faraday/test/connection_test.rb:77:in `new'
/home/mdupont/experiments/diaspora/deps/faraday/test/connection_test.rb:77:in `test_auto_parses_basic_auth_from_url_and_unescapes'
103 tests, 151 assertions, 0 failures, 2 errors, 0 skips
Test run options: --seed 7526
rake aborted!
Command failed with status (1): [/home/mdupont/.rvm/rubies/ruby-1.9.2-p290/...]
Tasks: TOP => default => test
(See full trace by running task with --trace)
Seems to be a bug in either the net/http lib or the faraday gem with ruby-1.9.2-p180. Stack trace here: https://gist.github.com/76bfca7917f5a43bd850
see line 19
https://github.com/technoweenie/faraday/blob/master/lib/faraday/adapter/net_http.rb#L19
for example,
a = {:foo => false}
=> {:foo=>false}
ruby-1.9.2-p180-fastrequire :002 > b = a[:foo] || "nope"
=> "nope"
this logic seems flawed... i think you want something like:
http.verify_mode = ssl.key?(:verify_mode) ? ssl[:verify_mode] : ssl.fetch(:verify, true) ?
OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
I'm using Faraday to access a web service. Naturally, I would have expected to just do:
VCR.config do |c|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
c.stub_with :faraday
end
But in order to get any cassettes to save I needed to do:
VCR.config do |c|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
c.stub_with :fakeweb, :faraday
end
This took me a few hours today to locate. I was using koala gem which uses Faraday and I was getting
"NoMethodError: undefined method `bytesize' for nil:NilClass"
The problem was in
lib/faraday/utils.rb:129:in `block in escape'
And it is being caused by
However, if Faraday::Utils#escape is changed from
def escape(s)
s.to_s.gsub(/([^a-zA-Z0-9_.-]+)/n) do
'%' << $1.unpack('H2'*bytesize($1)).join('%').tap { |c| c.upcase! }
end
end
to
def escape(s)
s.to_s.gsub(/([^a-zA-Z0-9_.-]+)/n) do |match|
'%' << match.unpack('H2'*bytesize(match)).join('%').tap { |c| c.upcase! }
end
end
everything works.
Is there any particular reason why $1 is used instead of the block parameter?
I've had some people wanting OmniAuth (which depends on oauth2 which depends on faraday) to work on Rails 2.3.5 and the Rack 1.2.1 dependency is throwing them. Any way to make it work on 1.1 instead?
https://github.com/technoweenie/faraday/blob/master/lib/faraday/response.rb#L75
should it cover all the other 2xx statuses also?
http://www.codyfauser.com/2008/7/4/rails-http-status-code-to-symbol-mapping
From: https://github.com/jnunemaker/twitter/issues/#issue/119
I believe this error is in Faraday code, but perhaps not. I am intentionally configuring Twitter to use an invalid endpoint to test my rescue block for connection failed. I am using ruby 1.9.2, twitter 1.0.0.rc8 and faraday 0.5.3 on a daemon-kit 0.1.8.1 app. Instead of ConnectionFailed, I get NoMethodError:
base.rb:9: Base::TwitterService Exception on client.update: <NoMethodError: undefined method `message' for Errno::ECONNREFUSED:Class>
base.rb:12: /Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/error.rb:9:in `message'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/adapter/net_http.rb:59:in `raise'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/adapter/net_http.rb:59:in `rescue in call'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/adapter/net_http.rb:12:in `call'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/twitter-1.0.0.rc.8/lib/faraday/oauth.rb:15:in `call'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/twitter-1.0.0.rc.8/lib/faraday/multipart.rb:16:in `call'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/request.rb:84:in `run'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/request.rb:26:in `run'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/connection.rb:169:in `run_request'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/faraday-0.5.3/lib/faraday/connection.rb:68:in `post'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/twitter-1.0.0.rc.8/lib/twitter/request.rb:28:in `request'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/twitter-1.0.0.rc.8/lib/twitter/request.rb:11:in `post'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_gemset/gems/twitter-1.0.0.rc.8/lib/twitter/client/tweets.rb:43:in `update'
/sandbox/my_app/lib/services/twitter.rb:32:in `send_request'
/sandbox/my_app/libexec/my_app-daemon.rb:77:in `block (2 levels) in <top (required)>'
/sandbox/my_app/libexec/my_app-daemon.rb:51:in `each'
/sandbox/my_app/libexec/my_app-daemon.rb:51:in `block in <top (required)>'
/sandbox/my_app/libexec/my_app-daemon.rb:41:in `loop'
/sandbox/my_app/libexec/my_app-daemon.rb:41:in `<top (required)>'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_app/gems/daemon-kit-0.1.8.1/lib/daemon_kit/application.rb:38:in `require'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_app/gems/daemon-kit-0.1.8.1/lib/daemon_kit/application.rb:38:in `run'
/Users/danhealy/.rvm/gems/ruby-1.9.2-p0@my_app/gems/daemon-kit-0.1.8.1/lib/daemon_kit/application.rb:21:in `exec'
./bin/my_app:8:in `<main>'
Thanks
This is our current Rack app (i.e. the "inner app" wrapped by middleware):
app = lambda { |env|
response = Response.new
response.finish(env) unless env[:parallel_manager]
env[:response] = response
}
It's really kind of a hack. I think our adapters should each perform this and stop acting like middleware when they really play a role of an endpoint. I can't think of a use case where you would want to mount middleware after the adapter.
This sucks:
url = "/fb?"
url << "ixBug=1&"
url << "ixRepository=&"
url << "sFile=%2Flib%2Fgrit%2Fgrit.rb&"
url << "sNew=06f63b43050935962f84fe54473a7c5de7977325&"
url << "sPrev=4c8124ffcf4039d292442eeccabdeca5af5c5017"
@stubs.get url do |env|
end
I'd rather test the parsed params in the yielded env
var.
I'm trying (without much success so far) to find the best spot to even write a failing test for this, but I'm seeing :request_headers are ignored in the middleware.
To reproduce, use the Yajl request middleware and note that 'Content-Type' does not flow through with the request. I'd be glad to work up a patch if you could point me in the right direction.
I'm going to be cleaning some crap up and pushing v0.5 hopefully this week. If you have any pet features, get them in soon :)
My TODO:
Hi guys,
So I've been attempting to use Faraday in the aws gem so that the user can swap out connection implementations at will. And the driver for doing that was to enable EventMachine support.
Anyways, I've hacked together a working example, but I wanted to run it by you guys so you can start thinking about how you want the async interface for Faraday to work. I added an AsyncResponse which enables callbacks and what not so the user can use it truly asynchronously.
EM adapter with async stuff on it:
https://github.com/appoxy/aws/blob/faraday/test/sdb/faraday_em_adapter.rb
Performance tests, HUGE performance gain:
https://github.com/appoxy/aws/blob/faraday/test/sdb/test_performance.rb
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.