Bug Tracker

Modify

Ticket #4664 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

$.ajax() WITH null data property in config object results in missing Content-Length header in FF3

Reported by: rmurphey Owned by:
Priority: minor Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

(See the full thread at  http://groups.google.com/group/jquery-dev/browse_thread/thread/fe76bdc97c6f727b/c178b67e55b2d3d6?lnk=gst&q=length)

I had an ajax request as follows:

var myData = null;

$.ajax({
  'url' : 'foo.php',
  'data' : myData,
  'type' : 'POST',
  'dataType' : 'json',
  'success' : function(j) {
    // whatever
  }

});

Client was reporting a 411 HTTP response code on the request -- their proxy was expecting a Content-Length header on the request, and wasn't getting one. This also occurred if myData was undefined. It did *not* occur when myData was {}.

We hadn't detected this error internally because our requests weren't proxy'd. It seems Content-Length "should" always be there

 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

and should be 0 if myData is null or undefined.

I'm not sure whether this is just a Firefox issue, or something that jQuery should address in the spirit of abstracting away browser differences?

Change History

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

Dup of #4044.

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.