httpclient-fixcerts 2.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +98 -0
- data/bin/httpclient +77 -0
- data/bin/jsonclient +85 -0
- data/lib/hexdump.rb +50 -0
- data/lib/http-access2/cookie.rb +1 -0
- data/lib/http-access2/http.rb +1 -0
- data/lib/http-access2.rb +55 -0
- data/lib/httpclient/auth.rb +924 -0
- data/lib/httpclient/cacert.pem +3952 -0
- data/lib/httpclient/cacert1024.pem +3866 -0
- data/lib/httpclient/connection.rb +88 -0
- data/lib/httpclient/cookie.rb +220 -0
- data/lib/httpclient/http.rb +1082 -0
- data/lib/httpclient/include_client.rb +85 -0
- data/lib/httpclient/jruby_ssl_socket.rb +594 -0
- data/lib/httpclient/session.rb +960 -0
- data/lib/httpclient/ssl_config.rb +433 -0
- data/lib/httpclient/ssl_socket.rb +150 -0
- data/lib/httpclient/timeout.rb +140 -0
- data/lib/httpclient/util.rb +222 -0
- data/lib/httpclient/version.rb +3 -0
- data/lib/httpclient/webagent-cookie.rb +459 -0
- data/lib/httpclient.rb +1332 -0
- data/lib/jsonclient.rb +66 -0
- data/lib/oauthclient.rb +111 -0
- data/sample/async.rb +8 -0
- data/sample/auth.rb +11 -0
- data/sample/cookie.rb +18 -0
- data/sample/dav.rb +103 -0
- data/sample/howto.rb +49 -0
- data/sample/jsonclient.rb +67 -0
- data/sample/oauth_buzz.rb +57 -0
- data/sample/oauth_friendfeed.rb +59 -0
- data/sample/oauth_twitter.rb +61 -0
- data/sample/ssl/0cert.pem +22 -0
- data/sample/ssl/0key.pem +30 -0
- data/sample/ssl/1000cert.pem +19 -0
- data/sample/ssl/1000key.pem +18 -0
- data/sample/ssl/htdocs/index.html +10 -0
- data/sample/ssl/ssl_client.rb +22 -0
- data/sample/ssl/webrick_httpsd.rb +29 -0
- data/sample/stream.rb +21 -0
- data/sample/thread.rb +27 -0
- data/sample/wcat.rb +21 -0
- data/test/ca-chain.pem +44 -0
- data/test/ca.cert +23 -0
- data/test/client-pass.key +18 -0
- data/test/client.cert +19 -0
- data/test/client.key +15 -0
- data/test/helper.rb +131 -0
- data/test/htdigest +1 -0
- data/test/htpasswd +2 -0
- data/test/jruby_ssl_socket/test_pemutils.rb +32 -0
- data/test/runner.rb +2 -0
- data/test/server.cert +19 -0
- data/test/server.key +15 -0
- data/test/sslsvr.rb +65 -0
- data/test/subca.cert +21 -0
- data/test/test_auth.rb +492 -0
- data/test/test_cookie.rb +309 -0
- data/test/test_hexdump.rb +14 -0
- data/test/test_http-access2.rb +508 -0
- data/test/test_httpclient.rb +2145 -0
- data/test/test_include_client.rb +52 -0
- data/test/test_jsonclient.rb +98 -0
- data/test/test_ssl.rb +562 -0
- data/test/test_webagent-cookie.rb +465 -0
- metadata +124 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('helper', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'httpclient/include_client'
|
5
|
+
class TestIncludeClient < Test::Unit::TestCase
|
6
|
+
class Widget
|
7
|
+
extend HTTPClient::IncludeClient
|
8
|
+
|
9
|
+
include_http_client("http://example.com") do |client|
|
10
|
+
client.cookie_manager = nil
|
11
|
+
client.agent_name = "iMonkey 4k"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class OtherWidget
|
16
|
+
extend HTTPClient::IncludeClient
|
17
|
+
|
18
|
+
include_http_client
|
19
|
+
include_http_client(:method_name => :other_http_client)
|
20
|
+
end
|
21
|
+
|
22
|
+
class UnrelatedBlankClass ; end
|
23
|
+
|
24
|
+
def test_client_class_level_singleton
|
25
|
+
assert_equal Widget.http_client.object_id, Widget.http_client.object_id
|
26
|
+
|
27
|
+
assert_equal Widget.http_client.object_id, Widget.new.http_client.object_id
|
28
|
+
|
29
|
+
assert_not_equal Widget.http_client.object_id, OtherWidget.http_client.object_id
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_configured
|
33
|
+
assert_equal Widget.http_client.agent_name, "iMonkey 4k"
|
34
|
+
assert_nil Widget.http_client.cookie_manager
|
35
|
+
assert_equal Widget.http_client.proxy.to_s, "http://example.com"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_two_includes
|
39
|
+
assert_not_equal OtherWidget.http_client.object_id, OtherWidget.other_http_client.object_id
|
40
|
+
|
41
|
+
assert_equal OtherWidget.other_http_client.object_id, OtherWidget.new.other_http_client.object_id
|
42
|
+
end
|
43
|
+
|
44
|
+
# meta-programming gone wrong sometimes accidentally
|
45
|
+
# adds the class method to _everyone_, a mistake we've made before.
|
46
|
+
def test_not_infected_class_hieararchy
|
47
|
+
assert ! Class.respond_to?(:http_client)
|
48
|
+
assert ! UnrelatedBlankClass.respond_to?(:http_client)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('helper', File.dirname(__FILE__))
|
3
|
+
require 'jsonclient'
|
4
|
+
|
5
|
+
|
6
|
+
class TestJSONClient < Test::Unit::TestCase
|
7
|
+
include Helper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
setup_server
|
12
|
+
@client = JSONClient.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_post
|
20
|
+
res = @client.post(serverurl + 'json', {'a' => 1, 'b' => {'c' => 2}})
|
21
|
+
assert_equal(2, res.content['b']['c'])
|
22
|
+
assert_equal('application/json; charset=utf-8', res.content_type)
|
23
|
+
# #previous contains the original response
|
24
|
+
assert_equal(1, JSON.parse(res.previous.content)['a'])
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_post_with_array
|
28
|
+
res = @client.post(serverurl + 'json', [{'a' => 1, 'b' => {'c' => 2}}])
|
29
|
+
assert_equal(2, res.content[0]['b']['c'])
|
30
|
+
assert_equal('application/json; charset=utf-8', res.content_type)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_post_with_header
|
34
|
+
res = @client.post(serverurl + 'json', :header => {'X-foo' => 'bar'}, :body => {'a' => 1, 'b' => {'c' => 2}})
|
35
|
+
assert_equal(2, res.content['b']['c'])
|
36
|
+
assert_equal('application/json; charset=utf-8', res.content_type)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_post_with_array_header
|
40
|
+
res = @client.post(serverurl + 'json', :header => [['X-foo', 'bar']], :body => {'a' => 1, 'b' => {'c' => 2}})
|
41
|
+
assert_equal(2, res.content['b']['c'])
|
42
|
+
assert_equal('application/json; charset=utf-8', res.content_type)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_post_non_json_body
|
46
|
+
res = @client.post(serverurl + 'json', 'a=b&c=d')
|
47
|
+
assert_equal('a=b&c=d', res.content)
|
48
|
+
assert_equal('application/x-www-form-urlencoded', res.content_type)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_put
|
52
|
+
res = @client.put(serverurl + 'json', {'a' => 1, 'b' => {'c' => 2}})
|
53
|
+
assert_equal(2, res.content['b']['c'])
|
54
|
+
assert_equal('application/json; charset=utf-8', res.content_type)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_get_not_affected
|
58
|
+
res = @client.get(serverurl + 'json', {'a' => 1, 'b' => {'c' => 2}})
|
59
|
+
assert_equal('', res.content)
|
60
|
+
assert_equal('', res.content_type)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_hash_header_not_modified
|
64
|
+
header = {'X-foo' => 'bar'}
|
65
|
+
_res = @client.post(serverurl, :header => header, :body => {'a' => 1, 'b' => {'c' => 2}})
|
66
|
+
assert_equal({'X-foo' => 'bar'}, header)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_array_header_not_modified
|
70
|
+
header = [['X-foo', 'bar']]
|
71
|
+
_res = @client.post(serverurl, :header => header, :body => {'a' => 1, 'b' => {'c' => 2}})
|
72
|
+
assert_equal([['X-foo', 'bar']], header)
|
73
|
+
end
|
74
|
+
|
75
|
+
class JSONServlet < WEBrick::HTTPServlet::AbstractServlet
|
76
|
+
def get_instance(*arg)
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
def service(req, res)
|
81
|
+
res['content-type'] = req['content-type']
|
82
|
+
res.body = req.body
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def setup_server
|
87
|
+
@server = WEBrick::HTTPServer.new(
|
88
|
+
:BindAddress => "localhost",
|
89
|
+
:Logger => @logger,
|
90
|
+
:Port => 0,
|
91
|
+
:AccessLog => [],
|
92
|
+
:DocumentRoot => File.dirname(File.expand_path(__FILE__))
|
93
|
+
)
|
94
|
+
@serverport = @server.config[:Port]
|
95
|
+
@server.mount('/json', JSONServlet.new(@server))
|
96
|
+
@server_thread = start_server_thread(@server)
|
97
|
+
end
|
98
|
+
end
|