faraday-cookie_jar 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -1
- data/README.md +1 -1
- data/Rakefile +4 -0
- data/faraday-cookie_jar.gemspec +1 -1
- data/lib/faraday/cookie_jar.rb +8 -6
- data/lib/faraday/cookie_jar/version.rb +1 -1
- metadata +7 -7
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Faraday middleware to manage client-side cookies
|
|
4
4
|
|
5
5
|
## Description
|
6
6
|
|
7
|
-
This gem is a piece of Faraday middleware that adds client-side Cookies management, using [
|
7
|
+
This gem is a piece of Faraday middleware that adds client-side Cookies management, using [http-cookie gem](https://github.com/sparklemotion/http-cookie).
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
data/Rakefile
CHANGED
data/faraday-cookie_jar.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "faraday", ">= 0.7.4"
|
22
|
-
spec.add_dependency "
|
22
|
+
spec.add_dependency "http-cookie", "~> 1.0.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake"
|
data/lib/faraday/cookie_jar.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
require "faraday"
|
2
|
-
require "
|
2
|
+
require "http/cookie_jar"
|
3
3
|
|
4
4
|
module Faraday
|
5
5
|
class CookieJar < Faraday::Middleware
|
6
6
|
def initialize(app, options = {})
|
7
7
|
super(app)
|
8
|
-
@jar = ::CookieJar
|
8
|
+
@jar = HTTP::CookieJar.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
12
|
-
|
13
|
-
unless
|
14
|
-
env[:request_headers]["Cookie"] =
|
12
|
+
cookies = @jar.cookies(env[:url])
|
13
|
+
unless cookies.empty?
|
14
|
+
env[:request_headers]["Cookie"] = HTTP::Cookie.cookie_value(cookies)
|
15
15
|
end
|
16
16
|
|
17
17
|
@app.call(env).on_complete do |res|
|
18
|
-
|
18
|
+
if set_cookie = res[:response_headers]["Set-Cookie"]
|
19
|
+
@jar.parse(set_cookie, env[:url])
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-cookie_jar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -28,21 +28,21 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.7.4
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: http-cookie
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 1.0.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 1.0.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bundler
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|