티스토리 뷰

CS

[Network] HTTP/0.9 ~ 1.1

신잼 2022. 1. 3. 20:05

HTTP

  • 정의: HTML 문서와 같은 리소스들을 가져올 수 있도록 해 주는 프로토콜
  • 1989~1991 사이에 World Wide Web 통신 프로토콜로 사용하기 위해 Tim Berners-Lee가 CERN에서 만들었다
  • client와 server 간에 request에 따라 response 하는 model
  • IETF와 W3C에서 개발됐으며 RFC로 관리

https://developer.mozilla.org/ko/docs/Web/HTTP/Overview

HTTP/0.9

  • 원라인 프로토콜이라고 불린다.
  • telnet friendly 한 프로토콜
  • 초기에는 버전 번호가 없었고 차후에 구별하기 위해 0.9로 불렸다.
  • Connection: response후에 바로 connection이 끊어진다.
  • Reqeust
    • 요청은 단일 라인으로 구성
    • URL이 아닌 GET 요청만 가능.
  • Response
    • 응답은 단순하게 파일 내용 자체로 구성
$> telnet ashenlive.com 80

(Connection 1 Establishment - TCP Three-Way Handshake)
Connected to xxx.xxx.xxx.xxx

(Request)
GET /my-page.html

(Response in hypertext)
<HTML> A very simple HTML page </HTML>

(Connection 1 Closed - TCP Teardown)

HTTP/1.0

  • RFC 1945에 정의되어 있다.
  • 공식적인 표준이 아니다.(1991 ~ 1995년까지 시장 반응 확인)
  • Browser friendly 한 프로토콜
  • 풍부한 metadata를 포함하는 header가 request와 response 모두에게 포함된다.(HTTP 버전 정보, 상태 코드, content type)
  • connection: response후에 바로 connection이 끊어진다.
  • Request
    • user agent 등장
    • GET, HEAD, POST 메서드 지원
  • Response
    • 상태 코드가 상단에 포함.
      • 브라우저가 요청에 대한 성공가 실패를 알 수 있다.
      • 결과에 따라 로컬 캐시를 갱신하는 것과 같은 동작을 할 수 있게 된다.
    • Content-Type을 사용하면서 HTML 파일 외에 다른 문서들을 전송할 수 있게 됐다.
(Connection 1 Establishment - TCP Three-Way Handshake)
Connected to xxx.xxx.xxx.xxx

(Request)
GET /my-page.html HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)

(Response)
HTTP/1.0 200 OK
Content-Type: text/html
Content-Length: 137582
Expires: Thu, 01 Dec 1997 16:00:00 GMT
Last-Modified: Wed, 1 May 1996 12:45:26 GMT
Server: Apache 0.84

<HTML>
A page with an image
  <IMG SRC=“/myimage.gif”>
</HTML>
(Connection 1 Closed - TCP Teardown)

------------------------------------------

(Connection 2 Establishment - TCP Three-Way Handshake)
Connected to xxx.xxx.xxx.xxx

(Request)
GET /myimage.gif HTTP/1.0
User-Agent: NCSA_Mosaic/2.0 (Windows 3.1)

(Response)
HTTP/1.0 200 OK
Content-Type: text/gif
Content-Length: 137582
Expires: Thu, 01 Dec 1997 16:00:00 GMT
Last-Modified: Wed, 1 May 1996 12:45:26 GMT
Server: Apache 0.84
[image content]

(Connection 2 Closed - TCP Teardown)

HTTP/0.9와 HTTP/1.0의 문제

  • 새로운 request마다 새로운 connection을 맺는 것
  • 즉 새로운 request 마다 3 way handshake가 발생하기 때문에 성능을 위해서 HTTP/1.1에서는 지속적인 연결로 해결.

A typical TCP Three-way Handshake (see how the TCP state machine is changing its state) from&amp;nbsp;lwn.net

HTTP/1.1

  • 성능 향상을 위한 최적화와 새로운 기능 추가
    • 지속적이고 파이프라인 된 연결(persistent and pipelined connections)
      • connection을 재사용하여 시간 절약
      • pipelining을 사용하여 latency 낮춤
    • Chunked 된 전송(chunked transfers)
    • 압축 및 압축 해제(compression/decompression)
    • 언어, 인코딩 혹은 타입 등 컨텐트 협상(content negotiation)
    • 가상 호스팅(하나의 IP로 여러 도메인 호스팅)
      • Host 헤더 사용
      • server collocation 가능하게 함
    • cache지원으로 인한 빠른 응답과 대역폭 절약
  • HTTP/1.0이 나온 지 몇 달 안돼서 1997년 1월에 RFC 2068에서 처음 공개
  • Connection: long-lived
  • Request
    • GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS 헤더 지원
(Connection 1 Establishment - TCP Three-Way Handshake)
Connected to xxx.xxx.xxx.xxx

(Request 1)
GET /en-US/docs/Glossary/Simple_header HTTP/1.1
Host: 
developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: 
https://developer.mozilla.org/en-US/docs/Glossary/Simple_header

(Response 1)
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Wed, 20 Jul 2016 10:55:30 GMT
Etag: “547fa7e369ef56031dd3bff2ace9fc0832eb251a”
Keep-Alive: timeout=5, max=1000
Last-Modified: Tue, 19 Jul 2016 00:59:33 GMT
Server: Apache
Transfer-Encoding: chunked
Vary: Cookie, Accept-Encoding

[content]

(Request 2)
GET /static/img/header-background.png HTTP/1.1
Host: 
developer.cdn.mozilla.net
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: 
https://developer.mozilla.org/en-US/docs/Glossary/Simple_header

(Response 2)
HTTP/1.1 200 OK
Age: 9578461
Cache-Control: public, max-age=315360000
Connection: keep-alive
Content-Length: 3077
Content-Type: image/png
Date: Thu, 31 Mar 2016 13:34:46 GMT
Last-Modified: Wed, 21 Oct 2015 18:27:50 GMT
Server: Apache

[image content of 3077 bytes]

(Connection 1 Closed - TCP Teardown)

informit.com

Transfer Encoding

http/1.1에서는 하나의 연결에 여러 개의 요청이 가능하기 때문에 client 입장에서는 매 요청마다 server에서 주는 data의 크기를 알아야 한다. 따라서 Content-Length 헤더로 데이터의 크기를 알려준다. 하지만 데이터 크기가 클 때는 client에서 데이터를 읽어올 때 오래 걸릴 수 있다. 따라서 데이터를 쪼개서 보내기 위해 Chunked 방식 사용된다.

flylib.com/books/en/1.2.1.149/1/

Content Negotiation

  • 동일한 URI에서 리소스의 서로 다른 버전을 서브하기 위해 사용되는 메커니즘
  • 사용자 에이전트가 사용자에게 제일 잘 맞는 것이 무엇인지 명시
  • 서버 주도, Agent 주도 협상 두 가지 방법이 있다.

developer.mozilla.org/ko/docs/Web/HTTP/Content_negotiation

Keep Alive

  • HTTP/1.1 이전에 사용되다가 HTTP/1.1부터 기본으로 사용된다.
  • host 간 long-lived 통신을 위한 정책을 설정하는 데 사용될 수 있다.
    • i.e. event가 발생할 때까지 connection을 유지하는 것을 허용하는 것
  • Client 및 Server 등 어떤 중개자는 Keep-Alive 정보를 제공할 수 있다.
  • 유휴 상태일 때에도 서버 리소스를 소비하며, 과부하 상태에서는 DoS attacks (en-US)을 당할 수 있다.
  • host는 timeout과 max를 추가할 수 있다.
    • timeout: 연결 지속 시간
    • max: 한 connection당 최대 request
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 11 Aug 2016 15:23:13 GMT
Keep-Alive: timeout=5, max=1000
Last-Modified: Mon, 25 Jul 2016 04:32:39 GMT
Server: Apache

[body]

각각의 connection이&amp;nbsp; 독립적으로 &amp;nbsp; negotiated&amp;nbsp; 됨을 보여주는 예제. Image from ietf.org

Upgrade header

  • HTTP/1.1과 같이 사용되고 있는 프로토콜에서 HTTP/2.0이나 WebSocket과 같은 다른 프로토콜로 변경하고 싶을 때 사용된다.
  • upgrade header에는 max가 없다.
  • hop-by-hop header라고 불리기도 한다.

upgrade 후에는 각연결의 timeout이 독립적이지 않는 예제. image from ietf.org &amp;nbsp;

Pipelining & Multiple connections

  • Keep-Alive 덕분에 pipelining, multiple connection 등 성능 향상을 실현시킬 수 있다.
  • Pipelining: 파이프 라이닝은 여러 개의 요청을 보낼 때 처음 요청이 응답될 때까지 기다리지 않고 바로 요청을 보내는 것

informit.com

HOL(head-of-line) Block

  • piplining은 FIFO 방식으로 response가 보내져야 한다.
  • 서버에서 동시에 두 요청을 처리하면 문제 발생
    • GET /css에 대한 요청은 먼저 처리됐어도 GET /html 요청이 완료될 때까지 block 된다.
    • 첫 번째 요청이 오래 걸릴 경우 다른 요청들에 대한 응답을 보낼 수 없어 비효율적인 상황이 발생

velog.io/@seeker1207/HTTP-0.9에서-HTTP-3.0까지

  • 브라우저에서는 여러 개의 TCP 연결을 만들어 병렬적으로 해결 가능
    • 메모리와 CPU 등 리소스를 낭비하게 된다.
  • HOL Block을 보완하기 위해 탄생한 것이 HTTP/2

FYI

IETF The Internet Engineering Task Force 인터넷의 상호 접속성을 향상시키는 것을 목적으로 만들어진 임의 단체
RFC Request For Comments IETF가 만든 규약 문서
IANA Internet Assigned Numbers Authority 포트 번호와 파일 타입(Content-Type) 등 웹에 관한 데이터베이스를 관리하는 단체
W3C World Wide Web Consortium 웹 관련 표준화를 하는 비영리 단체
WHATWG Web Hypertext Application Technology Working Group 웹 관련 규격을 논의하는 단체

출처: [길은 가면, 뒤에 있다.]

 

종단 간 헤더(end-to-end)

메시지의 최종 수신인(요청용 서버 또는 응답용 클라이언트)에게 전송

중간 프락시는 수정되지 않은 헤더를 재전송해야 하며 캐시는 헤더를 저장해야 한다.

홉간 헤더(hop-by-hop)

proxy를 거치는 도중 소비되는 헤더.

이러한 헤더는 단일 전송-레벨 연결에서만 의미가 있으며 프락시에 의해 재전송되거나 캐시 되어선 안됩니다.

아래의 8개 헤더 필드 이외에는 모두 End-by-end 헤더에 분류된다.

  • Connection
  • Keep-Alive
  • proxy-Authenticate
  • Proxy-Authorization
  • Trailer
  • TE
  • Transfer-Encoding
  • Upgrade

 

출처: [HTTP-header]


Reference

반응형

'CS' 카테고리의 다른 글

[Network] HTTP/3 and QUIC  (0) 2022.01.18
[Network] HTTP/2  (0) 2022.01.10
[Network/OS] Network Socket(IP Socket, WebSocket)  (0) 2021.12.27
Interpreter VS Compiler  (0) 2021.11.26
[DB]Transaction(Race condition, Isolate level  (0) 2021.11.16
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함