Sha256: daeb65bf13befcd485885f73e2c48f75986000c7287b53d4c0973e5e8a011510

Contents?: true

Size: 683 Bytes

Versions: 14

Compression:

Stored size: 683 Bytes

Contents

require 'uri'

require 'murlsh'

module Murlsh

  # Try to fetch the content length, content type and title of a url.
  class AddPre50LookupContentTypeTitle < Plugin

    @hook = 'add_pre'

    def self.run(url, config)
      headers = {}
      headers['User-Agent'] = config['user_agent']  if config['user_agent']

      content_length = url.ask.content_length(:headers => headers)
      if content_length and not content_length.empty?
        url.content_length = content_length
      end

      url.content_type = url.ask.content_type(:headers => headers)

      unless url.user_supplied_title?
        url.title = url.ask.title(:headers => headers)
      end
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
murlsh-1.9.3 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.9.2 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.9.1 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.9.0 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.8.0 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.7.1 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.7.0 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.6.1 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.6.0 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.5.0 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.4.1 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.4.0 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.3.1 plugins/add_pre_50_lookup_content_type_title.rb
murlsh-1.3.0 plugins/add_pre_50_lookup_content_type_title.rb