3. Method 의미
• GET
• 리소스 취득 (read)
• POST
• 서브 리소스의 작성, 리소스 데이터 추가, 그 외.. (create)
• PUT
• 리소스 갱신, 리소스 작성 (update, create)
• DELETE
• 리소스 삭제 (delete)
• HEAD
• 리소스의 헤더 취득
• OPTIONS
• 리소스가 서포트 하는 메서드의 취득
• TRACE
• 자기 앞으로 요청 메시지를 반환(루프 백) 시험
• CONNECT
• 프록시 동작의 터널 접속으로 변경
4. GET
• 리소스의 취득.
• Request
GET /list HTTP/1.1
Host: example.com
• Response
HTTP/1.1 200 OK
Content-Type:application/json
{
json data…//생략
}
5. POST
• 리소스의 작성, 추가.
• Request
POST /list HTTP/1.1
Host: example.com
Content-Type: text/plain;charset=utf-8
안녕하세요!
• Response
HTTP/1.1 201 Created
Content-Type: text/plain;charset=utf-8
Location:Http://example.com/list/item5
안녕하세요!
6. POST
• 리소스 데이터 추가
• Request Header info
POST /log HTTP/1.1
Host: example.com
• Response Header info
HTTP/1.1 20o OK
Content-Type: text/plain;charset=utf-8
• 다른 method로는 대응할 수 없는 부분 처
리
7. PUT
• 리소스의 갱신
• Request
PUT /list/item5 HTTP/1.1
Host:example.com
Content-Type:text/plain;charset=utf-8
좋은밤이네요!
• Response
HTTP/1.1 200 OK
Content-Type:text/plain;charset=utf-8
좋은밤이네요!
8. PUT
• 리소스의 작성
• Request
PUT /newitem HTTP/1.1
Host:example.com
Content-Type:text/plain;charset=utf-8
좋은 아침이네요!
• Response
HTTP/1.1 201 OK
Content-Type:text/plain;charset=utf-8
좋은 아침이네요!
9. POST vs PUT
• 리소스를 작성 할 경우
• POST
• 리소스 URI 결정권은 서버.
• PUT
• 리소스 URI 결정권은 클라이언트.
• Wiki 같이 타이틀 그대로 URI가 되는경우.
• 리소스 작성은 POST로 수행 (권장)
11. HEAD
• 리소스의 헤더 취득
• Request
HEAD /list/item1 HTTP/1.1
Host:example.com
• Response
HTTP/1.1 200 OK
Content-Type:text/plain;charset=utf-8
• Response 정보 BODY 미 포함
• 네트워크 대역 절약, 리소스 크기 및 갱신일
자 조회
12. OPTIONS
• 리소스 URI가 지원하는 Method 목록 반환
• Request
OPTIONS /list HTTP/1.1
• Response
HTTP/1.1 200 OK
Allow:GET,HEAD,POST
13. _method
• HTML에서 지정 가능한 Method
• POST, GET
• XMLHttpRequest를 사용하면 해결 되지만 지원하지 않는
브라우져가 존재.
• _method
• <input type=‘hidden’ id=‘_method’ value=“PUT”>
• Request info
POST /list/item HTTP/1.1
Host:example.com
Content-Type:application/x-www-form-urlencoded
_method=PUT&body=...//body 내용 생략
14. X-HTTP-Method-Override
• POST 내용이 XML 인 경우
application/x-www-form-urlencoded 이용
불가.
• X-HTTP-Method-Override 사용
• Request info
POST /list/item1 HTTP/1.1
Host:example.com
…
X-HTTP-Method-Override:PUT
15. 멱등성과 안정성
• GET,HEAD
• 멱등이고 안전하다.
• PUT,DELETE
• 멱등이지만 안전하지 않다.
• POST
• 멱등이지도 안전하지도 않다.