Sha256: 1753617f0c41fe7ade67ad2b71c12c4bbafb8a3e480f845199b3534016d54001
Contents?: true
Size: 704 Bytes
Versions: 4
Compression:
Stored size: 704 Bytes
Contents
require 'net/http' module GoogleWebTranslate # HTTP client functionality class HTTPClient def self.user_agent gem_version = "GoogleWebTranslate/#{VERSION}" platform_version = "(#{RUBY_PLATFORM}) #{RUBY_ENGINE}/#{RUBY_VERSION}" gem_version + ' ' + platform_version end def initialize(options = {}) @user_agent = options[:user_agent] || self.class.user_agent end def get(url) uri = URI.parse(url) request = Net::HTTP::Get.new(uri) request['User-Agent'] = @user_agent options = { use_ssl: uri.scheme == 'https' } Net::HTTP.start(uri.host, uri.port, options) do |http| http.request(request) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems