Module: StreamlyFFI
- Defined in:
- lib/streamly_ffi.rb,
lib/streamly_ffi/base.rb,
lib/streamly_ffi/request.rb,
lib/streamly_ffi/version.rb,
lib/streamly_ffi/connection.rb,
lib/streamly_ffi/persistent_request.rb
Defined Under Namespace
Modules: Base Classes: Connection, ConnectionFailed, Error, HostResolutionError, PartialFileError, PersistentRequest, Request, TimeoutError, TooManyRedirects, URLFormatError, UnsupportedProtocol
Constant Summary collapse
- VERSION =
"0.2.6"
Class Method Summary collapse
-
.connect ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner.
-
.delete(url, headers = {}, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner.
-
.get(url, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner.
-
.head(url, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner.
-
.post(url, payload, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner.
-
.put(url, payload, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner.
Class Method Details
.connect ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner
Example:
Streamly.delete("www.somehost.com/some_resource/1")
Streamly.delete("www.somehost.com/some_resource/1") do |chunk|
# do something with _chunk_
end
Parameters: url
should be a String, the url to request headers
should be a Hash and is optional
This method also accepts a block, which will stream the response body in chunks to the caller
142 143 144 |
# File 'lib/streamly_ffi.rb', line 142 def self.connect Connection.new end |
.delete(url, headers = {}, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner
Example:
Streamly.delete("www.somehost.com/some_resource/1")
Streamly.delete("www.somehost.com/some_resource/1") do |chunk|
# do something with _chunk_
end
Parameters: url
should be a String, the url to request headers
should be a Hash and is optional
This method also accepts a block, which will stream the response body in chunks to the caller
122 123 124 125 126 |
# File 'lib/streamly_ffi.rb', line 122 def self.delete(url, headers={}, &block) opts = {:method => :delete, :url => url, :headers => headers} opts.merge!({:response_body_handler => block}) if block_given? Request.execute(opts) end |
.get(url, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner
Example:
Streamly.get("www.somehost.com/some_resource/1")
Streamly.get("www.somehost.com/some_resource/1") do |chunk|
# do something with _chunk_
end
Parameters: url
should be a String, the url to request headers
should be a Hash and is optional
This method also accepts a block, which will stream the response body in chunks to the caller
60 61 62 63 64 |
# File 'lib/streamly_ffi.rb', line 60 def self.get(url, headers=nil, &block) opts = {:method => :get, :url => url, :headers => headers} opts.merge!({:response_body_handler => block}) if block_given? Request.execute(opts) end |
.head(url, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner
Example:
Streamly.head("www.somehost.com/some_resource/1")
Streamly.head("www.somehost.com/some_resource/1") do |header_chunk|
# do something with _header_chunk_
end
Parameters: url
should be a String, the url to request headers
should be a Hash and is optional
This method also accepts a block, which will stream the response headers in chunks to the caller
40 41 42 43 44 |
# File 'lib/streamly_ffi.rb', line 40 def self.head(url, headers=nil, &block) opts = {:method => :head, :url => url, :headers => headers} opts.merge!({:response_header_handler => block}) if block_given? Request.execute(opts) end |
.post(url, payload, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner
Example:
Streamly.post("www.somehost.com/some_resource", "asset[id]=2&asset[name]=bar")
Streamly.post("www.somehost.com/some_resource", "asset[id]=2&asset[name]=bar") do |chunk|
# do something with _chunk_
end
Parameters: url
should be a String (the url to request) and is required payload
should be a String and is required headers
should be a Hash and is optional
This method also accepts a block, which will stream the response body in chunks to the caller
81 82 83 84 85 |
# File 'lib/streamly_ffi.rb', line 81 def self.post(url, payload, headers=nil, &block) opts = {:method => :post, :url => url, :payload => payload, :headers => headers} opts.merge!({:response_body_handler => block}) if block_given? Request.execute(opts) end |
.put(url, payload, headers = nil, &block) ⇒ Object
A helper method to make HEAD requests a dead-simple one-liner
Example:
Streamly.put("www.somehost.com/some_resource/1", "asset[name]=foo")
Streamly.put("www.somehost.com/some_resource/1", "asset[name]=foo") do |chunk|
# do something with _chunk_
end
Parameters: url
should be a String (the url to request) and is required payload
should be a String and is required headers
should be a Hash and is optional
This method also accepts a block, which will stream the response body in chunks to the caller
102 103 104 105 106 |
# File 'lib/streamly_ffi.rb', line 102 def self.put(url, payload, headers=nil, &block) opts = {:method => :put, :url => url, :payload => payload, :headers => headers} opts.merge!({:response_body_handler => block}) if block_given? Request.execute(opts) end |