Ticket #3408 (closed bug: fixed)
ajax accept quality score fix
| Reported by: | jonrhall | Owned by: | flesler |
|---|---|---|---|
| Priority: | major | Milestone: | 1.5 |
| Component: | ajax | Version: | 1.2.6 |
| Keywords: | ajaxrewrite | Cc: | jaubourg |
| Blocking: | Blocked by: |
Description
*/* is appended to the Accept header of an ajax request that uses dataType.
For "datatype: 'json'" the Accept header is:
"Accept: application/json, text/javascript, */*"
This means every mimetype has the same quality score of 1. Some servers may use order precedence but this is not within the spec ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
The fix is simply to reduce the score of */* to below 1:
(25/09/2008 nightly - line 2730) s.accepts[ s.dataType ] + ", */*" : to s.accepts[ s.dataType ] + ", */*;q=0.8" :
Change History
comment:2 Changed 4 years ago by ashb
Not sure if I should raise this as another bug or not, but I would like the option to not send the "*/*" at all.
On the subject of the ticket tho, is there a reason the code shouldn't just be s.accepts[ s.dataType ] + ', ' + s.accepts._default instead of using a hardcoded "*/*".
I will prepare a patch to this effect tomorrow
comment:3 Changed 4 years ago by james
This is also a problem when trying to override the prefered type. I suggest the */* have a quality of 0.1 and the default jquery provided types have a quality of < 1 (say 0.2). This will allow the caller to override the prefered type with a higher quality.
XML has a lot of various types other than the generic "application/xml" and "text/xml", so these generic types should have a lower quality over more specific XML types provided by the calling function.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
