Representations

raccoonback·2019년 7월 28일
1

Network

목록 보기
6/7
post-thumbnail

Resources

Representation 알아보기 전에, Resource에 대해 알아보자.

HTTP Request Target을 Resource 라고 부른다. HTTP는 Resource의 특성을 제한하지 않고, 단지 상호작용을 위한 Interface로 사용한다. 각각의 Resource는 Uniform Resource Identifier(URI)로 식별된다.

Represetation

Representation은 Rest에서 도입되어, 특정 시점에서 Target Resource의 현재 상태를 반영하고 있는 정보이다. 아래의 예로 조금 더 이해해보자.

GET /foo
Host: www.example.com
Accept-Language: en;q=1.0, ko;q=0.5
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Language: en

hello

여기서 보통 foo url에 대한 hello resource 를 응답 받았다고 생각할 수 있지만, 정확히 말하자면 hello는 resource 가 아닌 representataion data인 것이다.

Representation Data 이란 Message의 payload body로 제공되거나, Message 의미와 유효한 요청 URI로 언급된다. 또한, Representation Data는 Representation Metadata header field로 정의된 포맷과 인코딩이다. 구체적으로 representation data는 Content-Type and Content-Encoding 헤더 필드로 결정된다.
representation-data := Content-Encoding( Content-Type( bits ) )

The GET method requests transfer of a current selected representation
for the target resource.

Resource는 무엇이든지 될 수 있고 HTTP가 제공하는 통일된 Interface 으로만 상대방과 커뮤니케이션할 수 있다는 것은 Resource 현재 상태를 나타내기 위해 추상화된 Representation 이 필요하다는 의미이다.

참고

profile
한번도 실수하지 않은 사람은, 한번도 새로운 것을 시도하지 않은 사람이다.

0개의 댓글