manticore 0.3.6-java → 0.4.0-java
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +9 -2
- data/lib/manticore/client.rb +44 -20
- data/lib/manticore/client/proxies.rb +3 -3
- data/lib/manticore/response.rb +3 -2
- data/lib/manticore/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e1191d64f814d4e5eeac2a74ea1cb9ec964451
|
4
|
+
data.tar.gz: 973396d996c2d9bb26491fe88e8566ee27809304
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dbfd05b0f5a02a31cde7696dac20baacfa9c981ae0c054d91fd203d2165d3fb42bf3add0363a7b49cb1a91e4c9047911be823c0409238783d8b19acad078088
|
7
|
+
data.tar.gz: 6eeeded09429d4275256cc81a70e8e12314f70ca7d7c9276160d2c0f982323aa23d3658315dec7dac64b11fed97e5d402fdb728d23224d8f7330ac08f06dfd70
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
## v0.
|
1
|
+
## v0.4.1 (pending)
|
2
|
+
|
3
|
+
### v0.4.0
|
2
4
|
|
3
|
-
|
5
|
+
* Proxy authentication is now supported
|
6
|
+
* Client#execute! no longer propagates exceptions; these should be handled in `on_failure`.
|
7
|
+
* Client#http and AsyncProxy now properly accept #delete
|
8
|
+
* Response#on_complete now receives the request as an argument
|
9
|
+
|
10
|
+
## v0.3
|
4
11
|
|
5
12
|
### v0.3.6
|
6
13
|
|
data/lib/manticore/client.rb
CHANGED
@@ -76,6 +76,7 @@ module Manticore
|
|
76
76
|
java_import "javax.net.ssl.SSLContext"
|
77
77
|
java_import "java.security.KeyStore"
|
78
78
|
java_import "org.manticore.HttpGetWithEntity"
|
79
|
+
java_import "org.apache.http.auth.UsernamePasswordCredentials"
|
79
80
|
|
80
81
|
include ProxiesInterface
|
81
82
|
|
@@ -121,7 +122,8 @@ module Manticore
|
|
121
122
|
# @option options [boolean] expect_continue (false) Enable support for HTTP 100
|
122
123
|
# @option options [boolean] stale_check (false) Enable support for stale connection checking. Adds overhead.
|
123
124
|
# @option options [String] proxy Proxy host in form: http://proxy.org:1234
|
124
|
-
# @option options [Hash] proxy Proxy host in form: {host: 'proxy.org'[, port: 80[, scheme: 'http']]}
|
125
|
+
# @option options [Hash] proxy Proxy host in form: {host: 'proxy.org'[, port: 80[, scheme: 'http'[, user: 'username@host', password: 'password']]]}
|
126
|
+
# @option options [Hash] proxy Proxy host in form: {url: 'http://proxy.org:1234'[, user: 'username@host', password: 'password']]]}
|
125
127
|
# @option options [URI] proxy Proxy host as a URI object
|
126
128
|
# @option options [Boolean/Fixnum] keepalive (true) Whether to allow connections to be reused. Defaults to true. If an integer,
|
127
129
|
# then connections will be kept alive for this long when Connection: keep-alive
|
@@ -257,7 +259,7 @@ module Manticore
|
|
257
259
|
request HttpPatch, url, options, &block
|
258
260
|
end
|
259
261
|
|
260
|
-
%w(get put head post options patch).each do |func|
|
262
|
+
%w(get put head post delete options patch).each do |func|
|
261
263
|
define_method "#{func}!" do |url, options, &block|
|
262
264
|
send(func, url, options, &block).call
|
263
265
|
end
|
@@ -269,7 +271,7 @@ module Manticore
|
|
269
271
|
# @macro http_request_exceptions
|
270
272
|
def http(method, url, options = {}, &block)
|
271
273
|
case method.to_s.downcase
|
272
|
-
when *%w(get put head post options patch)
|
274
|
+
when *%w(get put head post delete options patch)
|
273
275
|
send method, url, options, &block
|
274
276
|
else
|
275
277
|
raise "Invalid method: #{method}"
|
@@ -288,14 +290,6 @@ module Manticore
|
|
288
290
|
@stubs.delete(url_as_regex(url))
|
289
291
|
end
|
290
292
|
|
291
|
-
def url_as_regex(url)
|
292
|
-
if url.is_a?(String)
|
293
|
-
%r{^#{Regexp.escape url}$}
|
294
|
-
else
|
295
|
-
url
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
293
|
# Wipe all currently-set stubs.
|
300
294
|
def clear_stubs!
|
301
295
|
@stubs.clear
|
@@ -316,7 +310,13 @@ module Manticore
|
|
316
310
|
method = executor.java_method(:submit, [java.util.concurrent.Callable.java_class])
|
317
311
|
result = @async_requests.map {|r| method.call r }
|
318
312
|
@async_requests.clear
|
319
|
-
result.map
|
313
|
+
result.map do |future|
|
314
|
+
begin
|
315
|
+
future.get
|
316
|
+
rescue Java::JavaUtilConcurrent::ExecutionException => e
|
317
|
+
# These exceptions should be handled in on_failure blocks.
|
318
|
+
end
|
319
|
+
end
|
320
320
|
end
|
321
321
|
|
322
322
|
# Get at the underlying ExecutorService used to invoke asynchronous calls.
|
@@ -327,6 +327,14 @@ module Manticore
|
|
327
327
|
|
328
328
|
protected
|
329
329
|
|
330
|
+
def url_as_regex(url)
|
331
|
+
if url.is_a?(String)
|
332
|
+
%r{^#{Regexp.escape url}$}
|
333
|
+
else
|
334
|
+
url
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
330
338
|
def client_builder
|
331
339
|
HttpClientBuilder.create
|
332
340
|
end
|
@@ -434,11 +442,13 @@ module Manticore
|
|
434
442
|
end
|
435
443
|
end
|
436
444
|
|
445
|
+
req_options = @options.merge(options)
|
437
446
|
if options.key?(:proxy) || options.key?(:connect_timeout) || options.key?(:socket_timeout) || options.key?(:max_redirects) || options.key?(:follow_redirects)
|
438
447
|
config = RequestConfig.custom()
|
439
|
-
req_options = @options.merge(options)
|
440
448
|
|
441
|
-
|
449
|
+
if req_options[:proxy]
|
450
|
+
config.set_proxy get_proxy_host(req_options[:proxy])
|
451
|
+
end
|
442
452
|
config.set_max_redirects req_options[:max_redirects] if req_options[:max_redirects]
|
443
453
|
config.set_redirects_enabled !!req_options[:follow_redirects] if req_options.fetch(:follow_redirects, nil) != nil
|
444
454
|
config.set_connect_timeout req_options[:connect_timeout] * 1000 if req_options[:connect_timeout]
|
@@ -452,7 +462,8 @@ module Manticore
|
|
452
462
|
end
|
453
463
|
|
454
464
|
context = HttpClientContext.new
|
455
|
-
|
465
|
+
proxy_user = req_options[:proxy].is_a?(Hash) && (req_options[:proxy][:user] || req_options[:proxy][:username])
|
466
|
+
auth_from_options(req_options, context) if req_options.key?(:auth) || proxy_user
|
456
467
|
|
457
468
|
if @use_cookies == :per_request
|
458
469
|
store = BasicCookieStore.new
|
@@ -473,7 +484,11 @@ module Manticore
|
|
473
484
|
get_proxy_host uri
|
474
485
|
end
|
475
486
|
elsif opt.is_a? Hash
|
476
|
-
|
487
|
+
if opt.key?(:url)
|
488
|
+
get_proxy_host URI.parse(opt[:url])
|
489
|
+
elsif opt.key?(:host)
|
490
|
+
HttpHost.new(opt[:host], (opt[:port] || 80).to_i, opt[:scheme] || "http")
|
491
|
+
end
|
477
492
|
elsif opt.is_a? URI
|
478
493
|
opt.scheme ||= "http"
|
479
494
|
opt.port ||= 80
|
@@ -482,11 +497,20 @@ module Manticore
|
|
482
497
|
end
|
483
498
|
|
484
499
|
def auth_from_options(options, context)
|
485
|
-
|
500
|
+
proxy = options.fetch(:proxy, {})
|
501
|
+
if options[:auth] || proxy[:user] || proxy[:username]
|
486
502
|
provider = BasicCredentialsProvider.new
|
487
|
-
|
488
|
-
|
489
|
-
|
503
|
+
if options[:auth]
|
504
|
+
username = options[:auth][:user] || options[:auth][:username]
|
505
|
+
password = options[:auth][:pass] || options[:auth][:password]
|
506
|
+
provider.set_credentials AuthScope::ANY, UsernamePasswordCredentials.new(username, password)
|
507
|
+
end
|
508
|
+
|
509
|
+
if proxy[:user] || proxy[:username]
|
510
|
+
username = proxy[:user] || proxy[:username]
|
511
|
+
password = proxy[:pass] || proxy[:password]
|
512
|
+
provider.set_credentials AuthScope.new(get_proxy_host(proxy)), UsernamePasswordCredentials.new(username, password)
|
513
|
+
end
|
490
514
|
context.set_credentials_provider(provider)
|
491
515
|
end
|
492
516
|
end
|
@@ -24,7 +24,7 @@ module Manticore
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class AsyncProxy < BaseProxy
|
27
|
-
%w(get put head post options patch).each do |func|
|
27
|
+
%w(get put head post delete options patch).each do |func|
|
28
28
|
define_method func do |url, options = {}, &block|
|
29
29
|
@client.send(func, url, options.merge(async: true), &block)
|
30
30
|
end
|
@@ -37,7 +37,7 @@ module Manticore
|
|
37
37
|
@stubs = stubs
|
38
38
|
end
|
39
39
|
|
40
|
-
%w(get put head post options patch).each do |func|
|
40
|
+
%w(get put head post delete options patch).each do |func|
|
41
41
|
define_method func do |url, options = {}, &block|
|
42
42
|
@client.stub(url, @stubs)
|
43
43
|
@client.send(func, url, options, &block).complete { @client.unstub url }
|
@@ -46,7 +46,7 @@ module Manticore
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class BackgroundProxy < BaseProxy
|
49
|
-
%w(get put head post options patch).each do |func|
|
49
|
+
%w(get put head post delete options patch).each do |func|
|
50
50
|
define_method func do |url, options = {}, &block|
|
51
51
|
request = @client.send(func, url, options.merge(async: true), &block)
|
52
52
|
@client.executor.java_method(:submit, [java.util.concurrent.Callable.java_class]).call request
|
data/lib/manticore/response.rb
CHANGED
@@ -39,7 +39,7 @@ module Manticore
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Implementation of Callable#call
|
42
|
-
# Used by Manticore::Client to invoke the request tied to this response.
|
42
|
+
# Used by Manticore::Client to invoke the request tied to this response.
|
43
43
|
def call
|
44
44
|
raise "Already called" if @called
|
45
45
|
@called = true
|
@@ -60,6 +60,7 @@ module Manticore
|
|
60
60
|
@exception = ex
|
61
61
|
@handlers[:failure].call ex
|
62
62
|
execute_complete
|
63
|
+
nil
|
63
64
|
end
|
64
65
|
|
65
66
|
def fire_and_forget
|
@@ -226,7 +227,7 @@ module Manticore
|
|
226
227
|
end
|
227
228
|
|
228
229
|
def execute_complete
|
229
|
-
@handlers[:complete].each
|
230
|
+
@handlers[:complete].each {|h| h.call(self) }
|
230
231
|
end
|
231
232
|
end
|
232
233
|
end
|
data/lib/manticore/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manticore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Chris Heald
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
cnyabLOcGIKZNxvnSfwOuCBnjgoSOyJi/n48n1s+OPB/OmPJoWmhKu2DO4sUb4+K
|
31
31
|
/3Mhp5UWSl9SmDR1
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|