This project is archived and is in readonly mode.
Removed http header Accept by default
Reported by Edgar Suarez | September 15th, 2008 @ 06:27 PM
This patch fix the 406 Not Acceptable http error when working with the YouTube API.
http = Net::HTTP.new("gdata.youtube.com")
response = http.head('/feeds/api/videos?vq=rails', 'Accept' => 'application/xml')
response.code # => "406"
response = http.head('/feeds/api/videos?vq=rails')
response.code # => "200"
See http://groups.google.com/group/r... for details.
Comments and changes to this ticket
-
Michael Koziarski September 16th, 2008 @ 10:23 AM
- Tag changed from accept, activeresource, formats, header, patch, xml, youtube to accept, activeresource, formats, header, patch, xml, youtube
So what is it about this that breaks the youtube api?
You should be able to override the Accept header to contain the values supported by the api? The 406 reply you're receiving is just because gdata can't reply with that content type:
406 = "Not Acceptable",
-
Edgar Suarez September 17th, 2008 @ 01:31 AM
Yes, it's supposed to be able to change the accept header but it just ignores my header because the method overrides it:
#ActiveResource::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
So even when I do:
connection.get('/feeds/api/videos?vq=rails', {'Accept' => 'application/xhtml+xml'}) # or any other mime type
It is overridden with 'application/xml' which is the default mime for the get method.
I've been thinking and actually there should be a cleaner way to fix this (maybe a reverse update), but I just made the patch in hurry in the meantime.
Regards.
-
Michael Koziarski September 17th, 2008 @ 10:45 AM
- Assigned user set to Michael Koziarski
- Milestone changed from 2.x to 2.1.2
OK, so if you can upload a new version of this patch which:
1) Includes a test case (use mocha if it's easier) 2) Does a reverse merge instead
I think we'll be good to go
-
Edgar Suarez September 17th, 2008 @ 09:29 PM
Ok, so good so far... here is the cleaner patch with the proper test using mocha.
Hope it's good enough to go.
-
Michael Koziarski September 18th, 2008 @ 10:01 AM
- Milestone cleared.
I've reverted the change that introduced this from 2-1-stable, so this now needs to be addressed in 2.2.0
-
rbpandey September 23rd, 2008 @ 08:28 PM
This seems to have been applied to trunk already. Can this be marked as resolved?
-
Michael Koziarski September 23rd, 2008 @ 08:30 PM
- State changed from new to committed
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 450 format patches to support serializing data out in the correct format with correct http request headers per http method type This patch actually seems to have triggered both #1011 an...