rails-reverse-proxy 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1b94bbe6eeeeccc58ec4feead43ef9087adad7e
4
- data.tar.gz: c868d4034d08f11c0440fdb0622ac6956010b85f
3
+ metadata.gz: c3efd82dcfd11cfa021b4871b3e1f0aa33a8a509
4
+ data.tar.gz: 0eadd74a5b7effad66d73df02c694322e4011cc6
5
5
  SHA512:
6
- metadata.gz: 3aefba37ef43c29762fa578b005675086972f86cf9d1bde8bff44f3c76819ef77c59baae6fd685954310e8f8f8bf1be50eaf6c0bc3c6ba9f31bcc73977b5c2bb
7
- data.tar.gz: 0163b7b4c729933fb53e12b3403d28216fae4ec77ba7fe1270a641413c7ee98b5231d2b1d9ccdf095724cfea9a1ea30101b2e6f26946d8af7023836f39746deb
6
+ metadata.gz: 535ea09b49f805d311b6c492772ab8ea07c9395971ffd2ad726353d22f98befcb2f5c3fd16b7df347d4f87011b6930b5cc8e7a485fa9bce61c46021964f5f381
7
+ data.tar.gz: 727eb02da9067525e02f56bcaa179982ee53d413e723b066ed99688f3e6e145c9a68786ffc0e2718d23aee64269df618170d25be180fc8dfa7496f76a396d531
data/Gemfile CHANGED
@@ -4,7 +4,6 @@ gem 'rails'
4
4
  gem 'rack'
5
5
  gem 'rack-proxy'
6
6
  gem 'addressable'
7
- gem 'cookiejar', '~> 0.3.2'
8
7
 
9
8
  # Add dependencies to develop your gem here.
10
9
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -39,7 +39,6 @@ GEM
39
39
  addressable (2.3.8)
40
40
  arel (6.0.0)
41
41
  builder (3.2.2)
42
- cookiejar (0.3.2)
43
42
  descendants_tracker (0.0.4)
44
43
  thread_safe (~> 0.3, >= 0.3.1)
45
44
  docile (1.1.5)
@@ -149,7 +148,6 @@ PLATFORMS
149
148
  DEPENDENCIES
150
149
  addressable
151
150
  bundler (~> 1.0)
152
- cookiejar (~> 0.3.2)
153
151
  jeweler (~> 2.0.1)
154
152
  rack
155
153
  rack-proxy
@@ -157,3 +155,6 @@ DEPENDENCIES
157
155
  rdoc (~> 3.12)
158
156
  shoulda
159
157
  simplecov
158
+
159
+ BUNDLED WITH
160
+ 1.10.6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
@@ -1,6 +1,5 @@
1
1
  require 'rack'
2
2
  require 'rack-proxy'
3
- require 'cookiejar'
4
3
 
5
4
  module ReverseProxy
6
5
  class Client
@@ -92,11 +91,8 @@ module ReverseProxy
92
91
  set_cookies_hash = {}
93
92
 
94
93
  set_cookie_headers.each do |set_cookie_header|
95
- set_cookie_hash = CookieJar::CookieValidation.parse_set_cookie(set_cookie_header)
96
- set_cookie_hash[:value] = CGI.unescape(set_cookie_hash[:value])
97
-
98
- name = set_cookie_hash.delete(:name)
99
-
94
+ set_cookie_hash = parse_cookie(set_cookie_header)
95
+ name = set_cookie_hash[:name]
100
96
  set_cookies_hash[name] = set_cookie_hash
101
97
  end
102
98
 
@@ -140,5 +136,40 @@ module ReverseProxy
140
136
  def reconstruct_header_name(name)
141
137
  name.sub(/^HTTP_/, "").gsub("_", "-")
142
138
  end
139
+
140
+ COOKIE_PARAM_PATTERN = /\A([^(),\/<>@;:\\\"\[\]?={}\s]+)(?:=([^;]*))?\Z/
141
+ COOKIE_SPLIT_PATTERN = /;\s*/
142
+
143
+ def parse_cookie(cookie_str)
144
+ params = cookie_str.split(COOKIE_SPLIT_PATTERN)
145
+ info = params.shift.match(COOKIE_PARAM_PATTERN)
146
+ return {} unless info
147
+
148
+ cookie = {
149
+ name: info[1],
150
+ value: CGI.unescape(info[2]),
151
+ }
152
+
153
+ params.each do |param|
154
+ result = param.match(COOKIE_PARAM_PATTERN)
155
+ next unless result
156
+
157
+ key = result[1].downcase.to_sym
158
+ value = result[2]
159
+ case key
160
+ when :expires
161
+ begin
162
+ cookie[:expires] = Time.parse(value)
163
+ rescue ArgumentError
164
+ end
165
+ when *[:httponly, :secure]
166
+ cookie[key] = true
167
+ else
168
+ cookie[key] = value
169
+ end
170
+ end
171
+
172
+ cookie
173
+ end
143
174
  end
144
175
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rails-reverse-proxy 0.4.2 ruby lib
5
+ # stub: rails-reverse-proxy 0.5.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rails-reverse-proxy"
9
- s.version = "0.4.2"
9
+ s.version = "0.5.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["James Hu"]
14
- s.date = "2015-08-11"
14
+ s.date = "2015-08-28"
15
15
  s.description = "Reverse proxy for Ruby on Rails"
16
16
  s.email = "hello@james.hu"
17
17
  s.extra_rdoc_files = [
@@ -46,7 +46,6 @@ Gem::Specification.new do |s|
46
46
  s.add_runtime_dependency(%q<rack>, [">= 0"])
47
47
  s.add_runtime_dependency(%q<rack-proxy>, [">= 0"])
48
48
  s.add_runtime_dependency(%q<addressable>, [">= 0"])
49
- s.add_runtime_dependency(%q<cookiejar>, ["~> 0.3.2"])
50
49
  s.add_development_dependency(%q<shoulda>, [">= 0"])
51
50
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
52
51
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
@@ -57,7 +56,6 @@ Gem::Specification.new do |s|
57
56
  s.add_dependency(%q<rack>, [">= 0"])
58
57
  s.add_dependency(%q<rack-proxy>, [">= 0"])
59
58
  s.add_dependency(%q<addressable>, [">= 0"])
60
- s.add_dependency(%q<cookiejar>, ["~> 0.3.2"])
61
59
  s.add_dependency(%q<shoulda>, [">= 0"])
62
60
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
61
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -69,7 +67,6 @@ Gem::Specification.new do |s|
69
67
  s.add_dependency(%q<rack>, [">= 0"])
70
68
  s.add_dependency(%q<rack-proxy>, [">= 0"])
71
69
  s.add_dependency(%q<addressable>, [">= 0"])
72
- s.add_dependency(%q<cookiejar>, ["~> 0.3.2"])
73
70
  s.add_dependency(%q<shoulda>, [">= 0"])
74
71
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
75
72
  s.add_dependency(%q<bundler>, ["~> 1.0"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-reverse-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-11 00:00:00.000000000 Z
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: cookiejar
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.3.2
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.3.2
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: shoulda
85
71
  requirement: !ruby/object:Gem::Requirement