Class: Zencoder::HTTP
- Inherits:
-
Object
show all
- Includes:
- Serializer
- Defined in:
- lib/zencoder/http.rb,
lib/zencoder/http/net_http.rb,
lib/zencoder/http/typhoeus.rb
Defined Under Namespace
Classes: NetHTTP, Typhoeus
Constant Summary
collapse
- CA_CHAIN_PATH =
File.expand_path(File.join(File.dirname(__FILE__), "http", "resources", "zencoder_ca_chain.crt"))
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Serializer
#decode, #encode, included
Constructor Details
#initialize(method, url, options = {}) ⇒ HTTP
Returns a new instance of HTTP.
21
22
23
24
25
|
# File 'lib/zencoder/http.rb', line 21
def initialize(method, url, options={})
self.method = method
self.url = url
self.options = options
end
|
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
11
12
13
|
# File 'lib/zencoder/http.rb', line 11
def default_options
@default_options
end
|
.http_backend ⇒ Object
Returns the value of attribute http_backend.
11
12
13
|
# File 'lib/zencoder/http.rb', line 11
def http_backend
@http_backend
end
|
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
8
9
10
|
# File 'lib/zencoder/http.rb', line 8
def method
@method
end
|
#options ⇒ Object
Returns the value of attribute options.
8
9
10
|
# File 'lib/zencoder/http.rb', line 8
def options
@options
end
|
#url ⇒ Object
Returns the value of attribute url.
8
9
10
|
# File 'lib/zencoder/http.rb', line 8
def url
@url
end
|
Class Method Details
.delete(url, options = {}) ⇒ Object
39
40
41
|
# File 'lib/zencoder/http.rb', line 39
def self.delete(url, options={})
new(:delete, url, options).perform_method
end
|
.get(url, options = {}) ⇒ Object
35
36
37
|
# File 'lib/zencoder/http.rb', line 35
def self.get(url, options={})
new(:get, url, options).perform_method
end
|
.post(url, body, options = {}) ⇒ Object
27
28
29
|
# File 'lib/zencoder/http.rb', line 27
def self.post(url, body, options={})
new(:post, url, options.merge(:body => body)).perform_method
end
|
.put(url, body, options = {}) ⇒ Object
31
32
33
|
# File 'lib/zencoder/http.rb', line 31
def self.put(url, body, options={})
new(:put, url, options.merge(:body => body)).perform_method
end
|
Instance Method Details
#default_options ⇒ Object
74
75
76
|
# File 'lib/zencoder/http.rb', line 74
def default_options
self.class.default_options
end
|
#http_backend ⇒ Object
70
71
72
|
# File 'lib/zencoder/http.rb', line 70
def http_backend
self.class.http_backend
end
|
#inspect ⇒ Object
78
79
80
|
# File 'lib/zencoder/http.rb', line 78
def inspect
"#{method.to_s.upcase} #{url}\nOptions: " + options.inspect
end
|
43
44
45
46
47
|
# File 'lib/zencoder/http.rb', line 43
def perform_method
process(http_backend.send(method, url, options))
rescue StandardError => e
raise HTTPError.new(e)
end
|