Sha256: bd2f0e1bc53219bf3c5d49338ebc2312ccad32f62d7a4280235af1b8e5d5bfed

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

module Iconoclasm
  module Downloader

    @@user_agent = %Q{Mozilla/5.0 (compatible; Iconoclasm/1.0; +http://github.com/sander6/iconoclasm)}
    
    def self.user_agent=(agent)
      @@user_agent = agent
    end
    
    def self.user_agent
      @@user_agent
    end
    
    def user_agent
      @@user_agent
    end
    
    def get(url)
      c = curl(url)
      c.http_get
      c
    end
    
    def head(url)
      c = curl(url)
      c.http_head
      c
    end
    
    private
    
    def curl(url)
      Curl::Easy.new(url) do |curl|
        curl.useragent        = user_agent
        curl.follow_location  = true
        curl.timeout          = Iconoclasm.timeout || 1000
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iconoclasm-1.0.9 lib/iconoclasm/downloader.rb