def Utils.get_resp_html_info(resp, opts={})
case resp
when Net::HTTPSuccess
loc = URI.parse(resp['x-rbot-location'] || resp['location']) rescue nil
if loc and loc.fragment and not loc.fragment.empty?
opts[:uri_fragment] ||= loc.fragment
end
ret = DataStream.new(opts.dup)
ret[:headers] = resp.to_hash
ret[:text] = partial = opts[:full_body] ? resp.body : resp.partial_body(@@bot.config['http.info_bytes'])
filtered = Utils.try_htmlinfo_filters(ret)
if filtered
return filtered
elsif resp['content-type'] =~ /^text\/|(?:x|ht)ml/
ret.merge!(Utils.get_string_html_info(partial, opts))
end
return ret
else
raise UrlLinkError, "getting link (#{resp.code} - #{resp.message})"
end
end