Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

skipping Content-Type check for http responses containing feed data #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/atom/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# used under the terms of the MIT license

require "md5"
require "digest/md5"

def normalize_header_names _headers
headers = {}
Expand Down
5 changes: 5 additions & 0 deletions lib/atom/element.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "time"
require "rexml/element"
require "uri"

require 'uri'

Expand Down Expand Up @@ -597,6 +598,10 @@ def self.parse xml, base = ''

# URL absolutization
if !e.base.empty? and e.href
# url-encode necessary chars
e.base = URI.escape e.base
e.href = URI.escape e.href

e.href = (e.base.to_uri + e.href).to_s
end

Expand Down
10 changes: 6 additions & 4 deletions lib/atom/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def merge other_feed
# changes, new entries, &c.
#
# (note that this is different from Atom::Entry#updated!
def update!
def update!(check_content_type = true)
raise(RuntimeError, "can't fetch without a uri.") unless @uri

res = @http.get(@uri, "Accept" => "application/atom+xml")
Expand All @@ -172,9 +172,11 @@ def update!
end

# we'll be forgiving about feed content types.
res.validate_content_type(["application/atom+xml",
"application/xml",
"text/xml"])
if check_content_type
res.validate_content_type(["application/atom+xml",
"application/xml",
"text/xml"])
end

@etag = res["ETag"] if res["ETag"]

Expand Down
2 changes: 1 addition & 1 deletion lib/atom/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

require "atom/cache"

require "sha1"
require "digest/sha1"
require "digest/md5"

module URI # :nodoc: all
Expand Down