Bug Tracker

Opened 14 years ago

Closed 12 years ago

#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
Blocked by: Blocking:


*/* 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 (6)

comment:1 Changed 14 years ago by flesler

Owner: set to flesler
Status: newassigned

comment:2 Changed 13 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 13 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.

comment:4 Changed 12 years ago by Rick Waldron

Keywords: ajaxrewrite added

comment:5 Changed 12 years ago by timmywil

Cc: jaubourg added

Please confirm this bug is still present in jQuery 1.6b1.

comment:6 Changed 12 years ago by john

Milestone: 1.31.5
Resolution: fixed
Status: assignedclosed

In fact, it doesn't seem to be - we have "q=0.01" in Ajax now. I'll mark this as fixed in 1.5.

Note: See TracTickets for help on using tickets.