본문 바로가기

코딩/네트워크

[HTTP] HTTP 헤더

HTTP Header : HTTP 전송에 필요한 모든 부가정보가 담겨있음

field-name: field-value   형태

ex) Host: www.google.com 

      Content-Type: text/html;charset=UTF-8

헤더 분류

 - General 헤더 : 메시지 전체에 적용되는 정보

 - Request 헤더 : 요청 정보

 - Response 헤더 : 응답 정보

 - Entity 헤더 : 엔티티 바디(Message body) 정보 --> RFC723x 에서 Entity(엔티티)라는 단어를 Representation(표현)으로 변경!

즉 Entity 헤더 = Representation 헤더

 

 

Representation 헤더 : Representation data 를 해설할 수 있는 정보 제공

 - Content-Type: 표현 데이터의 형식 (미디어 타입, 문자 인코딩) 즉 본문의 데이터 형식을 지정한다!

     ex) Content-Type: text/html; charset=UTF-8

 - Content-Encoding: 표현 데이터의 압축 방식

     ex) Content-Encoding: gzip

 - Content-Language: 표현 데이터의 자연 언어

     ex) Content-Language: ko

 - Content-Length: 표현 데이터의 길이

     ex) Content-Length: 34

 

 

협상 헤더 : 클라이언트가 선호하는 표현 요청

Request 시에만 사용 가능!

- Accept: 미디어 타입 요청

- Accept-Charset: 문자 인코딩 요청

- Accept-Encoding: 압축 인코딩 요청

- Accept-Language: 자연 언어 요청

 

Quality Values(q) 를 사용해 우선순위를 줄 수 있다. (생략하면 1)

ex) Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8.en;q=0.7

+ 구체적일수록 우선순위가 높다

ex) Accept: text/*, text/plain, text/plain;format=flowed, */*

우선순위: text/plain;format=flowed > text/plain > text/* > */*