본문 바로가기
카테고리 없음

Content-Type

by sngynhy 2022. 5. 13.

Content-Type?
HTTP Header에 쓰이는 Content-Type은
Request에 실어 보내는 데이터(Body)의 type 정보를 표현한다.
text 타입으로는 text/css, text/javascript, text/html, text/plain 등
file 타입으로는 multipart/formed-data
application 타입으로는 application/json, application/x-www-form-urlencode
Content Type은 Request에 실어 보내는 data의 type에 따라 적절하게 선택해주면 된다.

주의할 점
applicatio 로직에서 applcation/x-www-form-urlencoded 사용 시
body 인코딩이 해당 프레임워크 혹은 라이브러리에서 자동으로 인코딩되는지 확인 해볼 것!
(node.js의 request 라이브러리는 해당  해당 Content-Type에 대해
qs.stringify로 url인코딩하도록 이미 내부에 구현되어 있음)