delete 메서드 body 사용하기?

kyung seob Lim·2022년 10월 18일
0

업무하다가 컨트롤러 delete메서드에 body를 받아야 하는 일이 생겨서 구현하려던 와중,

delete메서드에 body를 받는게 이질감이 느껴져 찾아보았다.

블로그 글들부터 찾아보다 rfc문서도 찾아보게 되었는데

delete body에 관한 두가지 rfc 문서를 찾을 수 있었고, 각각이 delete body에 대해 조금 다른 뉘앙스로 말하고 있다.

넷상에서 많이 인용되는 것은 7231으로 보이고 더 최근 문서인 9110을 신뢰하면 될듯하다.

RFC 7231: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

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.

HTTP Semantics

Although request message framing is independent of the method used, content received in a DELETE request has no generally defined semantics, cannot alter the meaning or target of the request, and might lead some implementations to reject the request and close the connection because of its potential as a request smuggling attack (Section 11.2 of [HTTP/1.1]). A client SHOULD NOT generate content in a DELETE request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported. An origin server SHOULD NOT rely on private agreements to receive content, since participants in HTTP communication are often unaware of intermediaries along the request chain.

아마 검색하게 되면 rfc7231을 기반으로한 글들을 많이 만나게 될 것 같은데, rfc9110이 최근 기준이기 때문에 이를 바탕으로 보면 될듯하다.

뒤에 문구가 영 와닿지 않지만 쓰지 말라는 뉘앙스가 더 강해진듯하다. 만일 꼭 써야한다면 웹서버나 프레임워크의 지원이 명확한지를 확인하고 넘어가는게 나을듯하다. 그리고 규약에 충실한 프레임워크일수록, 버전업 시 유의해야할지도 모른다.

0개의 댓글