- ๋ธ๋ผ์ฐ์ ์นํ์ ์ธ ํ๋กํ ์ฝ
- ์์ฒญ ๋ฐ ์๋ต์ ๋ํ ๋ฉํ ๋ฐ์ดํฐ๋ฅผ ํฌํจํ๋ ํค๋ ํ๋ ์ ๊ณต(Status code, Content-Type ๋ฑ)
- Response: Content-Type์ Http ํ์ผ ์ธ์๋ ์คํฌ๋ฆฝํธ, ์คํ์ผ ์ํธ, ๋ฏธ๋์ด ๋ฑ์ ์ ์ก ๊ฐ๋ฅ
- Method: GET, HEAD, POST
- Connection ํน์ฑ: ์๋ต ์งํ ์ข ๋ฃ
(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)
- ๋จ์ : ๊ฐ ๋ชจ๋ ์์ฒญ์ ๋ฐ๋ผ ์๋ก์ด ์ฐ๊ฒฐ์ ์ด๊ณ , ์๋ต์ด ์ ์ก๋ ํ ์ฆ์ ๋ซ๊ธฐ ๋๋ฌธ์ ์๋ก์ด ์ฐ๊ฒฐ์ด ์ค์ ๋ ๋๋ง๋ค TCP 3-way Handshake๊ฐ ๋ฐ์ํจ.
- ์ค๋๋ ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ๋๋ HTTP ๋ฒ์
- ์๊ตฌ ๋ฐ ํ์ดํ ๋ผ์ธ ์ฐ๊ฒฐ, ์์ถ/์์ถ ํด์ , ๊ฐ์ ํธ์คํ , ์บ์ ๋ฑ์ด ์ถ๊ฐ๋์ด ์๋ต์๋๊ฐ ๋นจ๋ผ์ง๊ณ ๋์ญํญ์ด ์ ์ฝ๋๋ ๋ฑ ์ฑ๋ฅ ์ต์ ํ ๋ฐ ๊ธฐ๋ฅ ํฅ์
- Upgrade๋ก WebSocket ์ ํ ๊ฐ๋ฅ
- Method: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
- Connection ํน์ฑ: long-lived
(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)
- ์ฐ๊ฒฐ์ ์ค์ ํ๊ธฐ ์ ์ TCP 3-way Handshake ๋ฐ์. ๋ง์ง๋ง์ผ๋ก ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ Client๋ก ๋ณด๋ธ ํ Server๋ ๋ ์ด์ ๋ณด๋ผ ๋ฐ์ดํฐ๊ฐ ์๋ค๋ ๋ฉ์ธ์ง๋ฅผ ๋ณด๋ด๊ณ , ๊ทธ ์ดํ ์ฐ๊ฒฐ์ ๋ซ๋๋ค.
- ์ฆ, HTTP1.1์ ์ฌ๋ฌ Request-Response์ ๋ํด ๋์ผํ ์ฐ๊ฒฐ์ ์ฌ์ฌ์ฉํ ์ ์๋ค.
HTTP 1.0
: TCP Connection์ HTTP ์์ฒญ๋ง๋ค 3-way Handshake์ TearDown์ ๋ฐ๋ณตํ๋ค.HTTP 1.1
: ํ๋์ TCP Connection์ด ์ด๋ ค์์ผ๋ฉด (Established ์ํ), ๊ทธ ์ฐ๊ฒฐ์ ํตํด ์ฌ๋ฌ Request์ ๋ํ Response๋ฅผ ๋ฐ์ ์ ์๋ค.
HTTP 1.1 Keep-Alive Pipelining
: Pipelining์ ์ฌ์ฉํ ๋, client๋ ์ฌ๋ฌ request๋ฅผ response์ ์๋ต์ ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ ๋ณด๋ผ ์ ์๋ค.HTTP 1.1 Keep-Alive Multiple Connections
: ํด๋ผ์ด์ธํธ๋ ๋ง์ ์์ objects๋ฅผ ๊ฒ์ํ๋ ์ฑ๋ฅ์ ๋์ด๊ธฐ ์ํด TCP ๋ค์ค ์ฐ๊ฒฐ์ ํ ์ ์๋ค.
- Http Pipelining์ผ๋ก ํ๋์ connection์ ํตํด ๋ค์๊ฐ์ ํ์ผ์ Request/Response ๋ฐ์ ์ ์์ง๋ง ์ฒซ ๋ฒ์งธ Response๊ฐ ์ง์ฐ๋๋ฉด, ๋ค์ ๋, ์ธ๋ฒ์งธ Response๋ ์ฒซ๋ฒ์งธ ์๋ต์ฒ๋ฆฌ๊ฐ ์๋ฃ๋๊ธฐ ์ ๊น์ง ๋๊ธฐํ๊ฒ ๋๊ธฐ ๋๋ฌธ์ Head Of Line Blocking(HOLB)๊ฐ ๋ฐ์ํ๋ค.
HTTP 2.0์ HTTP 1.1 ํ๋กํ ์ฝ์ ๊ณ์นํด ๋์ผํ API๋ฉด์ ์ฑ๋ฅ ํฅ์์ ์ด์ ์ ๋ง์ท๋ค. ๊ธฐ์กด์ Plain Text(ํ๋ฌธ)์ ์ฌ์ฉํ๊ณ ๊ฐํ์ผ๋ก ๊ตฌ๋ณ๋๋ HTTP/1.x ํ๋กํ ์ฝ๊ณผ ๋ฌ๋ฆฌ 2.0์ ๋ฐ์ด๋๋ฆฌ ํฌ๋งท์ผ๋ก ์ธ์ฝ๋ฉ๋ Message, Frame์ผ๋ก ๊ตฌ์ฑ๋๋ค.
- Stream: ๊ตฌ์ฑ๋ ์ฐ๊ฒฐ ๋ด์์ ์ ๋ฌ๋๋ ๋ฐ์ดํธ์ ์๋ฐฉํฅ ํ๋ฆ, ํ๋ ์ด์์ ๋ฉ์์ง๊ฐ ์ ๋ฌ ๊ฐ๋ฅํ๋ค.
- Message: ๋ ผ๋ฆฌ์ ์์ฒญ ๋๋ ์๋ต ๋ฉ์์ง์ ๋งคํ๋๋ ํ๋ ์์ ์ ์ฒด ์ํ์ค์ด๋ค.
- Frame: Http/2.0์์ ํต์ ์ ์ต์ ๋จ์, ๊ฐ ์ต์ ๋จ์์๋ ํ๋์ ํ๋ผ์ ํค๋๊ฐ ํฌํจ๋๋ค. ์ด ํ๋ผ์ ํค๋๋ ์ต์ํ์ผ๋ก ํ๋ ์์ด ์ํ๋ ์คํธ๋ฆผ์ ์๋ณํ๋ค. Headers Type Frame, Data Type Frame์ด ์กด์ฌํ๋ค.
- ํ Connection์ผ๋ก ๋์์ ์ฌ๋ฌ ๊ฐ ๋ฉ์์ง๋ฅผ ์ฃผ๊ณ ๋ฐ์ ์ ์์ผ๋ฉฐ, Response๋ ์์์ ์๊ด์์ด stream์ผ๋ก ์ฃผ๊ณ ๋ฐ๋๋ค.
- ๋ฆฌ์์ค๊ฐ ์ฐ์ ์์๋ฅผ ์ค์ ํด ํด๋ผ์ด์ธํธ๊ฐ ๋จผ์ ํ์ํ ๋ฆฌ์์ค๋ถํฐ ๋ณด๋ด์ค๋ค.
- ์๋ฒ๋ ํด๋ผ์ด์ธํธ์ ์์ฒญ์ ๋ํด ์์ฒญํ์ง ์์ ๋ฆฌ์์ค๋ฅผ ๋ง์๋๋ก ๋ณด๋ด์ค ์ ์๋ค.
- ์ฆ, ํด๋ผ์ด์ธํธ๊ฐ ์์ฒญํ๊ธฐ ์ ์ ํ์ํ๋ค๊ณ ์์๋๋ ๋ฆฌ์์ค๋ฅผ Server์์ ๋จผ์ ์์ฒญํ๋ค. ์) http๋ง ์์ฒญํ๋๋ฐ http์ css, js, image๋ฅผ ํจ๊ป ์ ์กํด์ฃผ๋ ๋ฑ