faraday_middleware 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -68,8 +68,13 @@ module FaradayMiddleware
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def finalize_response(response, env)
|
71
|
-
response =
|
72
|
-
response
|
71
|
+
response = response.dup if response.frozen?
|
72
|
+
env[:response] = response
|
73
|
+
unless env[:response_headers]
|
74
|
+
env.update response.env
|
75
|
+
# FIXME: omg hax
|
76
|
+
response.instance_variable_set('@env', env)
|
77
|
+
end
|
73
78
|
response
|
74
79
|
end
|
75
80
|
end
|
@@ -26,8 +26,8 @@ module FaradayMiddleware
|
|
26
26
|
@content_types = Array(options[:content_type])
|
27
27
|
end
|
28
28
|
|
29
|
-
def call(
|
30
|
-
@app.call(
|
29
|
+
def call(environment)
|
30
|
+
@app.call(environment).on_complete do |env|
|
31
31
|
if process_response_type?(response_type(env)) and parse_response?(env)
|
32
32
|
process_response(env)
|
33
33
|
end
|
data/spec/caching_test.rb
CHANGED
@@ -22,6 +22,16 @@ class CachingTest < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
class Lint < Struct.new(:app)
|
26
|
+
def call(env)
|
27
|
+
app.call(env).on_complete do
|
28
|
+
raise "no headers" unless env[:response_headers].is_a? Hash
|
29
|
+
raise "no response" unless env[:response].is_a? Faraday::Response
|
30
|
+
raise "env not identical" unless env[:response].env.object_id == env.object_id
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
25
35
|
def setup
|
26
36
|
@cache = TestCache.new
|
27
37
|
|
@@ -31,6 +41,7 @@ class CachingTest < Test::Unit::TestCase
|
|
31
41
|
}
|
32
42
|
|
33
43
|
@conn = Faraday.new do |b|
|
44
|
+
b.use Lint
|
34
45
|
b.use FaradayMiddleware::Caching, @cache
|
35
46
|
b.adapter :test do |stub|
|
36
47
|
stub.get('/', &response)
|
@@ -55,7 +66,7 @@ class CachingTest < Test::Unit::TestCase
|
|
55
66
|
get('/') # make cache
|
56
67
|
response = get('/')
|
57
68
|
assert_equal :get, response.env[:method]
|
58
|
-
assert_equal '/', response.env[:url].
|
69
|
+
assert_equal '/', response.env[:url].request_uri
|
59
70
|
end
|
60
71
|
|
61
72
|
def test_cache_query_params
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday_middleware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
17
|
-
requirement: &
|
17
|
+
requirement: &70176520423440 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -25,10 +25,10 @@ dependencies:
|
|
25
25
|
version: '0.9'
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
|
-
version_requirements: *
|
28
|
+
version_requirements: *70176520423440
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: multi_xml
|
31
|
-
requirement: &
|
31
|
+
requirement: &70176520413280 !ruby/object:Gem::Requirement
|
32
32
|
none: false
|
33
33
|
requirements:
|
34
34
|
- - ~>
|
@@ -36,10 +36,10 @@ dependencies:
|
|
36
36
|
version: '0.2'
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
|
-
version_requirements: *
|
39
|
+
version_requirements: *70176520413280
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rake
|
42
|
-
requirement: &
|
42
|
+
requirement: &70176520410400 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
@@ -47,10 +47,10 @@ dependencies:
|
|
47
47
|
version: '0.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
|
-
version_requirements: *
|
50
|
+
version_requirements: *70176520410400
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: hashie
|
53
|
-
requirement: &
|
53
|
+
requirement: &70176520395720 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
56
56
|
- - ~>
|
@@ -58,10 +58,10 @@ dependencies:
|
|
58
58
|
version: '1.2'
|
59
59
|
type: :development
|
60
60
|
prerelease: false
|
61
|
-
version_requirements: *
|
61
|
+
version_requirements: *70176520395720
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rash
|
64
|
-
requirement: &
|
64
|
+
requirement: &70176520393980 !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
@@ -69,10 +69,10 @@ dependencies:
|
|
69
69
|
version: '0.3'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
|
-
version_requirements: *
|
72
|
+
version_requirements: *70176520393980
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: rspec
|
75
|
-
requirement: &
|
75
|
+
requirement: &70176520392900 !ruby/object:Gem::Requirement
|
76
76
|
none: false
|
77
77
|
requirements:
|
78
78
|
- - ~>
|
@@ -80,10 +80,10 @@ dependencies:
|
|
80
80
|
version: '2.6'
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
|
-
version_requirements: *
|
83
|
+
version_requirements: *70176520392900
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: simple_oauth
|
86
|
-
requirement: &
|
86
|
+
requirement: &70176520391440 !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
89
89
|
- - ~>
|
@@ -91,10 +91,10 @@ dependencies:
|
|
91
91
|
version: '0.1'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
|
-
version_requirements: *
|
94
|
+
version_requirements: *70176520391440
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rack-cache
|
97
|
-
requirement: &
|
97
|
+
requirement: &70176520390140 !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
version: '1.1'
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
|
-
version_requirements: *
|
105
|
+
version_requirements: *70176520390140
|
106
106
|
description: Various middleware for Faraday
|
107
107
|
email:
|
108
108
|
- sferik@gmail.com
|