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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +98 -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/cookie.rb +1 -0
  7. data/lib/http-access2/http.rb +1 -0
  8. data/lib/http-access2.rb +55 -0
  9. data/lib/httpclient/auth.rb +924 -0
  10. data/lib/httpclient/cacert.pem +3952 -0
  11. data/lib/httpclient/cacert1024.pem +3866 -0
  12. data/lib/httpclient/connection.rb +88 -0
  13. data/lib/httpclient/cookie.rb +220 -0
  14. data/lib/httpclient/http.rb +1082 -0
  15. data/lib/httpclient/include_client.rb +85 -0
  16. data/lib/httpclient/jruby_ssl_socket.rb +594 -0
  17. data/lib/httpclient/session.rb +960 -0
  18. data/lib/httpclient/ssl_config.rb +433 -0
  19. data/lib/httpclient/ssl_socket.rb +150 -0
  20. data/lib/httpclient/timeout.rb +140 -0
  21. data/lib/httpclient/util.rb +222 -0
  22. data/lib/httpclient/version.rb +3 -0
  23. data/lib/httpclient/webagent-cookie.rb +459 -0
  24. data/lib/httpclient.rb +1332 -0
  25. data/lib/jsonclient.rb +66 -0
  26. data/lib/oauthclient.rb +111 -0
  27. data/sample/async.rb +8 -0
  28. data/sample/auth.rb +11 -0
  29. data/sample/cookie.rb +18 -0
  30. data/sample/dav.rb +103 -0
  31. data/sample/howto.rb +49 -0
  32. data/sample/jsonclient.rb +67 -0
  33. data/sample/oauth_buzz.rb +57 -0
  34. data/sample/oauth_friendfeed.rb +59 -0
  35. data/sample/oauth_twitter.rb +61 -0
  36. data/sample/ssl/0cert.pem +22 -0
  37. data/sample/ssl/0key.pem +30 -0
  38. data/sample/ssl/1000cert.pem +19 -0
  39. data/sample/ssl/1000key.pem +18 -0
  40. data/sample/ssl/htdocs/index.html +10 -0
  41. data/sample/ssl/ssl_client.rb +22 -0
  42. data/sample/ssl/webrick_httpsd.rb +29 -0
  43. data/sample/stream.rb +21 -0
  44. data/sample/thread.rb +27 -0
  45. data/sample/wcat.rb +21 -0
  46. data/test/ca-chain.pem +44 -0
  47. data/test/ca.cert +23 -0
  48. data/test/client-pass.key +18 -0
  49. data/test/client.cert +19 -0
  50. data/test/client.key +15 -0
  51. data/test/helper.rb +131 -0
  52. data/test/htdigest +1 -0
  53. data/test/htpasswd +2 -0
  54. data/test/jruby_ssl_socket/test_pemutils.rb +32 -0
  55. data/test/runner.rb +2 -0
  56. data/test/server.cert +19 -0
  57. data/test/server.key +15 -0
  58. data/test/sslsvr.rb +65 -0
  59. data/test/subca.cert +21 -0
  60. data/test/test_auth.rb +492 -0
  61. data/test/test_cookie.rb +309 -0
  62. data/test/test_hexdump.rb +14 -0
  63. data/test/test_http-access2.rb +508 -0
  64. data/test/test_httpclient.rb +2145 -0
  65. data/test/test_include_client.rb +52 -0
  66. data/test/test_jsonclient.rb +98 -0
  67. data/test/test_ssl.rb +562 -0
  68. data/test/test_webagent-cookie.rb +465 -0
  69. metadata +124 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 95dcb2a99a3f157d3b35c9892837beb972e77888a487743bcf48994b06e2aa22
4
+ data.tar.gz: 679bf035edc4b9b3148c123865a07f88cf04771f9d3ba6906a08ddfa4f39be52
5
+ SHA512:
6
+ metadata.gz: 76676fb8626210128227fa885034d0f0ef6e81792213c6cd29b4320df648802081a570b686f159eae29a1783959c389c768c39e05a120a422468d82e72cf43a4
7
+ data.tar.gz: 353bbf9e445f434e47eefba454186024b0c4ecaa6667d0cb07db2c067046bda203960b86c688b198dcfda29c8c29853d23eb4ab4486b368af2002bdfc62d71f4
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ httpclient - HTTP accessing library. [![Gem Version](https://badge.fury.io/rb/httpclient.svg)](http://badge.fury.io/rb/httpclient)
2
+
3
+ Copyright (C) 2000-2015 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
+
5
+ 'httpclient' gives something like the functionality of libwww-perl (LWP) in
6
+ Ruby. 'httpclient' formerly known as 'http-access2'.
7
+
8
+ See [HTTPClient](http://www.rubydoc.info/gems/httpclient/frames) for documentation.
9
+
10
+
11
+ ## Features
12
+
13
+ * methods like GET/HEAD/POST/* via HTTP/1.1.
14
+ * HTTPS(SSL), Cookies, proxy, authentication(Digest, NTLM, Basic), etc.
15
+ * asynchronous HTTP request, streaming HTTP request.
16
+ * debug mode CLI.
17
+ * by contrast with net/http in standard distribution;
18
+ * Cookies support
19
+ * MT-safe
20
+ * streaming POST (POST with File/IO)
21
+ * Digest auth
22
+ * Negotiate/NTLM auth for WWW-Authenticate (requires net/ntlm module; rubyntlm gem)
23
+ * NTLM auth for Proxy-Authenticate (requires 'win32/sspi' module; rubysspi gem)
24
+ * extensible with filter interface
25
+ * you don't have to care HTTP/1.1 persistent connection
26
+ (httpclient cares instead of you)
27
+ * Not supported now
28
+ * Cache
29
+ * Rather advanced HTTP/1.1 usage such as Range, deflate, etc.
30
+ (of course you can set it in header by yourself)
31
+
32
+ ## httpclient command
33
+
34
+ Usage: 1) `httpclient get https://www.google.co.jp/?q=ruby`
35
+ Usage: 2) `httpclient`
36
+
37
+ For 1) it issues a GET request to the given URI and shows the wiredump and
38
+ the parsed result. For 2) it invokes irb shell with the binding that has a
39
+ HTTPClient as 'self'. You can call HTTPClient instance methods like;
40
+
41
+ ```ruby
42
+ get "https://www.google.co.jp/", :q => :ruby
43
+ ```
44
+
45
+ ## Author
46
+
47
+ * Name:: Hiroshi Nakamura
48
+ * E-mail:: nahi@ruby-lang.org
49
+ * Project web site:: http://github.com/nahi/httpclient
50
+
51
+
52
+ ## License
53
+
54
+ This program is copyrighted free software by NAKAMURA, Hiroshi. You can
55
+ redistribute it and/or modify it under the same terms of Ruby's license;
56
+ either the dual license version in 2003, or any later version.
57
+
58
+ httpclient/session.rb is based on http-access.rb in http-access/0.0.4. Some
59
+ part of it is copyrighted by Maebashi-san who made and published
60
+ http-access/0.0.4. http-access/0.0.4 did not include license notice but when
61
+ I asked Maebashi-san he agreed that I can redistribute it under the same terms
62
+ of Ruby. Many thanks to Maebashi-san.
63
+
64
+
65
+ ## Install
66
+
67
+ You can install httpclient via rubygems: `gem install httpclient`
68
+
69
+
70
+ ## Usage
71
+
72
+ See [HTTPClient](http://www.rubydoc.info/gems/httpclient/frames) for documentation.
73
+ You can also check sample/howto.rb how to use APIs.
74
+
75
+ ## Bug report or Feature request
76
+
77
+ Please file a ticket at the project web site.
78
+
79
+ 1. find a similar ticket from https://github.com/nahi/httpclient/issues
80
+ 2. create a new ticket by clicking 'Create Issue' button.
81
+ 3. you can use github features such as pull-request if you like.
82
+
83
+ ## Changes
84
+
85
+ See [ChangeLog](https://github.com/nahi/httpclient/blob/master/CHANGELOG.md)
86
+
87
+
88
+ ## Release
89
+
90
+ Prerequisites:
91
+ - install gemfury client with `gem install gemfury`
92
+
93
+ To release a new version:
94
+ - create a branch from `master`
95
+ - update the version number in `./lib/httpclient/version`,
96
+ - update the `CHANGELOG.md`
97
+ - create a Pull Request, get it approved and merged to master
98
+ - checkout `master` and run `rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [gemfury.com](https://gemfury.com).
data/bin/httpclient ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # httpclient shell command.
4
+ #
5
+ # Usage: 1) % httpclient get https://www.google.co.jp/ q=ruby
6
+ # Usage: 2) % httpclient
7
+ #
8
+ # For 1) it issues a GET request to the given URI and shows the wiredump and
9
+ # the parsed result. For 2) it invokes irb shell with the binding that has a
10
+ # HTTPClient as 'self'. You can call HTTPClient instance methods like;
11
+ # > get "https://www.google.co.jp/", :q => :ruby
12
+ require 'httpclient'
13
+
14
+ method = ARGV.shift
15
+ if method == 'version'
16
+ puts HTTPClient::VERSION
17
+ exit
18
+ end
19
+
20
+ url = ARGV.shift
21
+ if method && url
22
+ client = HTTPClient.new
23
+ client.strict_response_size_check = true
24
+ if method == 'download'
25
+ print client.get_content(url)
26
+ else
27
+ client.debug_dev = STDERR
28
+ $DEBUG = true
29
+ require 'pp'
30
+ pp client.send(method, url, *ARGV)
31
+ end
32
+ exit
33
+ end
34
+
35
+ require 'irb'
36
+ require 'irb/completion'
37
+
38
+ class Runner
39
+ def initialize
40
+ @httpclient = HTTPClient.new
41
+ @httpclient.strict_response_size_check = true
42
+ end
43
+
44
+ def method_missing(msg, *a, &b)
45
+ debug, $DEBUG = $DEBUG, true
46
+ begin
47
+ @httpclient.send(msg, *a, &b)
48
+ ensure
49
+ $DEBUG = debug
50
+ end
51
+ end
52
+
53
+ def run
54
+ IRB.setup(nil)
55
+ ws = IRB::WorkSpace.new(binding)
56
+ irb = IRB::Irb.new(ws)
57
+ IRB.conf[:MAIN_CONTEXT] = irb.context
58
+
59
+ trap("SIGINT") do
60
+ irb.signal_handle
61
+ end
62
+
63
+ begin
64
+ catch(:IRB_EXIT) do
65
+ irb.eval_input
66
+ end
67
+ ensure
68
+ IRB.irb_at_exit
69
+ end
70
+ end
71
+
72
+ def to_s
73
+ 'HTTPClient'
74
+ end
75
+ end
76
+
77
+ Runner.new.run
data/bin/jsonclient ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # jsonclient shell command.
4
+ #
5
+ # Usage: 1) % jsonclient post https://www.example.com/ content.json
6
+ # Usage: 2) % jsonclient
7
+ #
8
+ # For 1) it issues a GET request to the given URI and shows the wiredump and
9
+ # the parsed result. For 2) it invokes irb shell with the binding that has a
10
+ # JSONClient as 'self'. You can call JSONClient instance methods like;
11
+ # > post "https://www.example.com/resource", {'hello' => 'world'}
12
+ require 'jsonclient'
13
+
14
+ method = ARGV.shift
15
+ url = ARGV.shift
16
+ body = []
17
+ if ['post', 'put'].include?(method)
18
+ if ARGV.size == 1 && File.exist?(ARGV[0])
19
+ body << File.read(ARGV[0])
20
+ else
21
+ body << ARGF.read
22
+ end
23
+ end
24
+ if method && url
25
+ require 'pp'
26
+ client = JSONClient.new
27
+ client.debug_dev = STDERR if $DEBUG
28
+ res = client.send(method, url, *body)
29
+ STDERR.puts('RESPONSE HEADER: ')
30
+ PP.pp(res.headers, STDERR)
31
+ if res.ok?
32
+ begin
33
+ puts JSON.pretty_generate(res.content)
34
+ rescue JSON::GeneratorError
35
+ puts res.content
36
+ end
37
+ exit 0
38
+ else
39
+ STDERR.puts res.content
40
+ exit 1
41
+ end
42
+ end
43
+
44
+ require 'irb'
45
+ require 'irb/completion'
46
+
47
+ class Runner
48
+ def initialize
49
+ @httpclient = JSONClient.new
50
+ end
51
+
52
+ def method_missing(msg, *a, &b)
53
+ debug, $DEBUG = $DEBUG, true
54
+ begin
55
+ @httpclient.send(msg, *a, &b)
56
+ ensure
57
+ $DEBUG = debug
58
+ end
59
+ end
60
+
61
+ def run
62
+ IRB.setup(nil)
63
+ ws = IRB::WorkSpace.new(binding)
64
+ irb = IRB::Irb.new(ws)
65
+ IRB.conf[:MAIN_CONTEXT] = irb.context
66
+
67
+ trap("SIGINT") do
68
+ irb.signal_handle
69
+ end
70
+
71
+ begin
72
+ catch(:IRB_EXIT) do
73
+ irb.eval_input
74
+ end
75
+ ensure
76
+ IRB.irb_at_exit
77
+ end
78
+ end
79
+
80
+ def to_s
81
+ 'JSONClient'
82
+ end
83
+ end
84
+
85
+ Runner.new.run
data/lib/hexdump.rb ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: binary
2
+
3
+ # This was written by Arai-san and published at
4
+ # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/31987
5
+
6
+
7
+ module HexDump
8
+ # str must be in BINARY encoding in 1.9
9
+ def encode(str)
10
+ offset = 0
11
+ result = []
12
+ while raw = str.slice(offset, 16) and raw.length > 0
13
+ # data field
14
+ data = ''
15
+ for v in raw.unpack('N* a*')
16
+ if v.kind_of? Integer
17
+ data << sprintf("%08x ", v)
18
+ else
19
+ v.each_byte {|c| data << sprintf("%02x", c) }
20
+ end
21
+ end
22
+ # text field
23
+ text = raw.tr("\000-\037\177-\377", ".")
24
+ result << sprintf("%08x %-36s %s", offset, data, text)
25
+ offset += 16
26
+ # omit duplicate line
27
+ if /^(#{regex_quote_n(raw)})+/n =~ str[offset .. -1]
28
+ result << sprintf("%08x ...", offset)
29
+ offset += $&.length
30
+ # should print at the end
31
+ if offset == str.length
32
+ result << sprintf("%08x %-36s %s", offset-16, data, text)
33
+ end
34
+ end
35
+ end
36
+ result
37
+ end
38
+ module_function :encode
39
+
40
+ if RUBY_VERSION >= "1.9"
41
+ # raw must be in BINARY encoding in 1.9
42
+ def self.regex_quote_n(raw)
43
+ Regexp.quote(raw)
44
+ end
45
+ else
46
+ def self.regex_quote_n(raw)
47
+ Regexp.quote(raw, 'n')
48
+ end
49
+ end
50
+ end
@@ -0,0 +1 @@
1
+ require 'httpclient/cookie'
@@ -0,0 +1 @@
1
+ require 'httpclient/http'
@@ -0,0 +1,55 @@
1
+ # HTTPAccess2 - HTTP accessing library.
2
+ # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
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
+ # http-access2.rb is based on http-access.rb in http-access/0.0.4. Some
9
+ # part of it is copyrighted by Maebashi-san who made and published
10
+ # http-access/0.0.4. http-access/0.0.4 did not include license notice but
11
+ # when I asked Maebashi-san he agreed that I can redistribute it under the
12
+ # same terms of Ruby. Many thanks to Maebashi-san.
13
+
14
+
15
+ require 'httpclient'
16
+
17
+
18
+ module HTTPAccess2
19
+ VERSION = ::HTTPClient::VERSION
20
+ RUBY_VERSION_STRING = ::HTTPClient::RUBY_VERSION_STRING
21
+ SSLEnabled = ::HTTPClient::SSLEnabled
22
+ SSPIEnabled = ::HTTPClient::SSPIEnabled
23
+ DEBUG_SSL = true
24
+
25
+ Util = ::HTTPClient::Util
26
+
27
+ class Client < ::HTTPClient
28
+ class RetryableResponse < StandardError
29
+ end
30
+ end
31
+
32
+ SSLConfig = ::HTTPClient::SSLConfig
33
+ BasicAuth = ::HTTPClient::BasicAuth
34
+ DigestAuth = ::HTTPClient::DigestAuth
35
+ NegotiateAuth = ::HTTPClient::NegotiateAuth
36
+ AuthFilterBase = ::HTTPClient::AuthFilterBase
37
+ WWWAuth = ::HTTPClient::WWWAuth
38
+ ProxyAuth = ::HTTPClient::ProxyAuth
39
+ Site = ::HTTPClient::Site
40
+ Connection = ::HTTPClient::Connection
41
+ SessionManager = ::HTTPClient::SessionManager
42
+ SSLSocketWrap = ::HTTPClient::SSLSocket
43
+ DebugSocket = ::HTTPClient::DebugSocket
44
+
45
+ class Session < ::HTTPClient::Session
46
+ class Error < StandardError
47
+ end
48
+ class InvalidState < Error
49
+ end
50
+ class BadResponse < Error
51
+ end
52
+ class KeepAliveDisconnected < Error
53
+ end
54
+ end
55
+ end