scout 5.7.1 → 5.7.2.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. data/CHANGELOG.markdown +5 -0
  2. data/lib/scout/command/run.rb +1 -1
  3. data/lib/scout/server.rb +2 -1
  4. data/lib/scout/streamer.rb +3 -2
  5. data/lib/scout/streamer_daemon.rb +4 -4
  6. data/lib/scout/version.rb +1 -1
  7. data/test/scout_test.rb +7 -8
  8. data/vendor/httpclient/README.txt +759 -0
  9. data/vendor/httpclient/bin/httpclient +65 -0
  10. data/vendor/httpclient/lib/hexdump.rb +50 -0
  11. data/vendor/httpclient/lib/http-access2.rb +55 -0
  12. data/vendor/httpclient/lib/http-access2/cookie.rb +1 -0
  13. data/vendor/httpclient/lib/http-access2/http.rb +1 -0
  14. data/vendor/httpclient/lib/httpclient.rb +1156 -0
  15. data/vendor/httpclient/lib/httpclient/auth.rb +899 -0
  16. data/vendor/httpclient/lib/httpclient/cacert.p7s +1912 -0
  17. data/vendor/httpclient/lib/httpclient/connection.rb +88 -0
  18. data/vendor/httpclient/lib/httpclient/cookie.rb +438 -0
  19. data/vendor/httpclient/lib/httpclient/http.rb +1046 -0
  20. data/vendor/httpclient/lib/httpclient/include_client.rb +83 -0
  21. data/vendor/httpclient/lib/httpclient/session.rb +1025 -0
  22. data/vendor/httpclient/lib/httpclient/ssl_config.rb +403 -0
  23. data/vendor/httpclient/lib/httpclient/timeout.rb +140 -0
  24. data/vendor/httpclient/lib/httpclient/util.rb +178 -0
  25. data/vendor/httpclient/lib/httpclient/version.rb +3 -0
  26. data/vendor/httpclient/lib/oauthclient.rb +110 -0
  27. data/vendor/httpclient/sample/async.rb +8 -0
  28. data/vendor/httpclient/sample/auth.rb +11 -0
  29. data/vendor/httpclient/sample/cookie.rb +18 -0
  30. data/vendor/httpclient/sample/dav.rb +103 -0
  31. data/vendor/httpclient/sample/howto.rb +49 -0
  32. data/vendor/httpclient/sample/oauth_buzz.rb +57 -0
  33. data/vendor/httpclient/sample/oauth_friendfeed.rb +59 -0
  34. data/vendor/httpclient/sample/oauth_salesforce_10.rb +63 -0
  35. data/vendor/httpclient/sample/oauth_twitter.rb +61 -0
  36. data/vendor/httpclient/sample/ssl/0cert.pem +22 -0
  37. data/vendor/httpclient/sample/ssl/0key.pem +30 -0
  38. data/vendor/httpclient/sample/ssl/1000cert.pem +19 -0
  39. data/vendor/httpclient/sample/ssl/1000key.pem +18 -0
  40. data/vendor/httpclient/sample/ssl/htdocs/index.html +10 -0
  41. data/vendor/httpclient/sample/ssl/ssl_client.rb +22 -0
  42. data/vendor/httpclient/sample/ssl/webrick_httpsd.rb +29 -0
  43. data/vendor/httpclient/sample/stream.rb +21 -0
  44. data/vendor/httpclient/sample/thread.rb +27 -0
  45. data/vendor/httpclient/sample/wcat.rb +21 -0
  46. data/vendor/httpclient/test/ca-chain.cert +44 -0
  47. data/vendor/httpclient/test/ca.cert +23 -0
  48. data/vendor/httpclient/test/client.cert +19 -0
  49. data/vendor/httpclient/test/client.key +15 -0
  50. data/vendor/httpclient/test/helper.rb +129 -0
  51. data/vendor/httpclient/test/htdigest +1 -0
  52. data/vendor/httpclient/test/htpasswd +2 -0
  53. data/vendor/httpclient/test/runner.rb +2 -0
  54. data/vendor/httpclient/test/server.cert +19 -0
  55. data/vendor/httpclient/test/server.key +15 -0
  56. data/vendor/httpclient/test/sslsvr.rb +65 -0
  57. data/vendor/httpclient/test/subca.cert +21 -0
  58. data/vendor/httpclient/test/test_auth.rb +321 -0
  59. data/vendor/httpclient/test/test_cookie.rb +391 -0
  60. data/vendor/httpclient/test/test_hexdump.rb +14 -0
  61. data/vendor/httpclient/test/test_http-access2.rb +507 -0
  62. data/vendor/httpclient/test/test_httpclient.rb +1783 -0
  63. data/vendor/httpclient/test/test_include_client.rb +52 -0
  64. data/vendor/httpclient/test/test_ssl.rb +235 -0
  65. data/vendor/multi_json/.document +5 -0
  66. data/vendor/multi_json/.rspec +3 -0
  67. data/vendor/multi_json/.travis.yml +11 -0
  68. data/vendor/multi_json/.yardopts +6 -0
  69. data/vendor/multi_json/CHANGELOG.md +169 -0
  70. data/vendor/multi_json/CONTRIBUTING.md +46 -0
  71. data/vendor/multi_json/Gemfile +31 -0
  72. data/vendor/multi_json/LICENSE.md +20 -0
  73. data/vendor/multi_json/README.md +109 -0
  74. data/vendor/multi_json/Rakefile +12 -0
  75. data/vendor/multi_json/lib/multi_json.rb +157 -0
  76. data/vendor/multi_json/lib/multi_json/adapter.rb +48 -0
  77. data/vendor/multi_json/lib/multi_json/adapters/gson.rb +19 -0
  78. data/vendor/multi_json/lib/multi_json/adapters/jr_jackson.rb +19 -0
  79. data/vendor/multi_json/lib/multi_json/adapters/json_common.rb +25 -0
  80. data/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +11 -0
  81. data/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +11 -0
  82. data/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +34 -0
  83. data/vendor/multi_json/lib/multi_json/adapters/oj.rb +24 -0
  84. data/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +22 -0
  85. data/vendor/multi_json/lib/multi_json/adapters/yajl.rb +19 -0
  86. data/vendor/multi_json/lib/multi_json/convertible_hash_keys.rb +43 -0
  87. data/vendor/multi_json/lib/multi_json/load_error.rb +11 -0
  88. data/vendor/multi_json/lib/multi_json/options.rb +48 -0
  89. data/vendor/multi_json/lib/multi_json/vendor/okjson.rb +606 -0
  90. data/vendor/multi_json/lib/multi_json/version.rb +20 -0
  91. data/vendor/multi_json/multi_json.gemspec +22 -0
  92. data/vendor/multi_json/spec/adapter_shared_example.rb +235 -0
  93. data/vendor/multi_json/spec/has_options.rb +119 -0
  94. data/vendor/multi_json/spec/helper.rb +35 -0
  95. data/vendor/multi_json/spec/json_common_shared_example.rb +30 -0
  96. data/vendor/multi_json/spec/multi_json_spec.rb +226 -0
  97. data/vendor/{signature → pusher}/.document +0 -0
  98. data/vendor/{json_pure/diagrams/.keep → pusher/.gemtest} +0 -0
  99. data/vendor/pusher/.gitignore +23 -0
  100. data/vendor/pusher/.travis.yml +15 -0
  101. data/vendor/pusher/Gemfile +2 -0
  102. data/vendor/{pusher-gem → pusher}/LICENSE +1 -1
  103. data/vendor/pusher/README.md +186 -0
  104. data/vendor/{pusher-gem → pusher}/Rakefile +0 -0
  105. data/vendor/{pusher-gem → pusher}/examples/async_message.rb +0 -0
  106. data/vendor/pusher/lib/pusher.rb +60 -0
  107. data/vendor/{pusher-gem → pusher}/lib/pusher/channel.rb +47 -54
  108. data/vendor/pusher/lib/pusher/client.rb +306 -0
  109. data/vendor/pusher/lib/pusher/request.rb +107 -0
  110. data/vendor/pusher/lib/pusher/resource.rb +36 -0
  111. data/vendor/pusher/lib/pusher/webhook.rb +110 -0
  112. data/vendor/{pusher-gem → pusher}/pusher.gemspec +6 -5
  113. data/vendor/pusher/spec/channel_spec.rb +127 -0
  114. data/vendor/pusher/spec/client_spec.rb +464 -0
  115. data/vendor/{pusher-gem → pusher}/spec/spec_helper.rb +12 -0
  116. data/vendor/pusher/spec/web_hook_spec.rb +117 -0
  117. data/vendor/signature/.travis.yml +15 -0
  118. data/vendor/signature/Gemfile +1 -1
  119. data/vendor/signature/README.md +38 -28
  120. data/vendor/signature/lib/signature.rb +97 -15
  121. data/vendor/signature/lib/signature/query_encoder.rb +47 -0
  122. data/vendor/signature/lib/signature/version.rb +1 -1
  123. data/vendor/signature/signature.gemspec +3 -2
  124. data/vendor/signature/spec/signature_spec.rb +164 -55
  125. data/vendor/signature/spec/spec_helper.rb +2 -3
  126. metadata +120 -145
  127. data/vendor/json_pure/.gitignore +0 -12
  128. data/vendor/json_pure/.travis.yml +0 -20
  129. data/vendor/json_pure/CHANGES +0 -282
  130. data/vendor/json_pure/COPYING +0 -58
  131. data/vendor/json_pure/COPYING-json-jruby +0 -57
  132. data/vendor/json_pure/GPL +0 -340
  133. data/vendor/json_pure/Gemfile +0 -11
  134. data/vendor/json_pure/README-json-jruby.markdown +0 -33
  135. data/vendor/json_pure/README.rdoc +0 -358
  136. data/vendor/json_pure/Rakefile +0 -412
  137. data/vendor/json_pure/TODO +0 -1
  138. data/vendor/json_pure/VERSION +0 -1
  139. data/vendor/json_pure/data/example.json +0 -1
  140. data/vendor/json_pure/data/index.html +0 -38
  141. data/vendor/json_pure/data/prototype.js +0 -4184
  142. data/vendor/json_pure/ext/json/ext/fbuffer/fbuffer.h +0 -181
  143. data/vendor/json_pure/ext/json/ext/generator/depend +0 -1
  144. data/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -14
  145. data/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1435
  146. data/vendor/json_pure/ext/json/ext/generator/generator.h +0 -148
  147. data/vendor/json_pure/ext/json/ext/parser/depend +0 -1
  148. data/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -13
  149. data/vendor/json_pure/ext/json/ext/parser/parser.c +0 -2204
  150. data/vendor/json_pure/ext/json/ext/parser/parser.h +0 -77
  151. data/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -927
  152. data/vendor/json_pure/install.rb +0 -23
  153. data/vendor/json_pure/java/src/json/ext/ByteListTranscoder.java +0 -167
  154. data/vendor/json_pure/java/src/json/ext/Generator.java +0 -444
  155. data/vendor/json_pure/java/src/json/ext/GeneratorMethods.java +0 -232
  156. data/vendor/json_pure/java/src/json/ext/GeneratorService.java +0 -43
  157. data/vendor/json_pure/java/src/json/ext/GeneratorState.java +0 -543
  158. data/vendor/json_pure/java/src/json/ext/OptionsReader.java +0 -114
  159. data/vendor/json_pure/java/src/json/ext/Parser.java +0 -2644
  160. data/vendor/json_pure/java/src/json/ext/Parser.rl +0 -968
  161. data/vendor/json_pure/java/src/json/ext/ParserService.java +0 -35
  162. data/vendor/json_pure/java/src/json/ext/RuntimeInfo.java +0 -121
  163. data/vendor/json_pure/java/src/json/ext/StringDecoder.java +0 -167
  164. data/vendor/json_pure/java/src/json/ext/StringEncoder.java +0 -106
  165. data/vendor/json_pure/java/src/json/ext/Utils.java +0 -89
  166. data/vendor/json_pure/json-java.gemspec +0 -23
  167. data/vendor/json_pure/json.gemspec +0 -37
  168. data/vendor/json_pure/json_pure.gemspec +0 -39
  169. data/vendor/json_pure/lib/json.rb +0 -62
  170. data/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
  171. data/vendor/json_pure/lib/json/add/complex.rb +0 -22
  172. data/vendor/json_pure/lib/json/add/core.rb +0 -11
  173. data/vendor/json_pure/lib/json/add/date.rb +0 -34
  174. data/vendor/json_pure/lib/json/add/date_time.rb +0 -50
  175. data/vendor/json_pure/lib/json/add/exception.rb +0 -31
  176. data/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
  177. data/vendor/json_pure/lib/json/add/range.rb +0 -29
  178. data/vendor/json_pure/lib/json/add/rational.rb +0 -22
  179. data/vendor/json_pure/lib/json/add/regexp.rb +0 -30
  180. data/vendor/json_pure/lib/json/add/struct.rb +0 -30
  181. data/vendor/json_pure/lib/json/add/symbol.rb +0 -25
  182. data/vendor/json_pure/lib/json/add/time.rb +0 -38
  183. data/vendor/json_pure/lib/json/common.rb +0 -487
  184. data/vendor/json_pure/lib/json/ext.rb +0 -21
  185. data/vendor/json_pure/lib/json/ext/.keep +0 -0
  186. data/vendor/json_pure/lib/json/generic_object.rb +0 -70
  187. data/vendor/json_pure/lib/json/pure.rb +0 -21
  188. data/vendor/json_pure/lib/json/pure/generator.rb +0 -522
  189. data/vendor/json_pure/lib/json/pure/parser.rb +0 -359
  190. data/vendor/json_pure/lib/json/version.rb +0 -8
  191. data/vendor/json_pure/tests/fixtures/fail1.json +0 -1
  192. data/vendor/json_pure/tests/fixtures/fail10.json +0 -1
  193. data/vendor/json_pure/tests/fixtures/fail11.json +0 -1
  194. data/vendor/json_pure/tests/fixtures/fail12.json +0 -1
  195. data/vendor/json_pure/tests/fixtures/fail13.json +0 -1
  196. data/vendor/json_pure/tests/fixtures/fail14.json +0 -1
  197. data/vendor/json_pure/tests/fixtures/fail18.json +0 -1
  198. data/vendor/json_pure/tests/fixtures/fail19.json +0 -1
  199. data/vendor/json_pure/tests/fixtures/fail2.json +0 -1
  200. data/vendor/json_pure/tests/fixtures/fail20.json +0 -1
  201. data/vendor/json_pure/tests/fixtures/fail21.json +0 -1
  202. data/vendor/json_pure/tests/fixtures/fail22.json +0 -1
  203. data/vendor/json_pure/tests/fixtures/fail23.json +0 -1
  204. data/vendor/json_pure/tests/fixtures/fail24.json +0 -1
  205. data/vendor/json_pure/tests/fixtures/fail25.json +0 -1
  206. data/vendor/json_pure/tests/fixtures/fail27.json +0 -2
  207. data/vendor/json_pure/tests/fixtures/fail28.json +0 -2
  208. data/vendor/json_pure/tests/fixtures/fail3.json +0 -1
  209. data/vendor/json_pure/tests/fixtures/fail4.json +0 -1
  210. data/vendor/json_pure/tests/fixtures/fail5.json +0 -1
  211. data/vendor/json_pure/tests/fixtures/fail6.json +0 -1
  212. data/vendor/json_pure/tests/fixtures/fail7.json +0 -1
  213. data/vendor/json_pure/tests/fixtures/fail8.json +0 -1
  214. data/vendor/json_pure/tests/fixtures/fail9.json +0 -1
  215. data/vendor/json_pure/tests/fixtures/pass1.json +0 -56
  216. data/vendor/json_pure/tests/fixtures/pass15.json +0 -1
  217. data/vendor/json_pure/tests/fixtures/pass16.json +0 -1
  218. data/vendor/json_pure/tests/fixtures/pass17.json +0 -1
  219. data/vendor/json_pure/tests/fixtures/pass2.json +0 -1
  220. data/vendor/json_pure/tests/fixtures/pass26.json +0 -1
  221. data/vendor/json_pure/tests/fixtures/pass3.json +0 -6
  222. data/vendor/json_pure/tests/setup_variant.rb +0 -11
  223. data/vendor/json_pure/tests/test_json.rb +0 -545
  224. data/vendor/json_pure/tests/test_json_addition.rb +0 -196
  225. data/vendor/json_pure/tests/test_json_encoding.rb +0 -65
  226. data/vendor/json_pure/tests/test_json_fixtures.rb +0 -35
  227. data/vendor/json_pure/tests/test_json_generate.rb +0 -322
  228. data/vendor/json_pure/tests/test_json_generic_object.rb +0 -75
  229. data/vendor/json_pure/tests/test_json_string_matching.rb +0 -39
  230. data/vendor/json_pure/tests/test_json_unicode.rb +0 -72
  231. data/vendor/json_pure/tools/fuzz.rb +0 -139
  232. data/vendor/json_pure/tools/server.rb +0 -62
  233. data/vendor/pusher-gem/Gemfile +0 -2
  234. data/vendor/pusher-gem/README.md +0 -80
  235. data/vendor/pusher-gem/lib/pusher.rb +0 -107
  236. data/vendor/pusher-gem/lib/pusher/request.rb +0 -107
  237. data/vendor/pusher-gem/spec/channel_spec.rb +0 -274
  238. data/vendor/pusher-gem/spec/pusher_spec.rb +0 -87
  239. data/vendor/ruby-hmac/History.txt +0 -15
  240. data/vendor/ruby-hmac/Manifest.txt +0 -11
  241. data/vendor/ruby-hmac/README.md +0 -41
  242. data/vendor/ruby-hmac/Rakefile +0 -23
  243. data/vendor/ruby-hmac/lib/hmac-md5.rb +0 -11
  244. data/vendor/ruby-hmac/lib/hmac-rmd160.rb +0 -11
  245. data/vendor/ruby-hmac/lib/hmac-sha1.rb +0 -11
  246. data/vendor/ruby-hmac/lib/hmac-sha2.rb +0 -25
  247. data/vendor/ruby-hmac/lib/hmac.rb +0 -118
  248. data/vendor/ruby-hmac/lib/ruby_hmac.rb +0 -2
  249. data/vendor/ruby-hmac/ruby-hmac.gemspec +0 -33
  250. data/vendor/ruby-hmac/test/test_hmac.rb +0 -89
  251. data/vendor/signature/VERSION +0 -1
@@ -0,0 +1,178 @@
1
+ # HTTPClient - HTTP client library.
2
+ # Copyright (C) 2000-2012 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
+ unless ''.respond_to?(:bytesize)
10
+ class String
11
+ alias bytesize size
12
+ end
13
+ end
14
+
15
+ if RUBY_VERSION < "1.9.3"
16
+ require 'uri'
17
+ module URI
18
+ class Generic
19
+ def hostname
20
+ v = self.host
21
+ /\A\[(.*)\]\z/ =~ v ? $1 : v
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ class HTTPClient
28
+
29
+
30
+ # A module for common function.
31
+ module Util
32
+
33
+ # URI abstraction; Addressable::URI or URI
34
+ require 'uri'
35
+ begin
36
+ require 'addressable/uri'
37
+ # Older versions doesn't have #default_port
38
+ unless Addressable::URI.instance_methods.include?(:default_port) # 1.9 only
39
+ raise LoadError
40
+ end
41
+ class AddressableURI < Addressable::URI
42
+ # Overwrites the original definition just for one line...
43
+ def authority
44
+ self.host && @authority ||= (begin
45
+ authority = ""
46
+ if self.userinfo != nil
47
+ authority << "#{self.userinfo}@"
48
+ end
49
+ authority << self.host
50
+ if self.port != self.default_port # ...HERE! Compares with default_port because self.port is not nil in this wrapper.
51
+ authority << ":#{self.port}"
52
+ end
53
+ authority
54
+ end)
55
+ end
56
+
57
+ # HTTPClient expects urify("http://foo/").port to be not nil but 80 like URI.
58
+ def port
59
+ super || default_port
60
+ end
61
+
62
+ # Captured from uri/generic.rb
63
+ def hostname
64
+ v = self.host
65
+ /\A\[(.*)\]\z/ =~ v ? $1 : v
66
+ end
67
+ end
68
+ AddressableEnabled = true
69
+ rescue LoadError
70
+ AddressableEnabled = false
71
+ end
72
+
73
+ # Keyword argument helper.
74
+ # args:: given arguments.
75
+ # *field:: a list of arguments to be extracted.
76
+ #
77
+ # You can extract 3 arguments (a, b, c) with:
78
+ #
79
+ # include Util
80
+ # def my_method(*args)
81
+ # a, b, c = keyword_argument(args, :a, :b, :c)
82
+ # ...
83
+ # end
84
+ # my_method(1, 2, 3)
85
+ # my_method(:b => 2, :a = 1)
86
+ #
87
+ # instead of;
88
+ #
89
+ # def my_method(a, b, c)
90
+ # ...
91
+ # end
92
+ #
93
+ def keyword_argument(args, *field)
94
+ if args.size == 1 and Hash === args[0]
95
+ h = args[0]
96
+ if field.any? { |f| h.key?(f) }
97
+ return h.values_at(*field)
98
+ end
99
+ end
100
+ args
101
+ end
102
+
103
+ # Keyword argument to hash helper.
104
+ # args:: given arguments.
105
+ # *field:: a list of arguments to be extracted.
106
+ #
107
+ # Returns hash which has defined keys. When a Hash given, returns it
108
+ # including undefined keys. When an Array given, returns a Hash which only
109
+ # includes defined keys.
110
+ def argument_to_hash(args, *field)
111
+ return nil if args.empty?
112
+ if args.size == 1 and Hash === args[0]
113
+ h = args[0]
114
+ if field.any? { |f| h.key?(f) }
115
+ return h
116
+ end
117
+ end
118
+ h = {}
119
+ field.each_with_index do |e, idx|
120
+ h[e] = args[idx]
121
+ end
122
+ h
123
+ end
124
+
125
+ # Gets an URI instance.
126
+ def urify(uri)
127
+ if uri.nil?
128
+ nil
129
+ elsif uri.is_a?(URI)
130
+ uri
131
+ elsif AddressableEnabled
132
+ AddressableURI.parse(uri.to_s)
133
+ else
134
+ URI.parse(uri.to_s)
135
+ end
136
+ end
137
+ module_function :urify
138
+
139
+ # Returns true if the given 2 URIs have a part_of relationship.
140
+ # * the same scheme
141
+ # * the same host String (no host resolution or IP-addr conversion)
142
+ # * the same port number
143
+ # * target URI's path starts with base URI's path.
144
+ def uri_part_of(uri, part)
145
+ ((uri.scheme == part.scheme) and
146
+ (uri.host == part.host) and
147
+ (uri.port == part.port) and
148
+ uri.path.upcase.index(part.path.upcase) == 0)
149
+ end
150
+ module_function :uri_part_of
151
+
152
+ # Returns parent directory URI of the given URI.
153
+ def uri_dirname(uri)
154
+ uri = uri.clone
155
+ uri.path = uri.path.sub(/\/[^\/]*\z/, '/')
156
+ uri
157
+ end
158
+ module_function :uri_dirname
159
+
160
+ # Finds a value of a Hash.
161
+ def hash_find_value(hash, &block)
162
+ v = hash.find(&block)
163
+ v ? v[1] : nil
164
+ end
165
+ module_function :hash_find_value
166
+
167
+ # Checks if the given URI is https.
168
+ def https?(uri)
169
+ uri.scheme && uri.scheme.downcase == 'https'
170
+ end
171
+
172
+ def http?(uri)
173
+ uri.scheme && uri.scheme.downcase == 'http'
174
+ end
175
+ end
176
+
177
+
178
+ end
@@ -0,0 +1,3 @@
1
+ class HTTPClient
2
+ VERSION = '2.3.4.1'
3
+ end
@@ -0,0 +1,110 @@
1
+ # HTTPClient - HTTP client library.
2
+ # Copyright (C) 2000-2009 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 'httpclient'
10
+
11
+ module HTTP
12
+ class Message
13
+ attr_accessor :oauth_params
14
+ end
15
+ end
16
+
17
+
18
+ # OAuthClient provides OAuth related methods in addition to HTTPClient.
19
+ #
20
+ # See sample/ dir how to use OAuthClient. There are sample clients for Twitter,
21
+ # FriendFeed and Google Buzz.
22
+ class OAuthClient < HTTPClient
23
+
24
+ # HTTPClient::OAuth::Config:: OAuth configurator.
25
+ attr_accessor :oauth_config
26
+
27
+ # Creates a OAuthClient instance which provides OAuth related methods in
28
+ # addition to HTTPClient.
29
+ #
30
+ # Method signature is as same as HTTPClient. See HTTPClient.new
31
+ def initialize(*arg)
32
+ super
33
+ @oauth_config = HTTPClient::OAuth::Config.new
34
+ self.www_auth.oauth.set_config(nil, @oauth_config)
35
+ self.www_auth.oauth.challenge(nil)
36
+ end
37
+
38
+ # Get request token.
39
+ # uri:: URI for request token.
40
+ # callback:: callback String. This can be nil for OAuth 1.0a
41
+ # param:: Additional query parameter Hash.
42
+ #
43
+ # It returns a HTTP::Message instance as a response. When the request is made
44
+ # successfully, you can retrieve a pair of request token and secret like
45
+ # following;
46
+ # res = client.get_request_token(...)
47
+ # token = res.oauth_params['oauth_token']
48
+ # secret = res.oauth_params['oauth_token_secret']
49
+ def get_request_token(uri, callback = nil, param = nil)
50
+ oauth_config.token = nil
51
+ oauth_config.secret = nil
52
+ oauth_config.callback = callback
53
+ oauth_config.verifier = nil
54
+ res = request(oauth_config.http_method, uri, param)
55
+ filter_response(res)
56
+ res
57
+ end
58
+
59
+ # Get access token.
60
+ # uri:: URI for request token.
61
+ # request_token:: a request token String. See get_access_token.
62
+ # request_token_secret:: a request secret String. See get_access_token.
63
+ # verifier:: a verifier tag String.
64
+ #
65
+ # When the request succeeds and the server returns a pair of access token
66
+ # and secret, oauth_config.token and oauth_token.secret are updated with
67
+ # the access token. Then you can call OAuthClient#get, #post, #delete, etc.
68
+ # All requests are signed.
69
+ def get_access_token(uri, request_token, request_token_secret, verifier = nil)
70
+ oauth_config.token = request_token
71
+ oauth_config.secret = request_token_secret
72
+ oauth_config.callback = nil
73
+ oauth_config.verifier = verifier
74
+ res = request(oauth_config.http_method, uri)
75
+ filter_response(res)
76
+ oauth_config.verifier = nil
77
+ res
78
+ end
79
+
80
+ # Parse response and returns a Hash.
81
+ def get_oauth_response(res)
82
+ enc = res.header['content-encoding']
83
+ body = nil
84
+ if enc and enc[0] and enc[0].downcase == 'gzip'
85
+ body = Zlib::GzipReader.wrap(StringIO.new(res.content)) { |gz| gz.read }
86
+ else
87
+ body = res.content
88
+ end
89
+ body.split('&').inject({}) { |r, e|
90
+ key, value = e.split('=', 2)
91
+ r[unescape(key)] = unescape(value)
92
+ r
93
+ }
94
+ end
95
+
96
+ private
97
+
98
+ def unescape(escaped)
99
+ escaped ? ::HTTP::Message.unescape(escaped) : nil
100
+ end
101
+
102
+ def filter_response(res)
103
+ if res.status == 200
104
+ if res.oauth_params = get_oauth_response(res)
105
+ oauth_config.token = res.oauth_params['oauth_token']
106
+ oauth_config.secret = res.oauth_params['oauth_token_secret']
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,8 @@
1
+ require 'httpclient'
2
+
3
+ c = HTTPClient.new
4
+ conn = c.get_async("http://dev.ctor.org/")
5
+ io = conn.pop.content
6
+ while str = io.read(40)
7
+ p str
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'httpclient'
2
+
3
+ c = HTTPClient.new
4
+ c.debug_dev = STDOUT
5
+
6
+ # for Proxy authentication: supports Basic, Negotiate and NTLM.
7
+ #c.set_proxy_auth("admin", "admin")
8
+
9
+ # for WWW authentication: supports Basic, Digest and Negotiate.
10
+ c.set_auth("http://dev.ctor.org/http-access2/", "user", "user")
11
+ p c.get("http://dev.ctor.org/http-access2/login")
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join('..', 'lib'))
4
+ require 'httpclient'
5
+
6
+ proxy = ENV['HTTP_PROXY']
7
+ clnt = HTTPClient.new(proxy)
8
+ clnt.set_cookie_store("cookie.dat")
9
+ clnt.debug_dev = STDOUT if $DEBUG
10
+
11
+ while urlstr = ARGV.shift
12
+ response = clnt.get(urlstr){ |data|
13
+ print data
14
+ }
15
+ p response.contenttype
16
+ end
17
+
18
+ clnt.save_cookie_store
@@ -0,0 +1,103 @@
1
+ require 'uri'
2
+ require 'httpclient'
3
+
4
+ class DAV
5
+ attr_reader :headers
6
+
7
+ def initialize(uri = nil)
8
+ @uri = nil
9
+ @headers = {}
10
+ open(uri) if uri
11
+ proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] || nil
12
+ @client = HTTPClient.new(proxy)
13
+ end
14
+
15
+ def open(uri)
16
+ @uri = if uri.is_a?(URI)
17
+ uri
18
+ else
19
+ URI.parse(uri)
20
+ end
21
+ end
22
+
23
+ def set_basic_auth(user_id, passwd)
24
+ @client.set_basic_auth(@uri, user_id, passwd)
25
+ end
26
+
27
+ # TODO: propget/propset support
28
+
29
+ def propfind(target)
30
+ target_uri = @uri + target
31
+ res = @client.propfind(target_uri)
32
+ res.body.content
33
+ end
34
+
35
+ def get(target, local = nil)
36
+ local ||= target
37
+ target_uri = @uri + target
38
+ if FileTest.exist?(local)
39
+ raise RuntimeError.new("File #{ local } exists.")
40
+ end
41
+ f = File.open(local, "wb")
42
+ res = @client.get(target_uri, nil, @headers) do |data|
43
+ f << data
44
+ end
45
+ f.close
46
+ STDOUT.puts("#{ res.header['content-length'][0] } bytes saved to file #{ target }.")
47
+ end
48
+
49
+ def debug_dev=(dev)
50
+ @client.debug_dev = dev
51
+ end
52
+
53
+ def get_content(target)
54
+ target_uri = @uri + target
55
+ @client.get_content(target_uri, nil, @headers)
56
+ end
57
+
58
+ def put_content(target, content)
59
+ target_uri = @uri + target
60
+ res = @client.put(target_uri, content, @headers)
61
+ if res.status < 200 or res.status >= 300
62
+ raise "HTTP PUT failed: #{res.inspect}"
63
+ end
64
+ end
65
+
66
+ class Mock
67
+ attr_reader :headers
68
+
69
+ def initialize(uri = nil)
70
+ @uri = nil
71
+ @headers = {}
72
+ open(uri) if uri
73
+
74
+ @cache = {}
75
+ end
76
+
77
+ def open(uri)
78
+ @uri = uri.is_a?(URI) ? uri : URI.parse(uri)
79
+ end
80
+
81
+ def set_basic_auth(user_id, passwd)
82
+ # ignore
83
+ end
84
+
85
+ def propfind(target)
86
+ # not found
87
+ nil
88
+ end
89
+
90
+ def get(target, local = nil)
91
+ # ignore
92
+ end
93
+
94
+ def get_content(target)
95
+ @cache[target]
96
+ end
97
+
98
+ def put_content(target, content)
99
+ @cache[target] = content
100
+ nil
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join('..', 'lib'))
4
+ require 'httpclient'
5
+
6
+ proxy = ENV['HTTP_PROXY']
7
+ clnt = HTTPClient.new(proxy)
8
+ clnt.set_cookie_store("cookie.dat")
9
+ target = ARGV.shift || "http://localhost/foo.cgi"
10
+
11
+ puts
12
+ puts '= GET content directly'
13
+ puts clnt.get_content(target)
14
+
15
+ puts '= GET result object'
16
+ result = clnt.get(target)
17
+ puts '== Header object'
18
+ p result.header
19
+ puts "== Content-type"
20
+ p result.contenttype
21
+ puts '== Body object'
22
+ p result.body
23
+ puts '== Content'
24
+ print result.content
25
+ puts '== GET with Block'
26
+ clnt.get(target) do |str|
27
+ puts str
28
+ end
29
+
30
+ puts
31
+ puts '= GET with query'
32
+ puts clnt.get(target, { "foo" => "bar", "baz" => "quz" }).content
33
+
34
+ puts
35
+ puts '= GET with query 2'
36
+ puts clnt.get(target, [["foo", "bar1"], ["foo", "bar2"]]).content
37
+
38
+ clnt.debug_dev = STDERR
39
+ puts
40
+ puts '= GET with extra header'
41
+ puts clnt.get(target, nil, { "SOAPAction" => "HelloWorld" }).content
42
+
43
+ puts
44
+ puts '= GET with extra header 2'
45
+ puts clnt.get(target, nil, [["Accept", "text/plain"], ["Accept", "text/html"]]).content
46
+
47
+ clnt.debug_dev = nil
48
+
49
+ clnt.save_cookie_store