Bug Tracker

Opened 5 years ago

Closed 5 years ago

#14533 closed bug (duplicate)

Content-Type of application/json with Content-Length: 0 causes jQuery to fail the request

Reported by: aaron.l.france@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.1.0-beta1
Keywords: Cc:
Blocked by: Blocking:

Description

Content-Type of application/json with Content-Length: 0 causes jQuery to fail the request.

The reasoning is that the empty string is not valid JSON. Whilst, technically correct (the best kind of correct!), jQuery shouldn't really fail in such a non-intuitive way.

The Content-Type should be used as a 'best try first' parsing for the response. If the response says "application/banana" by all means, try to parse it as a banana, but if it's a peach, then surely we should be able to continue?

After all, a remote server shouldn't be able to crash our application (barring application programmer error).

Change History (1)

comment:1 Changed 5 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Duplicate of #13756.
Certainly a remote server could "crash" your application by returning invalid json, such as {bad or an empty string. If you don't trust the server, declare an explicit dataType: text and parse it yourself, then handle (or ignore) the error.

Note: See TracTickets for help on using tickets.