[ActiveResource] Sets Accept header to 'application/xml' by default

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.

This would appear to be caused by:

http://github.com/rails/rails/commit/caabe228bc6c6e920043334d717e72093559e118

Could you submit a patch which includes a failing test case?

Well, so this is my first patch I make. Hope I did it ok.

I had some problems with the tests since http mock does not a true
call to the remote service, I did tests creating a bare http instance
that demonstrates this error.

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1053-removed-http-header-accept-by-default

Regards.