Sha256: 9071d3de4c48f84953f3dbf1388fd577d3f5d90c3f348cf069ccec96cd8b2fbb

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

module Pione
  module Location
    class HTTPSLocation < HTTPLocation
      set_scheme "https"

      define(:need_caching, true)
      define(:real_appendable, false)
      define(: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

6 entries across 6 versions & 1 rubygems

Version Path
pione-0.5.0 lib/pione/location/https-location.rb
pione-0.5.0.alpha.2 lib/pione/location/https-location.rb
pione-0.5.0.alpha.1 lib/pione/location/https-location.rb
pione-0.4.2 lib/pione/location/https-location.rb
pione-0.4.1 lib/pione/location/https-location.rb
pione-0.4.0 lib/pione/location/https-location.rb