I made a plugin for the YouTube API back in Rails' version 2.0.2 and
it was working good enough. Now I decided to try it in version 2.1.1
and it returns a 406 http error always.
So I tracked the issue and found that from version 2.1.0 to 2.1.1
there was a change in the
ActiveResource::Connection#build_request_headers method that updates
the request's header to "application/xml" by default with the GET http
method.
I really apologize for my english, I think it will be more clear with
an example:
Rails v 2.1.0:
module ActiveResource
class Connection
#.....
def build_request_headers(headers)
authorization_header.update(default_header).update(headers)
end
end
end
Rails v 2.1.1:
module ActiveResource
class Connection
#.....
def build_request_headers(headers, http_method=nil)
authorization_header.update(default_header).update(headers).update(http_format_header(http_method))
end
def http_format_header(http_method)
{HTTP_FORMAT_HEADER_NAMES[http_method] => format.mime_type}
end
end
end
So it's like if we were doing
connection.get('
http://gdata.youtube.com/feeds/api/videos?vq=rails',
'Accept' => 'application/xml')
and this causes a 406 http error always.... at least from YouTube API
Regards.