FriendsOfSymfony/FOSRestBundle — pull request #786 by eriksencosta (2014-05-30 03:12:37+00:00)
Title: Change BodyListener to not throw exception for empty DELETE requests

When issuing an empty DELETE request with no `Content-Type` set and `throw_exception_on_unsupported_content_type` is set to `true`, the expected `UnsupportedMediaTypeHttpException` is thrown.

As there is no value to send the `Content-Type` header for a request with no entity-body and that on `DELETE` requests have no defined semantics, this PR changes this behavior, to support these requests.

The RFC 2616 define anything about the semantics of the entity body in DELETE (section [9.7][sec97]) requests. The HTTPBis latest draft (revision 26, section [4.3.5][sec435]) says:

A payload within a DELETE request message has no defined semantics;
sending a payload body on a DELETE request might cause some existing
implementations to reject the request.

Also, the RFC says an entity-body (the payload) is "only present in a message when a message-body is present" (section [7.2][sec72]) which the presence is "signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers" (section [4.3][sec43]).

This is a replacement for PR #785. The code from that PR does not check if the HTTP verb is `DELETE`.

[sec97]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7
[sec435]: http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-26#section-4.3.5
[sec72]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2
[sec43]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3