Class: AzureBlob::Http
- Inherits:
-
Object
show all
- Includes:
- REXML
- Defined in:
- lib/azure_blob/http.rb
Overview
Defined Under Namespace
Classes: Error, FileNotFoundError, ForbiddenError, IntegrityError
Instance Method Summary
collapse
Constructor Details
#initialize(uri, headers = {}, signer: nil, metadata: {}, tags: {}, debug: false, raise_on_error: true) ⇒ Http
Returns a new instance of Http.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/azure_blob/http.rb', line 27
def initialize(uri, = {}, signer: nil, metadata: {}, tags: {}, debug: false, raise_on_error: true)
@raise_on_error = raise_on_error
@date = Time.now.httpdate
@uri = uri
@signer = signer
@headers = .merge(
Metadata.new(metadata).,
Tags.new(tags).,
)
@http = Net::HTTP.new(uri.hostname, uri.port)
@http.use_ssl = uri.port == 443
@http.set_debug_output($stdout) if debug
end
|
Instance Method Details
#delete ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/azure_blob/http.rb', line 80
def delete
sign_request("DELETE") if signer
@response = http.start do |http|
http.delete(uri, )
end
raise_error unless success?
response.body
end
|
#get ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/azure_blob/http.rb', line 44
def get
sign_request("GET") if signer
@response = http.start do |http|
http.get(uri, )
end
raise_error unless success?
response.body
end
|
#head ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/azure_blob/http.rb', line 71
def head
sign_request("HEAD") if signer
@response = http.start do |http|
http.head(uri, )
end
raise_error unless success?
response
end
|
#post(content = "") ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/azure_blob/http.rb', line 62
def post(content = "")
sign_request("POST") if signer
@response = http.start do |http|
http.post(uri, content, )
end
raise_error unless success?
response.body
end
|
#put(content = "") ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/azure_blob/http.rb', line 53
def put(content = "")
sign_request("PUT") if signer
@response = http.start do |http|
http.put(uri, content, )
end
raise_error unless success?
true
end
|
#success? ⇒ Boolean
89
90
91
|
# File 'lib/azure_blob/http.rb', line 89
def success?
status < Net::HTTPSuccess
end
|