Bug Tracker

Modify

Ticket #3408 (closed bug: fixed)

Opened 5 years ago

Last modified 2 years ago

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:1 Changed 5 years ago by flesler

  • Owner set to flesler
  • Status changed from new to assigned

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.

comment:4 Changed 2 years ago by rwaldron

  • Keywords ajaxrewrite added

comment:5 Changed 2 years ago by timmywil

  • Cc jaubourg added

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

comment:6 Changed 2 years ago by john

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Milestone changed from 1.3 to 1.5

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.