Class: Pione::Location::HTTPSLocation

Inherits:
HTTPLocation show all
Defined in:
lib/pione/location/https-location.rb

Constant Summary

Constants inherited from DataLocation

DataLocation::KNOWN_ATTRS

Instance Attribute Summary

Attributes inherited from DataLocation

#path, #uri

Attributes inherited from BasicLocation

#address

Instance Method Summary collapse

Methods inherited from HTTPLocation

#copy, #directory?, #exist?, #file?, #mtime, #read, #size

Methods inherited from DataLocation

#+, #==, #append, #as_directory, #basename, #cached?, #copy, #create, #ctime, define, #delete, #directory?, #directory_entries, #dirname, #entries, #exist?, #extname, #file?, #file_entries, #hash, #initialize, #inspect, #link, #local, #local?, #mkdir, #move, #mtime, #mtime=, need_caching?, #read, real_appendable?, #rebuild, #rel_entries, set_scheme, #sha1, #size, #turn, #update, writable?, #write

Methods inherited from BasicLocation

#==, #hash, #initialize, #inspect, location_type

Constructor Details

This class inherits a constructor from Pione::Location::DataLocation

Instance Method Details

#http_get(&b) ⇒ Object

Send a request HTTPS Get and evaluate the block with the response.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pione/location/https-location.rb', line 11

def http_get(&b)
  http = Net::HTTP.new(@uri.host, @uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  req = Net::HTTP::Get.new(@uri.path)
  res = http.request(req)
  if res.kind_of?(Net::HTTPSuccess)
    return b.call(res)
  else
    raise NotFound.new(@uri)
  end
end

#http_head(&b) ⇒ Object

Send a request HTTPS Head and evaluate the block with the response.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pione/location/https-location.rb', line 25

def http_head(&b)
  http = Net::HTTP.new(@uri.host, @uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  req = Net::HTTP::Head.new(@uri.path)
  res = http.request(req)
  if res.kind_of?(Net::HTTPSuccess)
    return b.call(res)
  else
    raise NotFound(@uri)
  end
end