httpclient 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/http-access2.rb +1 -2
- data/lib/httpclient.rb +631 -1832
- data/lib/httpclient/auth.rb +510 -0
- data/lib/httpclient/connection.rb +84 -0
- data/lib/httpclient/cookie.rb +82 -71
- data/lib/httpclient/http.rb +726 -484
- data/lib/httpclient/session.rb +855 -0
- data/lib/httpclient/ssl_config.rb +379 -0
- data/lib/httpclient/timeout.rb +122 -0
- data/lib/httpclient/util.rb +86 -0
- metadata +50 -37
@@ -0,0 +1,86 @@
|
|
1
|
+
# HTTPClient - HTTP client library.
|
2
|
+
# Copyright (C) 2000-2008 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
#
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
|
9
|
+
require 'uri'
|
10
|
+
|
11
|
+
|
12
|
+
class HTTPClient
|
13
|
+
|
14
|
+
|
15
|
+
# A module for common function.
|
16
|
+
module Util
|
17
|
+
# Keyword argument helper.
|
18
|
+
# args:: given arguments.
|
19
|
+
# *field:: a list of arguments to be extracted.
|
20
|
+
#
|
21
|
+
# You can extract 3 arguments (a, b, c) with:
|
22
|
+
#
|
23
|
+
# include Util
|
24
|
+
# def my_method(*args)
|
25
|
+
# a, b, c = keyword_argument(args, :a, :b, :c)
|
26
|
+
# ...
|
27
|
+
# end
|
28
|
+
# my_method(1, 2, 3)
|
29
|
+
# my_method(:b => 2, :a = 1)
|
30
|
+
#
|
31
|
+
# instead of;
|
32
|
+
#
|
33
|
+
# def my_method(a, b, c)
|
34
|
+
# ...
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
def keyword_argument(args, *field)
|
38
|
+
if args.size == 1 and args[0].is_a?(Hash)
|
39
|
+
args[0].values_at(*field)
|
40
|
+
else
|
41
|
+
args
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Gets an URI instance.
|
46
|
+
def urify(uri)
|
47
|
+
if uri.nil?
|
48
|
+
nil
|
49
|
+
elsif uri.is_a?(URI)
|
50
|
+
uri
|
51
|
+
else
|
52
|
+
URI.parse(uri.to_s)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns true if the given 2 URIs have a part_of relationship.
|
57
|
+
# * the same scheme
|
58
|
+
# * the same host String (no host resolution or IP-addr conversion)
|
59
|
+
# * the same port number
|
60
|
+
# * target URI's path starts with base URI's path.
|
61
|
+
def uri_part_of(uri, part)
|
62
|
+
((uri.scheme == part.scheme) and
|
63
|
+
(uri.host == part.host) and
|
64
|
+
(uri.port == part.port) and
|
65
|
+
uri.path.upcase.index(part.path.upcase) == 0)
|
66
|
+
end
|
67
|
+
module_function :uri_part_of
|
68
|
+
|
69
|
+
# Returns parent directory URI of the given URI.
|
70
|
+
def uri_dirname(uri)
|
71
|
+
uri = uri.clone
|
72
|
+
uri.path = uri.path.sub(/\/[^\/]*\z/, '/')
|
73
|
+
uri
|
74
|
+
end
|
75
|
+
module_function :uri_dirname
|
76
|
+
|
77
|
+
# Finds a value of a Hash.
|
78
|
+
def hash_find_value(hash, &block)
|
79
|
+
v = hash.find(&block)
|
80
|
+
v ? v[1] : nil
|
81
|
+
end
|
82
|
+
module_function :hash_find_value
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
metadata
CHANGED
@@ -1,54 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: httpclient
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 2.1.
|
7
|
-
date: 2007-09-22 00:00:00 +09:00
|
8
|
-
summary: gives something like the functionality of libwww-perl (LWP) in Ruby
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: nahi@ruby-lang.org
|
12
|
-
homepage: http://dev.ctor.org/httpclient
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 2.1.3
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- NAKAMURA, Hiroshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-29 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: nahi@ruby-lang.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
31
24
|
files:
|
32
|
-
- lib/httpclient.rb
|
33
|
-
- lib/http-access2.rb
|
34
25
|
- lib/httpclient
|
26
|
+
- lib/httpclient/cookie.rb
|
27
|
+
- lib/httpclient/ssl_config.rb
|
28
|
+
- lib/httpclient/auth.rb
|
35
29
|
- lib/httpclient/cacert.p7s
|
36
30
|
- lib/httpclient/http.rb
|
37
|
-
- lib/httpclient/
|
31
|
+
- lib/httpclient/session.rb
|
32
|
+
- lib/httpclient/timeout.rb
|
33
|
+
- lib/httpclient/connection.rb
|
34
|
+
- lib/httpclient/util.rb
|
38
35
|
- lib/http-access2
|
39
|
-
- lib/http-access2/http.rb
|
40
36
|
- lib/http-access2/cookie.rb
|
41
|
-
|
42
|
-
|
37
|
+
- lib/http-access2/http.rb
|
38
|
+
- lib/httpclient.rb
|
39
|
+
- lib/http-access2.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://dev.ctor.org/httpclient
|
42
|
+
post_install_message:
|
43
43
|
rdoc_options: []
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
51
59
|
requirements: []
|
52
60
|
|
53
|
-
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.3.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 2
|
65
|
+
summary: gives something like the functionality of libwww-perl (LWP) in Ruby
|
66
|
+
test_files: []
|
54
67
|
|