Class: Ethon::Easy
- Inherits:
-
Object
- Object
- Ethon::Easy
- Extended by:
- Features
- Includes:
- Callbacks, Header, Http, Informations, Operations, Options, ResponseCallbacks
- Defined in:
- lib/ethon/easy.rb,
lib/ethon/easy/form.rb,
lib/ethon/easy/http.rb,
lib/ethon/easy/util.rb,
lib/ethon/easy/header.rb,
lib/ethon/easy/mirror.rb,
lib/ethon/easy/params.rb,
lib/ethon/easy/options.rb,
lib/ethon/easy/features.rb,
lib/ethon/easy/http/get.rb,
lib/ethon/easy/http/put.rb,
lib/ethon/easy/callbacks.rb,
lib/ethon/easy/http/head.rb,
lib/ethon/easy/http/post.rb,
lib/ethon/easy/queryable.rb,
lib/ethon/easy/debug_info.rb,
lib/ethon/easy/http/patch.rb,
lib/ethon/easy/operations.rb,
lib/ethon/easy/http/custom.rb,
lib/ethon/easy/http/delete.rb,
lib/ethon/easy/http/options.rb,
lib/ethon/easy/http/putable.rb,
lib/ethon/easy/informations.rb,
lib/ethon/easy/http/postable.rb,
lib/ethon/easy/http/actionable.rb,
lib/ethon/easy/response_callbacks.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Callbacks, Features, Header, Http, Informations, Operations, Options, Queryable, ResponseCallbacks, Util Classes: DebugInfo, Form, Mirror, Params
Constant Summary
Constants included from Informations
Informations::AVAILABLE_INFORMATIONS
Instance Attribute Summary collapse
-
#return_code ⇒ Symbol
Returns the curl return code.
Attributes included from Options
Instance Method Summary collapse
-
#dup ⇒ Object
Clones libcurl session handle.
-
#escape(value) ⇒ String
private
Url escapes the value.
-
#initialize(options = {}) ⇒ Easy
constructor
Initialize a new Easy.
-
#log_inspect ⇒ String
Return pretty log out.
- #mirror ⇒ Object
-
#reset ⇒ Object
Reset easy.
-
#set_attributes(options) ⇒ Object
Set given options.
-
#to_hash ⇒ Hash
Returns the informations available through libcurl as a hash.
Methods included from Features
supports_asynch_dns?, supports_zlib?
Methods included from ResponseCallbacks
#body, #complete, #headers, #on_body, #on_complete, #on_headers, #on_progress, #progress
Methods included from Operations
#cleanup, #handle, #handle=, #perform, #prepare
Methods included from Http
Methods included from Header
#compose_header, #header_list, #headers, #headers=
Methods included from Options
#escape=, #escape?, #multipart=, #multipart?
Methods included from Callbacks
#body_write_callback, #debug_callback, #header_write_callback, included, #progress_callback, #read_callback, #set_callbacks, #set_progress_callback, #set_read_callback
Methods included from Informations
Constructor Details
#initialize(options = {}) ⇒ Easy
Initialize a new Easy. It initializes curl, if not already done and applies the provided options. Look into Options to see what you can provide in the options hash.
218 219 220 221 222 |
# File 'lib/ethon/easy.rb', line 218 def initialize( = {}) Curl.init set_attributes() set_callbacks end |
Instance Attribute Details
#return_code ⇒ Symbol
Returns the curl return code.
201 202 203 |
# File 'lib/ethon/easy.rb', line 201 def return_code @return_code end |
Instance Method Details
#dup ⇒ Object
Clones libcurl session handle. This means that all options that is set in
the current handle will be set on duplicated handle.
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/ethon/easy.rb', line 265 def dup e = super e.handle = Curl.easy_duphandle(handle) e.instance_variable_set(:@body_write_callback, nil) e.instance_variable_set(:@header_write_callback, nil) e.instance_variable_set(:@debug_callback, nil) e.instance_variable_set(:@progress_callback, nil) e.set_callbacks e end |
#escape(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Url escapes the value.
285 286 287 288 289 290 |
# File 'lib/ethon/easy.rb', line 285 def escape(value) string_pointer = Curl.easy_escape(handle, value, value.bytesize) returned_string = string_pointer.read_string Curl.free(string_pointer) returned_string end |
#log_inspect ⇒ String
Return pretty log out.
311 312 313 |
# File 'lib/ethon/easy.rb', line 311 def log_inspect "EASY #{mirror.log_informations.map{|k, v| "#{k}=#{v}"}.flatten.join(' ')}" end |
#mirror ⇒ Object
301 302 303 |
# File 'lib/ethon/easy.rb', line 301 def mirror @mirror ||= Mirror.from_easy(self) end |
#reset ⇒ Object
Reset easy. This means resetting all options and instance variables. Also the easy handle is resetted.
249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/ethon/easy.rb', line 249 def reset @url = nil @escape = nil @hash = nil @on_complete = nil @on_headers = nil @on_body = nil @on_progress = nil @procs = nil @mirror = nil Curl.easy_reset(handle) set_callbacks end |
#set_attributes(options) ⇒ Object
Set given options.
234 235 236 237 238 239 240 241 242 |
# File 'lib/ethon/easy.rb', line 234 def set_attributes() .each_pair do |key, value| method = "#{key}=" unless respond_to?(method) raise Errors::InvalidOption.new(key) end send(method, value) end end |
#to_hash ⇒ Hash
Returns the informations available through libcurl as a hash.
296 297 298 299 |
# File 'lib/ethon/easy.rb', line 296 def to_hash Kernel.warn("Ethon: Easy#to_hash is deprecated and will be removed, please use #mirror.") mirror.to_hash end |