lib/streamly_ffi/connection.rb in streamly_ffi-0.2.3 vs lib/streamly_ffi/connection.rb in streamly_ffi-0.2.4

- old
+ new

@@ -1,12 +1,12 @@ module StreamlyFFI class Connection - attr_accessor :connection + attr_accessor :curl_handle def initialize - self.connection ||= StreamlyFFI::PersistentRequest.new + @curl_handle = StreamlyFFI::PersistentRequest.new end # A helper method to make HEAD requests a dead-simple one-liner # # Example: @@ -22,11 +22,11 @@ # # This method also accepts a block, which will stream the response headers in chunks to the caller def head(url, headers=nil, &block) opts = {:method => :head, :url => url, :headers => headers} opts[:response_header_handler] = block if block_given? - self.connection.execute(opts) + @curl_handle.execute(opts) end # A helper method to make HEAD requests a dead-simple one-liner # # Example: @@ -42,11 +42,11 @@ # # This method also accepts a block, which will stream the response body in chunks to the caller def get(url, headers=nil, &block) opts = {:method => :get, :url => url, :headers => headers} opts[:response_body_handler] = block if block_given? - self.connection.execute(opts) + @curl_handle.execute(opts) end # A helper method to make HEAD requests a dead-simple one-liner # # Example: @@ -63,11 +63,11 @@ # # This method also accepts a block, which will stream the response body in chunks to the caller def post(url, payload, headers=nil, &block) opts = {:method => :post, :url => url, :payload => payload, :headers => headers} opts[:response_body_handler] = block if block_given? - self.connection.execute(opts) + @curl_handle.execute(opts) end # A helper method to make HEAD requests a dead-simple one-liner # # Example: @@ -84,11 +84,11 @@ # # This method also accepts a block, which will stream the response body in chunks to the caller def put(url, payload, headers=nil, &block) opts = {:method => :put, :url => url, :payload => payload, :headers => headers} opts[:response_body_handler] = block if block_given? - self.connection.execute(opts) + @curl_handle.execute(opts) end # A helper method to make HEAD requests a dead-simple one-liner # # Example: @@ -104,13 +104,13 @@ # # This method also accepts a block, which will stream the response body in chunks to the caller def delete(url, headers={}, &block) opts = {:method => :delete, :url => url, :headers => headers} opts[:response_body_handler] = block if block_given? - self.connection.execute(opts) + @curl_handle.execute(opts) end def escape(_string) - self.connection.escape(_string) + @curl_handle.escape(_string) end end end \ No newline at end of file