메소드들을 살펴보면,
PUT과 PATCH 메소드는 얼핏 비슷해 보이는 메소드처럼 느껴진다.
PUT 메소드
PUT 메소드는 요청 페이로드를 사용해 새로운 리소스를 생성하거나,
대상 리소스를 나타내는 데이터를 대체합니다.
PATCH 메소드
PATCH 메소드는 리소스의 부분적인 수정을 할 때에 사용됩니다.
둘다 수정을 한다는 개념을 공유하고 있으나,
구동방식에 따라 명등성과 안정성에 차이가 난다.
아래의 설명을 살펴보자.
In a PUT request, the enclosed entity
is considered to be a modified version of the resource stored on the
origin server, and the client is requesting that the stored version
be replaced. With PATCH, however, the enclosed entity contains a set
of instructions describing how a resource currently residing on the
origin server should be modified to produce a new version. The PATCH
method affects the resource identified by the Request-URI, and it
also MAY have side effects on other resources; i.e., new resources
may be created, or existing ones modified, by the application of a
PATCH.
PUT 요청에서 동봉된 개체는 서버에 저장된 소스의 수정본으로 간주된다.
따라서 클라이언트는 서버에 저장된 소스의 교체를 요청하는 것이다.
하지만 PATCH 메소드는 동봉된 개체가 서버에 있는 소스가 어떻게 변경되어야 하는지 지시사항들이 들어있다.
PATCH 메소드는 Request-URI로 구별된 리소스를 변형하고 다른 리소스에 사이드 이펙트를 발생시킬수도 있다.
새로운 리소스가 생성 되거나 기존의 것이 변경될 수 도 있다는 의미이다.
'HTTP' 카테고리의 다른 글
[Socket.io] Socket.io란 무엇인가? (0) | 2022.03.05 |
---|---|
HTTP MIME (0) | 2021.11.18 |
HTTP 상태 코드 (0) | 2021.11.18 |
HTTP 메소드의 멱등성 (0) | 2021.11.18 |
HTTP 요청 메서드 (0) | 2021.11.18 |