본문 바로가기
HTTP

HTTP MIME

by SeanK 2021. 11. 18.

 

 

이번에는 HTTP통신에서 마치 윈도우의 확장자와 같은 역할을 하는 MIME를 알아보자. 

 

 

마임으로 읽는지 미메로 읽는건지... 혹시 아시는 분들은 댓글 부탁드립니다 ㅠ

 

 

MDN을 통해 개념을 알아보려고 했지만, 

 

너무나 이해하기 어렵게 설명을 해놔서 stackoverflow의 답변을 참고하였다. 

 

 

 

What is a MIME type?

 

 

 

A MIME type is a label used to identify a type of data.
It is used so software can know how to handle the data.
It serves the same purpose on the Internet that file extensions do on Microsoft Windows.

So if a server says "This is text/html" the client can go "Ah, this is an HTML document, I can render that internally", while if the server says "This is application/pdf" the client can go "Ah, I need to launch the FoxIt PDF Reader plugin that the user has installed and that has registered itself as the application/pdf handler."

You'll most commonly find them in the headers of HTTP messages (to describe the content that an HTTP server is responding with or the formatting of the data that is being POSTed in a request) and in email headers (to describe the message format and attachments).


 

조금 길지만 알기쉽게 잘 설명을 해놓았다. 

 

MIME는 데이터의 타입을 알수 있도록 하는 일종의 라벨이다. 이것을 이용하면 소프트웨어는 데이터를 어떻게 취급해야 하는 지 알 수 있게 된다. 마치 마이크로 소프트의 확장자와 같은 목적을 가진 인터넷 내의 확장자와 마찬가지이다.

 

그래서 만약에 서버가 "이것은 text/html이에요" 라고 말한다면 클라이언트는 "아하 이것은 HTML 문서이고 내부적으로 랜더링이 가능하겠군" 이라고 알 수 있으며 서버가 "이것은 application/pdf에요" 라고 한다면 클라이언트는 "PDF 리더 플러그인이 필요하겠군" 이라고 알 수 있게 된다. 

 

보통 HTTP 메세지의 헤더와 이메일 헤더에 위치한다. 

 

타입의 종류와 예시는 아래와 같다. 

 

 

 

타입설명일반적인 서브타입 예시

 

 

 

text 텍스트를 포함하는 모든 문서를 나타내며 이론상으로는 인간이 읽을 수 있어야 합니다 text/plain, text/html, text/css, text/javascript
image  모든 종류의 이미지를 나타냅니다. (animated gif처럼) 애니메이션되는 이미지가 이미지 타입에 포함되긴 하지만, 비디오는 포함되지 않습니다. image/gif, image/png, image/jpeg, image/bmp, image/webp
audio 모든 종류의 오디오 파일들을 나타냅니다. audio/midi, audio/mpeg, audio/webm, audio/ogg, audio/wav
video 모든 종류의 비디오 파일들을 나타냅니다. video/webm, video/ogg
application 모든 종류의 이진 데이터를 나타냅니다. application/octet-stream, application/pkcs12, application/vnd.mspowerpoint, application/xhtml+xml, application/xml,  application/pdf

 

 

 

 

아래는 이해하기 어려운 MDN 문서

https://developer.mozilla.org/ko/docs/Web/HTTP/Basics_of_HTTP/MIME_types

 

 

 

 

 

'HTTP' 카테고리의 다른 글

[Socket.io] socket.io 룸 생성과 메세지 전달 프로세스  (0) 2022.03.11
[Socket.io] Socket.io란 무엇인가?  (0) 2022.03.05
HTTP 상태 코드  (0) 2021.11.18
HTTP PUT과 PATCH 메소드의 차이  (0) 2021.11.18
HTTP 메소드의 멱등성  (0) 2021.11.18