class Net::HTTPResponse

Public Instance Methods

raise_unless(status) click to toggle source
# File lib/aliyunoss/extension.rb, line 41
def raise_unless(status)
  raise OssException.new(self) unless status === self
  self
end
to_acl_status() click to toggle source
# File lib/aliyunoss/extension.rb, line 80
def to_acl_status
  raise message unless Net::HTTPOK === self
  Nokogiri::XML(self.body).xpath('//Grant')[0].content
end
to_buckets() click to toggle source
# File lib/aliyunoss/extension.rb, line 46
def to_buckets
  raise message unless Net::HTTPOK === self
  nodes = Nokogiri::XML(self.body).xpath('//Bucket') rescue []
  nodes.map do |node|
    bucket = Aliyun::Oss::Bucket.new
    node.elements.each {|e| bucket.send("#{e.name.underscore}=".to_sym, e.content) rescue nil }
    bucket
  end
end
to_logging_status() click to toggle source
# File lib/aliyunoss/extension.rb, line 66
def to_logging_status
  raise message unless Net::HTTPOK === self
  node = Nokogiri::XML(self.body).xpath('//LoggingEnabled') rescue []
  hash = Hash.new
  node[0].elements.each {|e| hash[e.name.underscore] = e.content }
  hash                                                     
end
to_multipart_id() click to toggle source
# File lib/aliyunoss/extension.rb, line 85
def to_multipart_id
  raise message unless Net::HTTPOK === self
  Nokogiri::XML(body).xpath('//UploadId').first.content      
end
to_mutlipart_task() click to toggle source
# File lib/aliyunoss/extension.rb, line 90
def to_mutlipart_task
  raise message unless Net::HTTPOK === self
  tasks = Array.new
  nodes = Nokogiri::XML(response.body).xpath('//Upload')
  nodes.each do |node|
    path = '/' + node.xpath('Key').first.content
    id = node.xpath('UploadId').first.content
    tasks << {'path'=> path, 'upload_id' => id}
  end
  tasks
end
to_objects() click to toggle source
# File lib/aliyunoss/extension.rb, line 56
def to_objects
  raise message unless Net::HTTPOK === self
  nodes = Nokogiri::XML(self.body).xpath('//Contents') rescue []
  nodes.map do |node|
    hash = Hash.new
    node.elements.each {|e| hash[e.name.underscore] = e.content unless e.name == 'Owner' }
    hash
  end      
end
to_website_status() click to toggle source
# File lib/aliyunoss/extension.rb, line 74
def to_website_status
  raise message unless Net::HTTPOK === self
  xml = Nokogiri::XML(self.body)
  {'index_page' => xml.xpath('//Suffix')[0].content, 'error_page' => xml.xpath('//Key')[0].content } rescue {}
end