7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/addressable/uri/fetch.rb', line 7
def fetch(limit: 50, use_get: :never)
Net::HTTP.start(hostname, port, use_ssl: scheme == 'https') do |http|
case use_get
when :always
response, uri = follow(http, self, limit, :get)
when :never
response, uri = follow(http, self, limit, :head)
when :on_error
response, uri = follow(http, self, limit, :head)
response, uri = follow(http, self, (limit / 10).to_i, :get) unless response.is_a?(Net::HTTPOK)
when :on_text
response, uri = follow(http, self, limit, :head)
response, uri = follow(http, self, (limit / 10).to_i, :get) if !response.is_a?(Net::HTTPOK) || text?(response.content_type)
end
response.uri ||= uri
response
end
end
|