λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
  • μž₯원읡 κΈ°μˆ λΈ”λ‘œκ·Έ
πŸ’» Computer Science/- Network

[HTTP-Header] HTTP General Header & Entity Header:: 곡톡 헀더와 μ—”ν‹°ν‹° 헀더

by Wonit 2020. 10. 9.

https://docs.trafficserver.apache.org/

곡톡 ν—€λ”λŠ” μš”μ²­ 헀더와 응닡 헀더에 ν•„μˆ˜μ μœΌλ‘œ ν¬ν•¨λ˜λŠ” 헀더이닀.
그리고 μ—”ν‹°ν‹° ν—€λ”λŠ” Entity-Bodyκ°€ μžˆμ„ λ•Œ ν•¨κ»˜ ν¬ν•¨λ˜λŠ” 헀더λ₯Ό λœ»ν•˜λŠ”λ°, 곡톡 헀더와 ν•¨κ»˜ μ•Œμ•„λ³Ό 것이닀.

μ—¬κΈ°μ„œ μš°λ¦¬λŠ” 자주 μ‚¬μš©ν•˜λŠ” 유λͺ…ν•œ 헀더에 λŒ€ν•΄μ„œλ§Œ μ•Œμ•„λ³Ό 것이닀.

ν—€λ”λŠ” 크둬의 개발자 λ„κ΅¬μ˜ λ„€νŠΈμ›Œν¬ νƒ­μ—μ„œ 헀더듀을 확인할 수 μžˆλ‹€.

곡톡 헀더 General Header

μš°λ¦¬κ°€ μ΄λ²ˆμ— 닀뀄볼 곡톡 ν—€λ”λŠ” λ‹€μŒκ³Ό κ°™λ‹€.

  • Date
  • Connection
  • Cache-Control
  • Content-Encoding

Date

일반적인 HTTP ν—€λ”λŠ” λ§Œλ“€μ–΄μ§„ λ‚ μ§œμ™€ μ‹œκ°„μ„ ν¬ν•¨ν•˜λŠ”λ°, λ‹€μŒκ³Ό κ°™λ‹€.

General-Header: Data: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT

// Date: Wed, 21 Oct 2015 07:28:00 GMT 

μš”μ²­κ³Ό μ‘λ‹΅μ‹œμ— μžλ™μœΌλ‘œ λ§Œλ“€μ–΄μ§€λŠ” 헀더이닀.

Connection

Connection ν—€λ”λŠ” ν˜„μž¬μ˜ 전솑이 μ™„λ£Œλœ ν›„ λ„€νŠΈμ›Œν¬ 접속을 μœ μ§€ν• μ§€ 말지λ₯Όμ œμ–΄ν•œλ‹€.

Connection의 μ†μ„±μ—λŠ” 크게 2가지가 μžˆλ‹€.

  1. Keep-alive : 지속 μ—°κ²°
  2. close : μ—°κ²° μ’…λ£Œ
Connection: keep-alive
Connection: close

Cache-Control

Cache-Control ν—€λ”λŠ” 캐싱을 ν—ˆμš©ν• μ§€ ν—ˆμš©ν•˜μ§€ μ•Šμ„μ§€λ₯Ό μ •ν•˜κΈ° μœ„ν•΄ μ‚¬μš©λœλ‹€.
캐싱은 μš”μ²­κ³Ό μ‘λ‹΅μ—μ„œ 단방ν–₯으둜 지정할 수 μžˆλŠ”λ° ν•΄μ•Όν•  이야기가 λ§Žμ•„μ„œ ν•΄λ‹Ή μΉ΄ν…Œκ³ λ¦¬μ˜ HTTP ν—€λ”μ˜ Cache-Control 헀더λ₯Ό ν™•μΈν•˜μž.

μ—”ν‹°ν‹° 헀더 Entity Header

μš°λ¦¬κ°€ μ΄λ²ˆμ— 닀뀄볼 μ—”ν‹°ν‹° ν—€λ”λŠ” λ‹€μŒκ³Ό κ°™λ‹€.

  • Content-Length
  • Content-Type
  • Content-Language
  • Content-Encoding

Content-Length

Content-LengthλŠ” λ°”μ΄νŠΈ λ‹¨μœ„λ₯Ό κ°€μ§€λŠ” Header + Body의 크기λ₯Ό λ‚˜νƒ€λ‚Έλ‹€.
λ©”μ‹œμ§€ 크기에 따라 μžλ™μœΌλ‘œ μƒμ„±λœλ‹€.

Content-Length: <length>

Content-Type

Content-TypeλŠ” 개체의 λ―Έλ””μ–΄ νƒ€μž…(MIME)κ³Ό λ¬Έμžμ—΄ 인코딩(UTF-8)을 μ§€μ •ν•˜κΈ° μœ„ν•΄ μ‚¬μš©ν•œλ‹€.
μ΄λŠ” Accept 헀더와 λŒ€μ›…λœλ‹€.

// λ©”μ‹œμ§€ λ‚΄μš©μ€ text/html νƒ€μž…μ΄κ³  λ¬Έμžμ—΄μ€ utf-8 λ¬Έμžμ—΄μ΄λΌλŠ” 것
Content-Type: text/html; charset=utf-8
Content-Type: multipart/form-data; boundary=something

Content-Language

Content-Language ν—€λ”λŠ” μ‚¬μš©μžλ“€μ—κ²Œ μ–Έμ–΄λ₯Ό μ„€λͺ…ν•˜κΈ° μœ„ν•΄ μ‚¬μš©λœλ‹€.
μ‚¬μš©μžκ°€ μ„ ν˜Έν•˜λŠ” 언어에 따라 μ‚¬μš©μžλ₯Ό ꡬ뢄할 수 있게 ν•œλ‹€.
예λ₯Ό λ“€μ–΄μ„œ Content-Language: en-US둜 μ„€μ •λœλ‹€λ©΄, λ―Έκ΅­μ—μ„œ λ§Œλ“€μ–΄μ‘Œμ§€λ§Œ, 일뢀뢄이 μ˜μ–΄κ°€ 아닐 μˆ˜λ„ μžˆλ‹€.

λ§Œμ•½ Content-Languageκ°€ μ§€μ •λ˜μ§€ μ•ŠμœΌλ©΄ λͺ¨λ“  μ‚¬λžŒλ“€μ—κ²Œ 곡개된 정보라고 κ°„μ£Όν•œλ‹€.
Content-LanguageλŠ” Text 뿐만 μ•„λ‹ˆλΌ λ―Έλ””μ–΄ νƒ€μž…μ—λ„ μ μš©λœλ‹€.

Content-Language: de-DE
Content-Language: en-US
Content-Language: de-DE, en-CA

HTML λ¬Έμ„œμ—λ„ λ‹€μŒκ³Ό 같이 μ‚¬μš©ν•  수 μžˆμ§€λ§Œ μ‚¬μš©ν•˜μ§€ μ•ŠλŠ”κ²ƒμ„ MDNμ—μ„œ κΆŒκ³ ν•œλ‹€.

<!-- /!\ This is bad practice -->
<meta http-equiv="content-language" content="de">

Content-Encoding

Content-Encoding 은 λ―Έλ””μ–΄ νƒ€μž…μ„ μ••μΆ•ν•˜κΈ° μœ„ν•΄μ„œ μ‚¬μš©λœλ‹€.
이 헀더가 μ‘΄μž¬ν•œλ‹€λ©΄ κ·Έ 값은어떀 λ°©μ‹μœΌλ‘œ 인코딩 λ˜λŠ”μ§€ μ•Œ 수 μžˆλ‹€.
μš°λ¦¬κ°€ gzipλ“±μ˜ μ•Œκ³ λ¦¬μ¦˜μ„ 톡해 encoding ν•΄μ„œ 보낸닀면 λΈŒλΌμš°μ €κ°€ μ•Œμ•„μ„œ ν•΄μ œν•΄μ„œ μ‚¬μš©ν•œλ‹€.

Content-Encoding: gzip
Content-Encoding: compress
Content-Encoding: deflate
Content-Encoding: identity
Content-Encoding: br

// Content-Encoding: gzip

λŒ“κΈ€