manticore 0.3.6-java → 0.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6318aab0fbc27d86f181429c393c9d4e984738e
4
- data.tar.gz: f4f55510384f05eab14ca8ba3f701264fc89ddef
3
+ metadata.gz: 19e1191d64f814d4e5eeac2a74ea1cb9ec964451
4
+ data.tar.gz: 973396d996c2d9bb26491fe88e8566ee27809304
5
5
  SHA512:
6
- metadata.gz: 5168f1c0805a6b982756b6c136d019582a0c23adee517472fd6b9ab84d2657071e5eadfcaf08e5ad85e50c825e2e3083926b417d7c83ef0d63d2e2f8ea5836d2
7
- data.tar.gz: 4693c3b2df44572cbfa0bb5a986400dc3e021717cd19d71b87795ef8da46ec2721f13d4ab82e9ed3c6b55ad2136b6f2908dde17e01ca4e110ac960ebb4698b1e
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.3
1
+ ## v0.4.1 (pending)
2
+
3
+ ### v0.4.0
2
4
 
3
- ## v0.3.7 (pending)
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
 
@@ -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(&:get)
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
- config.set_proxy get_proxy_host(req_options[:proxy]) if req_options[:proxy]
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
- auth_from_options(options, context) if options.key? :auth
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
- HttpHost.new(opt[:host], (opt[:port] || 80).to_i, opt[:scheme] || "http")
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
- if options[:auth]
500
+ proxy = options.fetch(:proxy, {})
501
+ if options[:auth] || proxy[:user] || proxy[:username]
486
502
  provider = BasicCredentialsProvider.new
487
- username = options[:auth][:user] || options[:auth][:username]
488
- password = options[:auth][:pass] || options[:auth][:password]
489
- provider.set_credentials AuthScope::ANY, UsernamePasswordCredentials.new(username, password)
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
@@ -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. Users should never call this directly.
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 &:call
230
+ @handlers[:complete].each {|h| h.call(self) }
230
231
  end
231
232
  end
232
233
  end
@@ -1,3 +1,3 @@
1
1
  module Manticore
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.6
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-03-14 00:00:00.000000000 Z
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