Sha256: 33b5c7b995890178065d9b81dbbd7b436c8ae596e025c6fea43120e85003faf4

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module Pione
  module Location
    class HTTPSLocation < HTTPLocation
      set_scheme "https"
      set_real_appendable false
      set_writable false

      # Send a request HTTPS Get and evaluate the block with the response.
      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

      # Send a request HTTPS Head and evaluate the block with the response.
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pione-0.3.2 lib/pione/location/https-location.rb
pione-0.3.1 lib/pione/location/https-location.rb
pione-0.3.0 lib/pione/location/https-location.rb
pione-0.2.2 lib/pione/location/https-location.rb