lib/atom/feed.rb in atom-tools-0.9.1 vs lib/atom/feed.rb in atom-tools-0.9.2
- old
+ new
@@ -3,12 +3,10 @@
require "atom/entry"
require "atom/http"
module Atom
- class HTTPException < RuntimeError # :nodoc:
- end
class FeedGone < RuntimeError # :nodoc:
end
# A feed of entries. As an Atom::Element, it can be manipulated using
# accessors for each of its child elements. You can set them with any
@@ -161,28 +159,29 @@
# (note that this is different from Atom::Entry#updated!
def update!
raise(RuntimeError, "can't fetch without a uri.") unless @uri
headers = {}
+ headers["Accept"] = "application/atom+xml"
headers["If-None-Match"] = @etag if @etag
headers["If-Modified-Since"] = @last_modified if @last_modified
res = @http.get(@uri, headers)
+ # we'll be forgiving about feed content types.
+ res.validate_content_type(["application/atom+xml",
+ "application/xml",
+ "text/xml"])
+
if res.code == "304"
# we're already all up to date
return self
elsif res.code == "410"
raise Atom::FeedGone, "410 Gone (#{@uri})"
elsif res.code != "200"
raise Atom::HTTPException, "Unexpected HTTP response code: #{res.code}"
end
- media_type = res.content_type.split(";").first
- unless ["application/atom+xml", "application/xml", "text/xml"].member? media_type
- raise Atom::HTTPException, "An atom:feed shouldn't have Content-Type: #{res.content_type}"
- end
-
@etag = res["Etag"] if res["Etag"]
@last_modified = res["Last-Modified"] if res["Last-Modified"]
xml = res.body