Sha256: e82f375902399fe11cbb02dfa43cd7b28c39b0d9969afa71bbfbd0f26f64f79e
Contents?: true
Size: 674 Bytes
Versions: 19
Compression:
Stored size: 674 Bytes
Contents
module Twitterscraper module Http module_function def get(url, headers = {}, proxy = nil, timeout = nil) timeout ||= 3 if proxy ip, port = proxy.split(':') http_class = Net::HTTP::Proxy(ip, port.to_i) else http_class = Net::HTTP end uri = URI.parse(url) http = http_class.new(uri.host, uri.port) http.use_ssl = true if url.match?(/^https/) http.open_timeout = timeout http.read_timeout = timeout req = Net::HTTP::Get.new(uri) headers.each do |key, value| req[key] = value end res = http.start { http.request(req) } res.body end end end
Version data entries
19 entries across 19 versions & 1 rubygems