26 Commits

Author SHA1 Message Date
Mislav Marohnić
441d8ac979 Simplify copying custom_members to new Env instance 2015-10-02 00:06:53 +02:00
nicholas a. evans
03f373a1fb Env custom members should be copied by Env.from(env)
Fixes lostisland/faraday#408.

If middleware or adapters add custom members to env, those members should be
retained.
2015-09-21 16:58:59 -04:00
Janko Marohnić
edacd5eb57 Fix response not changing with parallel requests
In this order the @env would not be changed by the "on complete"
callbacks, meaning that the response would not change after parallel
requests finish (e.g. JSON would not be parsed).

This would work

  def on_complete(env)
    env[:body].upcase!
  end

But this wouldn't

  def on_complete(env)
    env[:body] = env[:body].upcase
  end
2014-05-23 14:03:39 +02:00
Mislav Marohnić
7dff04854e Make Headers#fetch case-insensitive
Matches the behavior of `[]` and `[]=` methods. Also accepts symbols:

    headers.fetch(:content_type)
2013-10-06 16:10:28 +02:00
rick
2c5bf666b3 fix Faraday::Options#update 2013-06-22 17:24:52 -07:00
Lucas Mazza
abccadd2be Convert Env keys to symbols 2013-01-07 22:57:40 -02:00
technoweenie
e8c2ba0c0e fix Response#to_hash 2012-10-21 16:55:23 -06:00
technoweenie
04a8514cba Response#env is always an Env 2012-10-21 15:41:56 -06:00
technoweenie
dc383b0999 remove :custom option key 2012-10-21 15:05:59 -06:00
technoweenie
fa397470e2 simplify test requires 2012-10-21 10:25:34 -06:00
Mislav Marohnić
aec0723735 fix Utils::Headers 2012-01-29 00:06:34 +01:00
Mislav Marohnić
085ee735dc Improve how params, headers & options are handled in the request phase
Old behavior:

  # init connection with some defaults:
  conn = Faraday.new :params => {...}, :request => {...}

  conn.get('/') do |request|
    request.params = {...}   # params got merged with defaults
    request.options = {...}  # options got deep-merged with defaults
  end

New behavior:

  conn.get('/', {...}) do |request|
    request.params.update(...)  # merge with existing params
    request.params = {...}      # replace all existing params

    request.options[:proxy][:user] = "..." # add extra request options:
    request.options = {...}                # replace all existing options
  end

Pros of the new behavior are consistency, ability to completely override
parameters per-request. Cons are breaking backwards-compatibility.
2012-01-28 22:14:59 +01:00
Mislav Marohnić
8f7f6694da remove dependency on Addressable::URI
This is a potentially breaking change for 3rd party code that relies on
env[:url] being specifically Addressable. After this change all urls are
passed around as instances of URI::HTTP.
2011-12-30 15:08:14 +01:00
Erik Michaels-Ober
4524cfafdc Cleanup trailing whitespace 2011-11-28 03:46:27 -08:00
Mislav Marohnić
264492a4a8 enable setting per-request options
Global request options (`connection.options`) are copied to the env
hash as env[:request]. This adds the ability to customize these options
per request:

  conn.get('/') do |req|
    req.options[:timeout] = 10
    req.options[:proxy] = {:user => 'dave'}
  end

Local options are merged recursively with global ones.
2011-06-27 17:29:45 +02:00
Mislav Marohnić
7fa58f2009 refactor how Requests are ran
The Request class is not responsible for running itself anymore.
Its `run` methods (both class and instance) are gone.

The actual running of the request is handled by Connection in the
`run_request` method.
2011-05-08 16:24:13 -07:00
Mislav Marohnić
b9e54dbe0f add Response.apply_request method
Useful, for example, to re-apply the current request environment after
a response object was restored from cache.
2011-03-27 23:27:15 +02:00
Mislav Marohnić
f739002d0b more love for response headers; handle ones with multiple values
Also:
  - ensure that env[:response_headers] is not available during request phase
  - fix headers from "Test" adapter

Closes #43
2011-03-27 21:57:14 +02:00
Mislav Marohnić
8dccfc6117 like :request_headers, env[:response_headers] is now case-insensitive 2011-03-27 00:23:20 +01:00
rick
7d12ed5ddb Faraday.new shortcut 2011-02-27 10:20:18 -08:00
Erik Michaels-Ober
dbeab13512 Fix tests with duplicate names (they weren't being executed) 2010-10-08 13:04:45 -07:00
rick
a43e0896a6 add http proxy support to net/http 2010-04-27 09:53:33 -04:00
rick
7739157945 add ssl support to net/http and typhoeus 2010-04-27 09:35:17 -04:00
rick
a47c6066fa remove dependency on context 2010-02-18 13:33:50 -08:00
rick
14621781c4 send merged headers with requests 2010-02-06 21:16:42 -08:00
rick
67d619d780 rename Alice => Faraday. 2010-01-12 17:03:34 -08:00