HTTP/2의 특징

HTTP/2는 기존 HTTP 버전의 성능 향상에 초점을 맞추었다. 이전 HTTP 표준을 대체하는 것이 아니라 확장한다고 생각하면 된다.

바이너리 프레임 기반의 데이터 전송

Untitled

요청 및 응답 다중화

요청 및 응답 헤더의 중복 값 제거 / 헤더 압축

서버 푸시

HTTP/2의 이진 프레임

HTTP/2 이전 버전에서 HTTP의 요청과 응답은 메시지(message)라는 단위로 구성되었다. 메시지는 상태 라인(state line), 헤더와 페이로드로 이루어진다.

curl을 사용하여 HTTP/1.1 요청을 네이버에게 보내보자(curl은 기본적으로 HTTP/1.1 요청을 보낸다). 응답이 302이긴 하지만, HTTP/1.1 기반의 응답 메세지가 어떻게 되어 있는지 알 수 있다.

$ curl -s -v www.naver.com
*   Trying 23.193.52.203:80...
* Connected to www.naver.com (23.193.52.203) port 80 (#0)
> GET / HTTP/1.1
> Host: www.naver.com
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Moved Temporarily
< Server: NWS
< Content-Type: text/html
< Location: <https://www.naver.com/>
< Date: Mon, 20 Feb 2023 12:11:01 GMT
< Connection: close
<
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center> NWS </center>
</body>
</html>
* Closing connection 0