Tips

HTTP Header Content-Type

chsr 2022. 3. 16. 14:59
728x90
반응형

■ HTTP Header Content-Type

보내는 자원 형식 명시를 위해 헤더에 실리는 정보로
리소스의 미디어 타입(media type)을 나타내기 위해 사용함


 문법

Content-Type: text/html; charset=utf-8
Content-Type: multipart/form-data; boundary=something

 엘리먼트(요소)

  • media-type
    리소스 or 데이터의 MIME TYPE
  • charset
    문자 인코딩 표준
  • boundary
    멀티 파트 경계선을 캡슐화하기 위해 사용

 Content-Type IN HTML form

HTML form 전송 시 POST 요청의 Content-Type은 <form> 요소 상의 enctype 속성으로 지정됨

<form action="/" method="post" enctype="multipart/form-data">
  <input type="text" name="description" value="some text">
  <input type="file" name="myFile">
  <button type="submit">Submit</button>
</form>

 예시

// 기본형태
Content-Type: Multipart/related

// application 타입
Content-Type: Application/javascript
Content-Type: Application/json			// Javascript Object Notation JSON
Content-Type: Application/x-www-form-urlencode	// HTML form 형태 (대용량 바이너리 데이터 전송, 비능률적)

// multipart 타입
Content-Type: multipart/form-data		// HTML form 형태
Content-Type: multipart/mixed: MIME E-mail;
Content-Type: multipart/alternative:

// text 타입
Content-Type: text/css				// css
Content-Type: text/html				// html or htm
Content-Type: text/javascript			// javascript
Content-Type: text/plain			// txt
Content-Type: text/xml				// xml
Content-Type: text/xsl				// xsl

// file 타입
Content-Type: application/msword 		// doc
Content-Type: application/pdf			// pdf
Content-Type: application/vnd.ms-excel 		// xls
Content-Type: application/x-javascript 		// js
Content-Type: application/zip 			// zip
Content-Type: image/jpeg 			// jpeg, jpg
728x90
반응형