httpclient 2.5.3.1 → 2.5.3.2

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: c825be1948756d9856d5cd4546538e259d9f2c50
4
- data.tar.gz: e93d9f59d953cc2c4e2b11f437e0ef54fcda7942
3
+ metadata.gz: 2ed970a9f9a678a4e9ffc7db66c03b06c1a6ca55
4
+ data.tar.gz: cb2835e9852021421d95449c0551679c6533571d
5
5
  SHA512:
6
- metadata.gz: b3f335e8bd447c2886ab599c8271623e636e0cc368f439ac961606e4ed71481ea9467cffed271f91f187e850cecd071872c578b3c3d4c866bf38186b1d6a47fc
7
- data.tar.gz: 0daf288fb6105cf9b96bd3d0663bfa1dc3e083707583fcf4f9a33c45e8fe186b355073ed643064769cdd7362ee27fb89cb47bad912c5fd5ba2cc752206191b2f
6
+ metadata.gz: 1329315ea58bed3ccadd8172b06b1556f63ad2e1d6582ad81ac749717ab68bffc41c0bff83e72df8c3f99c5a9823eee5f28ee9ee6b06e5ae829fa4a8ffd69cd1
7
+ data.tar.gz: 2e23832e6b2a0aef542f76887c2f5f488218b4c721e58b94b8c828e58b11ec1fca7384c2022d3ccaa77e0ef8a43d6eed3eade51c913d68c846e8c81cc42741d1
@@ -958,7 +958,7 @@ private
958
958
  body.pos = pos if pos
959
959
  req = create_request(method, uri, query, body, header)
960
960
  begin
961
- protect_keep_alive_disconnected(req) do
961
+ protect_keep_alive_disconnected do
962
962
  do_get_block(req, proxy, conn, &block)
963
963
  end
964
964
  res = conn.pop
@@ -984,7 +984,7 @@ private
984
984
  body.pos = pos if pos
985
985
  req = create_request(method, uri, query, body, header)
986
986
  begin
987
- protect_keep_alive_disconnected(req) do
987
+ protect_keep_alive_disconnected do
988
988
  do_get_stream(req, proxy, tconn)
989
989
  end
990
990
  break
@@ -1054,14 +1054,14 @@ private
1054
1054
  end
1055
1055
  end
1056
1056
 
1057
- def protect_keep_alive_disconnected(req)
1057
+ def protect_keep_alive_disconnected
1058
1058
  begin
1059
1059
  yield
1060
1060
  rescue KeepAliveDisconnected => e
1061
1061
  if e.sess
1062
1062
  @session_manager.invalidate(e.sess.dest)
1063
1063
  end
1064
- yield if req.use_persistent_connection?
1064
+ yield
1065
1065
  end
1066
1066
  end
1067
1067
 
@@ -25,9 +25,9 @@ class WebAgent
25
25
 
26
26
  def tail_match?(str1, str2)
27
27
  if str1.length > 0
28
- str1 == str2[-str1.length..-1].to_s
28
+ str1 == str2[-str1.length..-1].to_s
29
29
  else
30
- true
30
+ true
31
31
  end
32
32
  end
33
33
 
@@ -37,14 +37,14 @@ class WebAgent
37
37
  hostname = host.sub(/\.\z/, '').downcase
38
38
  case domain
39
39
  when /\d+\.\d+\.\d+\.\d+/
40
- return (hostname == domainname)
41
- when '.'
42
- return true
40
+ return (hostname == domainname)
41
+ when '.'
42
+ return true
43
43
  when /^\./
44
44
  # allows; host == rubyforge.org, domain == .rubyforge.org
45
- return tail_match?(domainname, '.' + hostname)
45
+ return tail_match?(domainname, '.' + hostname)
46
46
  else
47
- return (hostname == domainname)
47
+ return (hostname == domainname)
48
48
  end
49
49
  end
50
50
  end
@@ -128,12 +128,12 @@ class WebAgent
128
128
  def match?(url)
129
129
  domainname = url.host
130
130
  if (!domainname ||
131
- !domain_match(domainname, @domain) ||
132
- (@path && !head_match?(@path, url.path.empty? ? '/' : url.path)) ||
133
- (@secure && (url.scheme != 'https')) )
134
- return false
131
+ !domain_match(domainname, @domain) ||
132
+ (@path && !head_match?(@path, url.path.empty? ? '/' : url.path)) ||
133
+ (@secure && (url.scheme != 'https')) )
134
+ return false
135
135
  else
136
- return true
136
+ return true
137
137
  end
138
138
  end
139
139
 
@@ -141,22 +141,22 @@ class WebAgent
141
141
  ret = Array.new
142
142
  old_elem = nil
143
143
  array.each{|elem|
144
- if (elem.scan(/"/).length % 2) == 0
145
- if old_elem
146
- old_elem << sep << elem
147
- else
148
- ret << elem
149
- old_elem = nil
150
- end
151
- else
152
- if old_elem
153
- old_elem << sep << elem
154
- ret << old_elem
155
- old_elem = nil
156
- else
157
- old_elem = elem.dup
158
- end
159
- end
144
+ if (elem.scan(/"/).length % 2) == 0
145
+ if old_elem
146
+ old_elem << sep << elem
147
+ else
148
+ ret << elem
149
+ old_elem = nil
150
+ end
151
+ else
152
+ if old_elem
153
+ old_elem << sep << elem
154
+ ret << old_elem
155
+ old_elem = nil
156
+ else
157
+ old_elem = elem.dup
158
+ end
159
+ end
160
160
  }
161
161
  ret
162
162
  end
@@ -169,37 +169,37 @@ class WebAgent
169
169
  cookie_elem -= [""] # del empty elements, a cookie might included ";;"
170
170
  first_elem = cookie_elem.shift
171
171
  if first_elem !~ /([^=]*)(\=(.*))?/
172
- return
173
- ## raise ArgumentError 'invalid cookie value'
172
+ return
173
+ ## raise ArgumentError 'invalid cookie value'
174
174
  end
175
175
  @name = $1.strip
176
176
  @value = normalize_cookie_value($3)
177
177
  cookie_elem.each{|pair|
178
- key, value = pair.split(/=/, 2) ## value may nil
179
- key.strip!
178
+ key, value = pair.split(/=/, 2) ## value may nil
179
+ key.strip!
180
180
  value = normalize_cookie_value(value)
181
- case key.downcase
182
- when 'domain'
183
- @domain = value
184
- when 'expires'
181
+ case key.downcase
182
+ when 'domain'
183
+ @domain = value
184
+ when 'expires'
185
185
  @expires = nil
186
- begin
187
- @expires = Time.parse(value).gmtime if value
188
- rescue ArgumentError
189
- end
190
- when 'path'
191
- @path = value
192
- when 'secure'
193
- @secure = true ## value may nil, but must 'true'.
194
- when 'httponly'
195
- @http_only = true ## value may nil, but must 'true'.
196
- else
186
+ begin
187
+ @expires = Time.parse(value).gmtime if value
188
+ rescue ArgumentError
189
+ end
190
+ when 'path'
191
+ @path = value
192
+ when 'secure'
193
+ @secure = true ## value may nil, but must 'true'.
194
+ when 'httponly'
195
+ @http_only = true ## value may nil, but must 'true'.
196
+ else
197
197
  warn("Unknown key: #{key} = #{value}")
198
- end
198
+ end
199
199
  }
200
200
  end
201
201
 
202
- private
202
+ private
203
203
 
204
204
  def normalize_cookie_value(value)
205
205
  if value
@@ -210,6 +210,13 @@ class WebAgent
210
210
  end
211
211
  end
212
212
 
213
+ ##
214
+ # An Array class that already includes the MonitorMixin module.
215
+ #
216
+ class SynchronizedArray < Array
217
+ include MonitorMixin
218
+ end
219
+
213
220
  class CookieManager
214
221
  include CookieUtils
215
222
 
@@ -223,8 +230,7 @@ class WebAgent
223
230
  attr_accessor :accept_domains, :reject_domains
224
231
 
225
232
  def initialize(file=nil)
226
- @cookies = Array.new
227
- @cookies.extend(MonitorMixin)
233
+ @cookies = SynchronizedArray.new
228
234
  @cookies_file = file
229
235
  @is_saved = true
230
236
  @reject_domains = Array.new
@@ -233,8 +239,11 @@ class WebAgent
233
239
  end
234
240
 
235
241
  def cookies=(cookies)
236
- @cookies = cookies
237
- @cookies.extend(MonitorMixin)
242
+ if cookies.is_a?(SynchronizedArray)
243
+ @cookies = cookies
244
+ else
245
+ @cookies = SynchronizedArray.new(cookies)
246
+ end
238
247
  end
239
248
 
240
249
  def save_all_cookies(force = nil, save_unused = true, save_discarded = true)
@@ -246,7 +255,7 @@ class WebAgent
246
255
  File.open(@cookies_file, 'w') do |f|
247
256
  @cookies.each do |cookie|
248
257
  if (cookie.use? or save_unused) and
249
- (!cookie.discard? or save_discarded)
258
+ (!cookie.discard? or save_discarded)
250
259
  f.print(cookie.url.to_s,"\t",
251
260
  cookie.name,"\t",
252
261
  cookie.value,"\t",
@@ -327,10 +336,10 @@ class WebAgent
327
336
  cookie.path_orig = given.path
328
337
 
329
338
  if cookie.discard? || cookie.expires == nil
330
- cookie.discard = true
339
+ cookie.discard = true
331
340
  else
332
- cookie.discard = false
333
- @is_saved = false
341
+ cookie.discard = false
342
+ @is_saved = false
334
343
  end
335
344
  end
336
345
 
@@ -362,33 +371,33 @@ class WebAgent
362
371
  # Who use it?
363
372
  def check_cookie_accept_domain(domain)
364
373
  unless domain
365
- return false
374
+ return false
366
375
  end
367
376
  @accept_domains.each{|dom|
368
- if domain_match(domain, dom)
369
- return true
370
- end
377
+ if domain_match(domain, dom)
378
+ return true
379
+ end
371
380
  }
372
381
  @reject_domains.each{|dom|
373
- if domain_match(domain, dom)
374
- return false
375
- end
382
+ if domain_match(domain, dom)
383
+ return false
384
+ end
376
385
  }
377
386
  return true
378
387
  end
379
388
 
380
- private
389
+ private
381
390
 
382
391
  def make_cookie_str(cookie_list)
383
392
  if cookie_list.empty?
384
- return nil
393
+ return nil
385
394
  end
386
395
 
387
396
  ret = ''
388
397
  c = cookie_list.shift
389
398
  ret += "#{c.name}=#{c.value}"
390
399
  cookie_list.each{|cookie|
391
- ret += "; #{cookie.name}=#{cookie.value}"
400
+ ret += "; #{cookie.name}=#{cookie.value}"
392
401
  }
393
402
  return ret
394
403
  end
@@ -432,7 +441,7 @@ class WebAgent
432
441
  # not tested well; used only netscape_rule = true.
433
442
  def cookie_error(err, override)
434
443
  if !err.kind_of?(ErrorOverrideOK) || !override
435
- raise err
444
+ raise err
436
445
  end
437
446
  end
438
447
  end
@@ -1043,10 +1043,6 @@ module HTTP
1043
1043
  def see_other?
1044
1044
  status == HTTP::Status::SEE_OTHER
1045
1045
  end
1046
-
1047
- def use_persistent_connection?
1048
- header.request_method != 'POST' && header.request_method != 'PUT'
1049
- end
1050
1046
  end
1051
1047
 
1052
1048
  end
@@ -200,7 +200,7 @@ class HTTPClient
200
200
  # each session.
201
201
  def get_session(req, via_proxy = false)
202
202
  site = Site.new(req.header.request_uri)
203
- if req.use_persistent_connection? && cached = get_cached_session(site)
203
+ if cached = get_cached_session(site)
204
204
  cached
205
205
  else
206
206
  open(req.header.request_uri, via_proxy)
@@ -1,3 +1,3 @@
1
1
  class HTTPClient
2
- VERSION = '2.5.3.1'
2
+ VERSION = '2.5.3.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3.1
4
+ version: 2.5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: nahi@ruby-lang.org