Sha256: af6580886e2d700fef1a19afdd4ce7b1258ed185d6421a94e98538d550f0dd2b

Contents?: true

Size: 406 Bytes

Versions: 1

Compression:

Stored size: 406 Bytes

Contents

require "net/http"
require "addressable/uri"

class PageDownloader
  class RemoteContentFetcher
    def fetch(page_url)
      puts "Fetching: #{page_url}"
      url = Addressable::URI.parse(page_url)
      ssl = url.scheme == "https"

      Net::HTTP.start(url.host, url.port, use_ssl: ssl) do |http|
        request = Net::HTTP::Get.new(url)
        http.request(request).body
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
page_downloader-1.0 lib/page_downloader/remote_content_fetcher.rb