httpclient 2.1.5 → 2.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +85 -0
  3. data/bin/httpclient +77 -0
  4. data/bin/jsonclient +85 -0
  5. data/lib/hexdump.rb +50 -0
  6. data/lib/http-access2.rb +6 -4
  7. data/lib/httpclient/auth.rb +575 -173
  8. data/lib/httpclient/cacert.pem +3952 -0
  9. data/lib/httpclient/cacert1024.pem +3866 -0
  10. data/lib/httpclient/connection.rb +6 -2
  11. data/lib/httpclient/cookie.rb +162 -504
  12. data/lib/httpclient/http.rb +334 -119
  13. data/lib/httpclient/include_client.rb +85 -0
  14. data/lib/httpclient/jruby_ssl_socket.rb +588 -0
  15. data/lib/httpclient/session.rb +385 -288
  16. data/lib/httpclient/ssl_config.rb +195 -155
  17. data/lib/httpclient/ssl_socket.rb +150 -0
  18. data/lib/httpclient/timeout.rb +14 -10
  19. data/lib/httpclient/util.rb +142 -6
  20. data/lib/httpclient/version.rb +3 -0
  21. data/lib/httpclient/webagent-cookie.rb +459 -0
  22. data/lib/httpclient.rb +509 -202
  23. data/lib/jsonclient.rb +63 -0
  24. data/lib/oauthclient.rb +111 -0
  25. data/sample/async.rb +8 -0
  26. data/sample/auth.rb +11 -0
  27. data/sample/cookie.rb +18 -0
  28. data/sample/dav.rb +103 -0
  29. data/sample/howto.rb +49 -0
  30. data/sample/jsonclient.rb +67 -0
  31. data/sample/oauth_buzz.rb +57 -0
  32. data/sample/oauth_friendfeed.rb +59 -0
  33. data/sample/oauth_twitter.rb +61 -0
  34. data/sample/ssl/0cert.pem +22 -0
  35. data/sample/ssl/0key.pem +30 -0
  36. data/sample/ssl/1000cert.pem +19 -0
  37. data/sample/ssl/1000key.pem +18 -0
  38. data/sample/ssl/htdocs/index.html +10 -0
  39. data/sample/ssl/ssl_client.rb +22 -0
  40. data/sample/ssl/webrick_httpsd.rb +29 -0
  41. data/sample/stream.rb +21 -0
  42. data/sample/thread.rb +27 -0
  43. data/sample/wcat.rb +21 -0
  44. data/test/ca-chain.pem +44 -0
  45. data/test/ca.cert +23 -0
  46. data/test/client-pass.key +18 -0
  47. data/test/client.cert +19 -0
  48. data/test/client.key +15 -0
  49. data/test/helper.rb +131 -0
  50. data/test/htdigest +1 -0
  51. data/test/htpasswd +2 -0
  52. data/test/jruby_ssl_socket/test_pemutils.rb +32 -0
  53. data/test/runner.rb +2 -0
  54. data/test/server.cert +19 -0
  55. data/test/server.key +15 -0
  56. data/test/sslsvr.rb +65 -0
  57. data/test/subca.cert +21 -0
  58. data/test/test_auth.rb +492 -0
  59. data/test/test_cookie.rb +309 -0
  60. data/test/test_hexdump.rb +14 -0
  61. data/test/test_http-access2.rb +508 -0
  62. data/test/test_httpclient.rb +2145 -0
  63. data/test/test_include_client.rb +52 -0
  64. data/test/test_jsonclient.rb +80 -0
  65. data/test/test_ssl.rb +559 -0
  66. data/test/test_webagent-cookie.rb +465 -0
  67. metadata +85 -44
  68. data/lib/httpclient/auth.rb.orig +0 -513
  69. data/lib/httpclient/cacert.p7s +0 -1579
  70. data/lib/httpclient.rb.orig +0 -1020
  71. data/lib/tags +0 -908
@@ -1,562 +1,220 @@
1
- # cookie.rb is redistributed file which is originally included in Webagent
2
- # version 0.6.2 by TAKAHASHI `Maki' Masayoshi. And it contains some bug fixes.
3
- # You can download the entire package of Webagent from
4
- # http://www.rubycolor.org/arc/.
1
+ # do not override if httpclient/webagent-cookie is loaded already
2
+ unless defined?(HTTPClient::CookieManager)
3
+ begin # for catching LoadError and load webagent-cookie instead
5
4
 
5
+ require 'http-cookie'
6
+ require 'httpclient/util'
6
7
 
7
- # Cookie class
8
- #
9
- # I refered to w3m's source to make these classes. Some comments
10
- # are quoted from it. I'm thanksful for author(s) of it.
11
- #
12
- # w3m homepage: http://ei5nazha.yz.yamagata-u.ac.jp/~aito/w3m/eng/
13
-
14
- require 'uri'
15
- require 'time'
16
- require 'monitor'
17
-
18
- class WebAgent
19
-
20
- module CookieUtils
8
+ class HTTPClient
9
+ class CookieManager
10
+ include HTTPClient::Util
21
11
 
22
- def head_match?(str1, str2)
23
- str1 == str2[0, str1.length]
24
- end
12
+ attr_reader :format, :jar
13
+ attr_accessor :cookies_file
25
14
 
26
- def tail_match?(str1, str2)
27
- if str1.length > 0
28
- str1 == str2[-str1.length..-1].to_s
29
- else
30
- true
31
- end
15
+ def initialize(cookies_file = nil, format = WebAgentSaver, jar = HTTP::CookieJar.new)
16
+ @cookies_file = cookies_file
17
+ @format = format
18
+ @jar = jar
19
+ load_cookies if @cookies_file
20
+ end
21
+
22
+ def load_cookies
23
+ check_cookies_file
24
+ @jar.clear
25
+ @jar.load(@cookies_file, :format => @format)
26
+ end
27
+
28
+ def save_cookies(session = false)
29
+ check_cookies_file
30
+ @jar.save(@cookies_file, :format => @format, :session => session)
31
+ end
32
+
33
+ def cookies(uri = nil)
34
+ cookies = @jar.cookies(uri)
35
+ # TODO: return HTTP::Cookie in the future
36
+ cookies.map { |cookie|
37
+ WebAgent::Cookie.new(
38
+ :name => cookie.name,
39
+ :value => cookie.value,
40
+ :domain => cookie.domain,
41
+ :path => cookie.path,
42
+ :origin => cookie.origin,
43
+ :for_domain => cookie.for_domain,
44
+ :expires => cookie.expires,
45
+ :httponly => cookie.httponly,
46
+ :secure => cookie.secure
47
+ )
48
+ }
32
49
  end
33
50
 
34
- def domain_match(host, domain)
35
- domainname = domain.sub(/\.\z/, '').downcase
36
- hostname = host.sub(/\.\z/, '').downcase
37
- case domain
38
- when /\d+\.\d+\.\d+\.\d+/
39
- return (hostname == domainname)
40
- when '.'
41
- return true
42
- when /^\./
43
- # allows; host == rubyforge.org, domain == .rubyforge.org
44
- return tail_match?(domainname, '.' + hostname)
45
- else
46
- return (hostname == domainname)
51
+ def cookie_value(uri)
52
+ cookies = self.cookies(uri)
53
+ unless cookies.empty?
54
+ HTTP::Cookie.cookie_value(cookies)
47
55
  end
48
56
  end
49
57
 
50
- def total_dot_num(string)
51
- string.scan(/\./).length()
58
+ def parse(value, uri)
59
+ @jar.parse(value, uri)
52
60
  end
53
61
 
54
- end
55
-
56
- class Cookie
57
- include CookieUtils
58
-
59
- attr_accessor :name, :value
60
- attr_accessor :domain, :path
61
- attr_accessor :expires ## for Netscape Cookie
62
- attr_accessor :url
63
- attr_writer :use, :secure, :discard, :domain_orig, :path_orig, :override
64
-
65
- USE = 1
66
- SECURE = 2
67
- DOMAIN = 4
68
- PATH = 8
69
- DISCARD = 16
70
- OVERRIDE = 32
71
- OVERRIDE_OK = 32
72
-
73
- def initialize()
74
- @name = @value = @domain = @path = nil
75
- @expires = nil
76
- @url = nil
77
- @use = @secure = @discard = @domain_orig = @path_orig = @override = nil
78
- end
79
-
80
- def discard?
81
- @discard
82
- end
83
-
84
- def use?
85
- @use
86
- end
87
-
88
- def secure?
89
- @secure
90
- end
91
-
92
- def domain_orig?
93
- @domain_orig
94
- end
95
-
96
- def path_orig?
97
- @path_orig
62
+ def cookies=(cookies)
63
+ @jar.clear
64
+ cookies.each do |cookie|
65
+ add(cookie)
66
+ end
98
67
  end
99
68
 
100
- def override?
101
- @override
69
+ def add(cookie)
70
+ @jar.add(cookie)
102
71
  end
103
72
 
104
- def flag
105
- flg = 0
106
- flg += USE if @use
107
- flg += SECURE if @secure
108
- flg += DOMAIN if @domain_orig
109
- flg += PATH if @path_orig
110
- flg += DISCARD if @discard
111
- flg += OVERRIDE if @override
112
- flg
73
+ def find(uri)
74
+ warning('CookieManager#find is deprecated and will be removed in near future. Use HTTP::Cookie.cookie_value(CookieManager#cookies) instead')
75
+ if cookie = cookies(uri)
76
+ HTTP::Cookie.cookie_value(cookie)
77
+ end
113
78
  end
114
79
 
115
- def set_flag(flag)
116
- flag = flag.to_i
117
- @use = true if flag & USE > 0
118
- @secure = true if flag & SECURE > 0
119
- @domain_orig = true if flag & DOMAIN > 0
120
- @path_orig = true if flag & PATH > 0
121
- @discard = true if flag & DISCARD > 0
122
- @override = true if flag & OVERRIDE > 0
123
- end
80
+ private
124
81
 
125
- def match?(url)
126
- domainname = url.host
127
- if (!domainname ||
128
- !domain_match(domainname, @domain) ||
129
- (@path && !head_match?(@path, url.path)) ||
130
- (@secure && (url.scheme != 'https')) )
131
- return false
132
- else
133
- return true
82
+ def check_cookies_file
83
+ unless @cookies_file
84
+ raise ArgumentError.new('Cookies file not specified')
134
85
  end
135
86
  end
87
+ end
136
88
 
137
- def join_quotedstr(array, sep)
138
- ret = Array.new()
139
- old_elem = nil
140
- array.each{|elem|
141
- if (elem.scan(/"/).length % 2) == 0
142
- if old_elem
143
- old_elem << sep << elem
144
- else
145
- ret << elem
146
- old_elem = nil
147
- end
148
- else
149
- if old_elem
150
- old_elem << sep << elem
151
- ret << old_elem
152
- old_elem = nil
153
- else
154
- old_elem = elem.dup
155
- end
156
- end
157
- }
158
- ret
89
+ class WebAgentSaver < HTTP::CookieJar::AbstractSaver
90
+ # no option
91
+ def default_options
92
+ {}
159
93
  end
160
94
 
161
- def parse(str, url)
162
- @url = url
163
- # TODO: should not depend on join_quotedstr. scan with escape like CSV.
164
- cookie_elem = str.split(/;/)
165
- cookie_elem = join_quotedstr(cookie_elem, ';')
166
- cookie_elem -= [""] # del empty elements, a cookie might included ";;"
167
- first_elem = cookie_elem.shift
168
- if first_elem !~ /([^=]*)(\=(.*))?/
169
- return
170
- ## raise ArgumentError 'invalid cookie value'
171
- end
172
- @name = $1.strip
173
- @value = normalize_cookie_value($3)
174
- cookie_elem.each{|pair|
175
- key, value = pair.split(/=/, 2) ## value may nil
176
- key.strip!
177
- value = normalize_cookie_value(value)
178
- case key.downcase
179
- when 'domain'
180
- @domain = value
181
- when 'expires'
182
- @expires = nil
183
- begin
184
- @expires = Time.parse(value).gmtime() if value
185
- rescue ArgumentError
186
- end
187
- when 'path'
188
- @path = value
189
- when 'secure'
190
- @secure = true ## value may nil, but must 'true'.
191
- else
192
- ## ignore
193
- end
95
+ # same as HTTP::CookieJar::CookiestxtSaver
96
+ def save(io, jar)
97
+ jar.each { |cookie|
98
+ next if !@session && cookie.session?
99
+ io.print cookie_to_record(cookie)
194
100
  }
195
101
  end
196
102
 
197
- def normalize_cookie_value(value)
198
- if value
199
- value = value.strip.sub(/\A"(.*)"\z/) { $1 }
200
- value = nil if value.empty?
201
- end
202
- value
103
+ # same as HTTP::CookieJar::CookiestxtSaver
104
+ def load(io, jar)
105
+ io.each_line { |line|
106
+ cookie = parse_record(line) and jar.add(cookie)
107
+ }
203
108
  end
204
- private :normalize_cookie_value
205
- end
206
-
207
- class CookieManager
208
- include CookieUtils
209
109
 
210
- ### errors
211
- class Error < StandardError; end
212
- class ErrorOverrideOK < Error; end
213
- class SpecialError < Error; end
110
+ private
214
111
 
215
- attr_reader :cookies
216
- attr_accessor :cookies_file
217
- attr_accessor :accept_domains, :reject_domains
218
-
219
- # for conformance to http://wp.netscape.com/newsref/std/cookie_spec.html
220
- attr_accessor :netscape_rule
221
- SPECIAL_DOMAIN = [".com",".edu",".gov",".mil",".net",".org",".int"]
222
-
223
- def initialize(file=nil)
224
- @cookies = Array.new()
225
- @cookies.extend(MonitorMixin)
226
- @cookies_file = file
227
- @is_saved = true
228
- @reject_domains = Array.new()
229
- @accept_domains = Array.new()
230
- @netscape_rule = false
112
+ def cookie_to_record(cookie)
113
+ [
114
+ cookie.origin,
115
+ cookie.name,
116
+ cookie.value,
117
+ cookie.expires.to_i,
118
+ cookie.dot_domain,
119
+ cookie.path,
120
+ self.class.flag(cookie)
121
+ ].join("\t") + "\n"
231
122
  end
232
123
 
233
- def cookies=(cookies)
234
- @cookies = cookies
235
- @cookies.extend(MonitorMixin)
236
- end
124
+ def parse_record(line)
125
+ return nil if /\A#/ =~ line
126
+ col = line.chomp.split(/\t/)
237
127
 
238
- def save_all_cookies(force = nil, save_unused = true, save_discarded = true)
239
- @cookies.synchronize do
240
- check_expired_cookies()
241
- if @is_saved and !force
242
- return
243
- end
244
- File.open(@cookies_file, 'w') do |f|
245
- @cookies.each do |cookie|
246
- if (cookie.use? or save_unused) and
247
- (!cookie.discard? or save_discarded)
248
- f.print(cookie.url.to_s,"\t",
249
- cookie.name,"\t",
250
- cookie.value,"\t",
251
- cookie.expires.to_i,"\t",
252
- cookie.domain,"\t",
253
- cookie.path,"\t",
254
- cookie.flag,"\n")
255
- end
256
- end
257
- end
128
+ origin = col[0]
129
+ name = col[1]
130
+ value = col[2]
131
+ value.chomp!
132
+ if col[3].empty? or col[3] == '0'
133
+ expires = nil
134
+ else
135
+ expires = Time.at(col[3].to_i)
136
+ return nil if expires < Time.now
258
137
  end
259
- @is_saved = true
260
- end
138
+ domain = col[4]
139
+ path = col[5]
261
140
 
262
- def save_cookies(force = nil)
263
- save_all_cookies(force, false, false)
141
+ cookie = WebAgent::Cookie.new(name, value,
142
+ :origin => origin,
143
+ :domain => domain,
144
+ :path => path,
145
+ :expires => expires
146
+ )
147
+ self.class.set_flag(cookie, col[6].to_i)
148
+ cookie
264
149
  end
265
150
 
266
- def check_expired_cookies()
267
- @cookies.reject!{|cookie|
268
- is_expired = (cookie.expires && (cookie.expires < Time.now.gmtime))
269
- if is_expired && !cookie.discard?
270
- @is_saved = false
271
- end
272
- is_expired
273
- }
274
- end
151
+ USE = 1
152
+ SECURE = 2
153
+ DOMAIN = 4
154
+ PATH = 8
155
+ HTTP_ONLY = 64
275
156
 
276
- def parse(str, url)
277
- cookie = WebAgent::Cookie.new()
278
- cookie.parse(str, url)
279
- add(cookie)
157
+ def self.flag(cookie)
158
+ flg = 0
159
+ flg += USE # not used
160
+ flg += SECURE if cookie.secure?
161
+ flg += DOMAIN if cookie.for_domain?
162
+ flg += HTTP_ONLY if cookie.httponly?
163
+ flg += PATH if cookie.path # not used
164
+ flg
280
165
  end
281
166
 
282
- def make_cookie_str(cookie_list)
283
- if cookie_list.empty?
284
- return nil
285
- end
286
-
287
- ret = ''
288
- c = cookie_list.shift
289
- ret += "#{c.name}=#{c.value}"
290
- cookie_list.each{|cookie|
291
- ret += "; #{cookie.name}=#{cookie.value}"
292
- }
293
- return ret
167
+ def self.set_flag(cookie, flag)
168
+ cookie.secure = true if flag & SECURE > 0
169
+ cookie.for_domain = true if flag & DOMAIN > 0
170
+ cookie.httponly = true if flag & HTTP_ONLY > 0
294
171
  end
295
- private :make_cookie_str
172
+ end
173
+ end
296
174
 
175
+ # for backward compatibility
176
+ class WebAgent
177
+ CookieManager = ::HTTPClient::CookieManager
297
178
 
298
- def find(url)
299
- return nil if @cookies.empty?
179
+ class Cookie < HTTP::Cookie
180
+ include HTTPClient::Util
300
181
 
301
- cookie_list = Array.new()
302
- @cookies.each{|cookie|
303
- is_expired = (cookie.expires && (cookie.expires < Time.now.gmtime))
304
- if cookie.use? && !is_expired && cookie.match?(url)
305
- if cookie_list.select{|c1| c1.name == cookie.name}.empty?
306
- cookie_list << cookie
307
- end
308
- end
309
- }
310
- return make_cookie_str(cookie_list)
182
+ def url
183
+ deprecated('url', 'origin')
184
+ self.origin
311
185
  end
312
186
 
313
- def find_cookie_info(domain, path, name)
314
- @cookies.find{|c|
315
- c.domain == domain && c.path == path && c.name == name
316
- }
187
+ def url=(url)
188
+ deprecated('url=', 'origin=')
189
+ self.origin = url
317
190
  end
318
- private :find_cookie_info
319
191
 
320
- # not tested well; used only netscape_rule = true.
321
- def cookie_error(err, override)
322
- if !err.kind_of?(ErrorOverrideOK) || !override
323
- raise err
324
- end
192
+ def http_only?
193
+ deprecated('http_only?', 'httponly?')
194
+ self.httponly?
325
195
  end
326
- private :cookie_error
327
-
328
- def add(cookie)
329
- url = cookie.url
330
- name, value = cookie.name, cookie.value
331
- expires, domain, path =
332
- cookie.expires, cookie.domain, cookie.path
333
- secure, domain_orig, path_orig =
334
- cookie.secure?, cookie.domain_orig?, cookie.path_orig?
335
- discard, override =
336
- cookie.discard?, cookie.override?
337
-
338
- domainname = url.host
339
- domain_orig, path_orig = domain, path
340
- use_security = override
341
-
342
- if domain
343
-
344
- # [DRAFT 12] s. 4.2.2 (does not apply in the case that
345
- # host name is the same as domain attribute for version 0
346
- # cookie)
347
- # I think that this rule has almost the same effect as the
348
- # tail match of [NETSCAPE].
349
- if domain !~ /^\./ && domainname != domain
350
- domain = '.'+domain
351
- end
352
-
353
- # [NETSCAPE] rule
354
- if @netscape_rule
355
- n = total_dot_num(domain)
356
- if n < 2
357
- cookie_error(SpecialError.new(), override)
358
- elsif n == 2
359
- ## [NETSCAPE] rule
360
- ok = SPECIAL_DOMAIN.select{|sdomain|
361
- sdomain == domain[-(sdomain.length)..-1]
362
- }
363
- if ok.empty?
364
- cookie_error(SpecialError.new(), override)
365
- end
366
- end
367
- end
368
-
369
- # this implementation does not check RFC2109 4.3.2 case 2;
370
- # the portion of host not in domain does not contain a dot.
371
- # according to nsCookieService.cpp in Firefox 3.0.4, Firefox 3.0.4
372
- # and IE does not check, too.
373
- end
374
196
 
375
- path ||= url.path.sub(%r|/[^/]*|, '')
376
- domain ||= domainname
377
- @cookies.synchronize do
378
- cookie = find_cookie_info(domain, path, name)
379
- if !cookie
380
- cookie = WebAgent::Cookie.new()
381
- cookie.use = true
382
- @cookies << cookie
383
- end
384
- check_expired_cookies()
385
- end
197
+ alias original_domain domain
386
198
 
387
- cookie.url = url
388
- cookie.name = name
389
- cookie.value = value
390
- cookie.expires = expires
391
- cookie.domain = domain
392
- cookie.path = path
393
-
394
- ## for flag
395
- cookie.secure = secure
396
- cookie.domain_orig = domain_orig
397
- cookie.path_orig = path_orig
398
- if discard || cookie.expires == nil
399
- cookie.discard = true
400
- else
401
- cookie.discard = false
402
- @is_saved = false
403
- end
199
+ def domain
200
+ warning('Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.')
201
+ self.original_domain
404
202
  end
405
203
 
406
- def load_cookies()
407
- return if !File.readable?(@cookies_file)
408
- @cookies.synchronize do
409
- @cookies.clear
410
- File.open(@cookies_file,'r'){|f|
411
- while line = f.gets
412
- cookie = WebAgent::Cookie.new()
413
- @cookies << cookie
414
- col = line.chomp.split(/\t/)
415
- cookie.url = URI.parse(col[0])
416
- cookie.name = col[1]
417
- cookie.value = col[2]
418
- if col[3].empty? or col[3] == '0'
419
- cookie.expires = nil
420
- else
421
- cookie.expires = Time.at(col[3].to_i).gmtime
422
- end
423
- cookie.domain = col[4]
424
- cookie.path = col[5]
425
- cookie.set_flag(col[6])
426
- end
427
- }
428
- end
204
+ def flag
205
+ deprecated('flag', 'secure, for_domain, etc.')
206
+ HTTPClient::WebAgentSaver.flag(self)
429
207
  end
430
208
 
431
- def check_cookie_accept_domain(domain)
432
- unless domain
433
- return false
434
- end
435
- @accept_domains.each{|dom|
436
- if domain_match(domain, dom)
437
- return true
438
- end
439
- }
440
- @reject_domains.each{|dom|
441
- if domain_match(domain, dom)
442
- return false
443
- end
444
- }
445
- return true
209
+ private
210
+
211
+ def deprecated(old, new)
212
+ warning("WebAgent::Cookie is deprecated and will be replaced with HTTP::Cookie in the near future. Please use Cookie##{new} instead of Cookie##{old} for the replacement.")
446
213
  end
447
214
  end
448
215
  end
449
216
 
450
- __END__
451
-
452
- =begin
453
-
454
- == WebAgent::CookieManager Class
455
-
456
- Load, save, parse and send cookies.
457
-
458
- === Usage
459
-
460
- ## initialize
461
- cm = WebAgent::CookieManager.new("/home/foo/bar/cookie")
462
-
463
- ## load cookie data
464
- cm.load_cookies()
465
-
466
- ## parse cookie from string (maybe "Set-Cookie:" header)
467
- cm.parse(str)
468
-
469
- ## send cookie data to url
470
- f.write(cm.find(url))
471
-
472
- ## save cookie to cookiefile
473
- cm.save_cookies()
474
-
475
-
476
- === Class Methods
477
-
478
- -- CookieManager::new(file=nil)
479
-
480
- create new CookieManager. If a file is provided,
481
- use it as cookies' file.
482
-
483
- === Methods
484
-
485
- -- CookieManager#save_cookies(force = nil)
486
-
487
- save cookies' data into file. if argument is true,
488
- save data although data is not modified.
489
-
490
- -- CookieManager#parse(str, url)
491
-
492
- parse string and store cookie (to parse HTTP response header).
493
-
494
- -- CookieManager#find(url)
495
-
496
- get cookies and make into string (to send as HTTP request header).
497
-
498
- -- CookieManager#add(cookie)
499
-
500
- add new cookie.
501
-
502
- -- CookieManager#load_cookies()
503
-
504
- load cookies' data from file.
505
-
506
-
507
- == WebAgent::CookieUtils Module
508
-
509
- -- CookieUtils::head_match?(str1, str2)
510
- -- CookieUtils::tail_match?(str1, str2)
511
- -- CookieUtils::domain_match(host, domain)
512
- -- CookieUtils::total_dot_num(str)
513
-
514
-
515
- == WebAgent::Cookie Class
516
-
517
- === Class Methods
518
-
519
- -- Cookie::new()
520
-
521
- create new cookie.
522
-
523
- === Methods
524
-
525
- -- Cookie#match?(url)
526
-
527
- match cookie by url. if match, return true. otherwise,
528
- return false.
529
-
530
- -- Cookie#name
531
- -- Cookie#name=(name)
532
- -- Cookie#value
533
- -- Cookie#value=(value)
534
- -- Cookie#domain
535
- -- Cookie#domain=(domain)
536
- -- Cookie#path
537
- -- Cookie#path=(path)
538
- -- Cookie#expires
539
- -- Cookie#expires=(expires)
540
- -- Cookie#url
541
- -- Cookie#url=(url)
542
-
543
- accessor methods for cookie's items.
544
-
545
- -- Cookie#discard?
546
- -- Cookie#discard=(discard)
547
- -- Cookie#use?
548
- -- Cookie#use=(use)
549
- -- Cookie#secure?
550
- -- Cookie#secure=(secure)
551
- -- Cookie#domain_orig?
552
- -- Cookie#domain_orig=(domain_orig)
553
- -- Cookie#path_orig?
554
- -- Cookie#path_orig=(path_orig)
555
- -- Cookie#override?
556
- -- Cookie#override=(override)
557
- -- Cookie#flag
558
- -- Cookie#set_flag(flag_num)
559
-
560
- accessor methods for flags.
561
-
562
- =end
217
+ rescue LoadError
218
+ require 'httpclient/webagent-cookie'
219
+ end
220
+ end