Bug Tracker

Modify

Ticket #7285 (closed bug: fixed)

Opened 3 years ago

Last modified 20 months ago

Ajax Data Body Regression

Reported by: Mal Owned by: dmethvin
Priority: low Milestone: 1.4.4
Component: ajax Version: 1.4.3
Keywords: Cc:
Blocking: Blocked by:

Description

Problem:
Any data sent using GET, HEAD or DELETE is ignored. This is inappropriate behavior for DELETE as the spec leaves it open to carrying a data body.

Test Case:
 http://www.locatetv.com/blog/test/test.php
PUT echos as expected, DELETE does not.

Cause:
 http://github.com/jquery/jquery/commit/c4e653237f258ce618ad5a9ec677917166fbed16

Possible Solution:
 http://github.com/malibu/jquery/commit/e0a604b90e1d927233d936851c07a427eaa53a2d
Remove DELETE from rnoContent (ajax.js:7).

Change History

comment:1 Changed 3 years ago by dmethvin

Can you provide a link to the spec? When researching it I convinced myself DELETE couldn't have a body.

comment:2 Changed 3 years ago by Mal

HTTP 1.1 DELETE Spec can be found here in section 9.7
 http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7

This question was also asked on StackOverflow, and has a very good answer:
 http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request

Basic gist of it is that; the only method forbidden from having an entity body is TRACE (see section 9.8 "A TRACE request MUST NOT include an entity."), all other methods offer no such clarity.

Perhaps the ideal solution would be to ban bodies from TRACE, and fallback to checking the contents of data for everything else.

Last edited 3 years ago by Mal (previous) (diff)

comment:3 Changed 3 years ago by dmethvin

  • Owner set to dmethvin
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to ajax
  • Milestone changed from 1.5 to 1.4.4

Ugh, thanks Mal. I agree after reading the spec and SO link.

Right now, $.ajax automagically serializes the data property and appends it to the url string for methods that it thinks can't have a body. We can't do that if everything can have a body.

 http://github.com/jquery/jquery/blob/master/src/ajax.js#L218

 http://github.com/jquery/jquery/blob/master/src/ajax.js#L280

(Need to see if we can do that sooner to avoid duplication.)

Let's all agree that GET and HEAD can't have a body, no matter what the spec says. That way we can retain url-serialization for data only on GET (which we already do) and HEAD (which I'll fix in the patch).

comment:4 Changed 3 years ago by snover

Regression from what version of jQuery?

comment:5 Changed 3 years ago by mal

@dmethvin:
Sounds good, happy to help.

@snover:
It was working as expected in 1.4.2.

comment:6 Changed 3 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Allow DELETE requests to have a content body, and properly serialize data to the url for HEAD requests. Fixes #7285.

Changeset: 09022e0b09db71259751e7146bb64727615028af

comment:7 Changed 20 months ago by jaubourg

#11586 is a duplicate of this ticket.

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.