generate functionWed, 01 Mar 2023

get contnet type from url

def content_type(url) url = URI.parse(url) Net::HTTP.start(url.host, url.port) do |http| return http.head(url.path)['Content-Type'] end end content_type(url)

Questions about programming?Chat with your personal AI assistant