@@ -27,7 +27,7 @@ def initialize(url, on_redirect: nil, auto_inflate: true, username: nil, passwor
2727 end
2828
2929 def download
30- if @url . respond_to? ( :host ) && curl_hosts . include? ( @url . host )
30+ if curl_host?
3131 return Curl . download ( @parsed_url . url )
3232 end
3333
@@ -81,10 +81,11 @@ def client
8181 def headers
8282 Hash . new . tap do |hash |
8383 hash [ :user_agent ] = @user_agent || "Feedbin"
84- hash [ :accept_encoding ] = "gzip, deflate" if @auto_inflate
85- hash [ :if_none_match ] = @etag unless @etag . nil?
86- hash [ :if_modified_since ] = @last_modified unless @last_modified . nil?
87- hash [ :authorization ] = basic_auth unless basic_auth . nil?
84+ hash [ :accept_encoding ] = "gzip, deflate" if @auto_inflate
85+ hash [ :accept ] = "application/xml" if accept_header_host?
86+ hash [ :if_none_match ] = @etag unless @etag . nil?
87+ hash [ :if_modified_since ] = @last_modified unless @last_modified . nil?
88+ hash [ :authorization ] = basic_auth unless basic_auth . nil?
8889 end
8990 end
9091
@@ -152,8 +153,14 @@ def request_error!(exception)
152153 end
153154 end
154155
155- def curl_hosts
156- ENV [ "FEEDKIT_CURL_HOSTS" ] &.split ( "," ) || [ ]
156+ def curl_host?
157+ hosts = ENV [ "FEEDKIT_CURL_HOSTS" ] &.split ( "," ) || [ ]
158+ @url . respond_to? ( :host ) && hosts . include? ( @url . host )
159+ end
160+
161+ def accept_header_host?
162+ hosts = ENV [ "FEEDKIT_ACCEPT_HOSTS" ] &.split ( "," ) || [ ]
163+ @url . respond_to? ( :host ) && hosts . include? ( @url . host )
157164 end
158165 end
159166end
0 commit comments