Skip to content

Instantly share code, notes, and snippets.

@mrkurt
Created February 21, 2009 23:37
Show Gist options
  • Save mrkurt/68229 to your computer and use it in GitHub Desktop.
Save mrkurt/68229 to your computer and use it in GitHub Desktop.
def from_url(url)
raise "No url specified" if url.nil?
easy = Curl::Easy.perform(url) do |c|
c.headers["If-Modified-Since"] = @last_modified unless @last_modified.nil?
c.headers["If-None-Match"] = @etag unless @etag.nil?
c.follow_location = true
end
if easy.response_code == 200
@source_url = url
parse_response(easy)
elsif easy.response_code != 304 #not modified is fine
raise
end
easy.response_code
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment