Sha256: 4afde2241470c351afff72eb75a54514b4b4f555550e56c438223cbc07a0cb8a

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

module Iconoclasm
  module Downloader

    @@user_agent = %Q{Mozilla/5.0 (compatible; Iconoclasm/#{Iconoclasm.version}; +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.8 lib/iconoclasm/downloader.rb