lib/httpx/session.rb in httpx-0.17.0 vs lib/httpx/session.rb in httpx-0.18.0

- old
+ new

@@ -9,20 +9,21 @@ def initialize(options = EMPTY_HASH, &blk) @options = self.class.default_options.merge(options) @responses = {} @persistent = @options.persistent - wrap(&blk) if block_given? + wrap(&blk) if blk end def wrap begin prev_persistent = @persistent @persistent = true yield self ensure @persistent = prev_persistent + close unless @persistent end end def close(*args) pool.close(*args) @@ -224,10 +225,14 @@ end break end responses ensure - close(connections) unless @persistent + if @persistent + pool.deactivate(connections) + else + close(connections) + end end end @default_options = Options.new @default_options.freeze