sapoci-connect 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/bin/sapoci-search CHANGED
@@ -56,7 +56,7 @@ begin
56
56
 
57
57
  # Setup
58
58
  conn = Faraday.new(uri.to_s, :ssl => {:verify => true}) do |builder|
59
- builder.response :follow_redirects, :cookies => :all, :limit => 5
59
+ builder.response :follow_redirects, :cookies => :all, :limit => 10
60
60
  builder.response :background_search
61
61
  builder.use Faraday::Response::Logger if options.debug
62
62
  builder.adapter Faraday.default_adapter
@@ -1,5 +1,6 @@
1
1
  require 'faraday'
2
2
  require 'set'
3
+ require 'webrick'
3
4
 
4
5
  module SAPOCI
5
6
  module Connect
@@ -62,13 +63,13 @@ module SAPOCI
62
63
  # standards_compliant - A Boolean indicating whether to respect
63
64
  # the HTTP spec when following 302
64
65
  # (default: false)
65
- # cookie - Use either an array of strings
66
- # (e.g. ['cookie1', 'cookie2']) to choose kept cookies
67
- # or :all to keep all cookies.
68
66
  def initialize(app, options = {})
69
67
  super(app)
70
68
  @options = options
71
69
 
70
+ @options[:cookies] = :all
71
+ @cookies = []
72
+
72
73
  @replay_request_codes = Set.new [307]
73
74
  @replay_request_codes << 302 if standards_compliant?
74
75
  end
@@ -99,10 +100,11 @@ module SAPOCI
99
100
 
100
101
  def update_env(env, request_body, response)
101
102
  location = response['location']
102
- raise RedirectWithoutLocation, response if location.blank?
103
+ raise RedirectWithoutLocation, response if location.to_s.size == 0
103
104
  env[:url] += location
104
- if @options[:cookies] && captured_cookies = keep_cookies(env)
105
- env[:request_headers]['Cookie'] = captured_cookies
105
+
106
+ if @options[:cookies] && cookie_string = collect_cookies(env)
107
+ env[:request_headers]['Cookie'] = cookie_string
106
108
  end
107
109
 
108
110
  if transform_into_get?(response)
@@ -126,22 +128,16 @@ module SAPOCI
126
128
  @options.fetch(:limit, FOLLOW_LIMIT)
127
129
  end
128
130
 
129
- def keep_cookies(env)
130
- cookies = @options.fetch(:cookies, [])
131
- response_cookies = env[:response_headers]['Set-Cookie'] #[:cookies]
132
- cookies == :all ? response_cookies : selected_request_cookies(response_cookies)
133
- end
134
-
135
- def selected_request_cookies(cookies)
136
- selected_cookies(cookies)[0...-1]
137
- end
138
-
139
- def selected_cookies(cookies)
140
- "".tap do |cookie_string|
141
- @options[:cookies].each do |cookie|
142
- string = /#{cookie}=?[^;]*/.match(cookies)[0] + ';'
143
- cookie_string << string
144
- end
131
+ def collect_cookies(env)
132
+ if response_cookies = env[:response_headers]['Set-Cookie']
133
+ @cookies = WEBrick::Cookie.parse_set_cookies(response_cookies)
134
+ @cookies.inject([]) do |result, cookie|
135
+ # TODO only send back cookies where path is nil or
136
+ # path matches according to env[:url]
137
+ result << cookie.name + "=" + cookie.value
138
+ end.uniq.join(";")
139
+ else
140
+ nil
145
141
  end
146
142
  end
147
143
 
metadata CHANGED
@@ -1,145 +1,150 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sapoci-connect
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 11
10
+ version: 0.1.11
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Oliver Eilhard
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-05-03 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-10-03 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: faraday
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 0.8.4
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 55
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 4
29
33
  version: 0.8.4
30
- - !ruby/object:Gem::Dependency
31
- name: rack
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 1.1.0
38
- - - <
39
- - !ruby/object:Gem::Version
40
- version: '2'
41
34
  type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rack
42
38
  prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
39
+ requirement: &id002 !ruby/object:Gem::Requirement
44
40
  none: false
45
- requirements:
46
- - - ! '>='
47
- - !ruby/object:Gem::Version
48
- version: 1.1.0
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 5
45
+ segments:
46
+ - 1
47
+ - 4
48
+ - 1
49
+ version: 1.4.1
49
50
  - - <
50
- - !ruby/object:Gem::Version
51
- version: '2'
52
- - !ruby/object:Gem::Dependency
53
- name: sapoci
54
- requirement: !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - ! '>='
58
- - !ruby/object:Gem::Version
59
- version: 0.1.8
51
+ - !ruby/object:Gem::Version
52
+ hash: 7
53
+ segments:
54
+ - 2
55
+ version: "2"
60
56
  type: :runtime
57
+ version_requirements: *id002
58
+ - !ruby/object:Gem::Dependency
59
+ name: sapoci
61
60
  prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
61
+ requirement: &id003 !ruby/object:Gem::Requirement
63
62
  none: false
64
- requirements:
65
- - - ! '>='
66
- - !ruby/object:Gem::Version
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 11
67
+ segments:
68
+ - 0
69
+ - 1
70
+ - 8
67
71
  version: 0.1.8
68
- - !ruby/object:Gem::Dependency
72
+ type: :runtime
73
+ version_requirements: *id003
74
+ - !ruby/object:Gem::Dependency
69
75
  name: bundler
70
- requirement: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: '1.0'
76
- type: :development
77
76
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ~>
82
- - !ruby/object:Gem::Version
83
- version: '1.0'
84
- - !ruby/object:Gem::Dependency
85
- name: rdoc
86
- requirement: !ruby/object:Gem::Requirement
77
+ requirement: &id004 !ruby/object:Gem::Requirement
87
78
  none: false
88
- requirements:
79
+ requirements:
89
80
  - - ~>
90
- - !ruby/object:Gem::Version
91
- version: '2.5'
81
+ - !ruby/object:Gem::Version
82
+ hash: 11
83
+ segments:
84
+ - 1
85
+ - 2
86
+ version: "1.2"
92
87
  type: :development
88
+ version_requirements: *id004
89
+ - !ruby/object:Gem::Dependency
90
+ name: rdoc
93
91
  prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
92
+ requirement: &id005 !ruby/object:Gem::Requirement
95
93
  none: false
96
- requirements:
94
+ requirements:
97
95
  - - ~>
98
- - !ruby/object:Gem::Version
99
- version: '2.5'
100
- - !ruby/object:Gem::Dependency
101
- name: rake
102
- requirement: !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ! '>='
106
- - !ruby/object:Gem::Version
107
- version: 0.9.2
96
+ - !ruby/object:Gem::Version
97
+ hash: 9
98
+ segments:
99
+ - 2
100
+ - 5
101
+ version: "2.5"
108
102
  type: :development
103
+ version_requirements: *id005
104
+ - !ruby/object:Gem::Dependency
105
+ name: rake
109
106
  prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
107
+ requirement: &id006 !ruby/object:Gem::Requirement
111
108
  none: false
112
- requirements:
113
- - - ! '>='
114
- - !ruby/object:Gem::Version
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 63
113
+ segments:
114
+ - 0
115
+ - 9
116
+ - 2
115
117
  version: 0.9.2
116
- - !ruby/object:Gem::Dependency
117
- name: sinatra
118
- requirement: !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ~>
122
- - !ruby/object:Gem::Version
123
- version: '1.2'
124
118
  type: :development
119
+ version_requirements: *id006
120
+ - !ruby/object:Gem::Dependency
121
+ name: sinatra
125
122
  prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
123
+ requirement: &id007 !ruby/object:Gem::Requirement
127
124
  none: false
128
- requirements:
125
+ requirements:
129
126
  - - ~>
130
- - !ruby/object:Gem::Version
131
- version: '1.2'
127
+ - !ruby/object:Gem::Version
128
+ hash: 25
129
+ segments:
130
+ - 1
131
+ - 3
132
+ - 1
133
+ version: 1.3.1
134
+ type: :development
135
+ version_requirements: *id007
132
136
  description: HTTP client library for working with SAP OCI compliant servers.
133
- email:
137
+ email:
134
138
  - oliver.eilhard@gmail.com
135
- executables:
139
+ executables:
136
140
  - sapoci-search
137
141
  extensions: []
138
- extra_rdoc_files:
142
+
143
+ extra_rdoc_files:
139
144
  - CHANGELOG.md
140
145
  - LICENSE
141
146
  - README.md
142
- files:
147
+ files:
143
148
  - bin/sapoci-search
144
149
  - lib/sapoci/connect.rb
145
150
  - lib/sapoci/connect/middleware/background_search.rb
@@ -149,27 +154,38 @@ files:
149
154
  - README.md
150
155
  homepage: http://github.com/meplato/sapoci-connect
151
156
  licenses: []
157
+
152
158
  post_install_message:
153
- rdoc_options:
159
+ rdoc_options:
154
160
  - --charset=UTF-8
155
- require_paths:
161
+ require_paths:
156
162
  - lib
157
- required_ruby_version: !ruby/object:Gem::Requirement
163
+ required_ruby_version: !ruby/object:Gem::Requirement
158
164
  none: false
159
- requirements:
160
- - - ! '>='
161
- - !ruby/object:Gem::Version
162
- version: '0'
163
- required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
173
  none: false
165
- requirements:
166
- - - ! '>='
167
- - !ruby/object:Gem::Version
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ hash: 23
178
+ segments:
179
+ - 1
180
+ - 3
181
+ - 6
168
182
  version: 1.3.6
169
183
  requirements: []
184
+
170
185
  rubyforge_project:
171
- rubygems_version: 1.8.23
186
+ rubygems_version: 1.8.24
172
187
  signing_key:
173
188
  specification_version: 3
174
189
  summary: HTTP client library for working with SAP OCI compliant servers.
175
190
  test_files: []
191
+