01.Basic

HTTP Basic

์ธํ„ฐ๋„ท ๋„คํŠธ์›Œํฌ

message๋ฅผ ์„œ๋ฒ„๋ฅผ ํ†ตํ•ด ์–ด๋–ป๊ฒŒ ์ „๋‹ฌ๋ ๊นŒ?

IP(Internet Protocol)

  • ์ง€์ •ํ•œ IP Address์— ๋ฐ์ดํ„ฐ ์ „๋‹ฌ

  • Packet์ด๋ผ๋Š” ํ†ต์‹  ๋‹จ์œ„๋กœ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ

    • IP Packet ์ •๋ณด : ์ถœ๋ฐœ์ง€ IP, ๋ชฉ์ ์ง€ IP, ๊ธฐํƒ€.. ์ „์†ก ๋ฐ์ดํ„ฐ

    • ์ธํ„ฐ๋„ท ๋…ธ๋“œ๋“ค๋ผ๋ฆฌ ๋ชฉ์ ์ง€ IP๋ฅผ ํ–ฅํ•ด Packet์„ ์ „๋‹ฌ

  • Internet Protocol์˜ ํ•œ๊ณ„

    • ๋น„์—ฐ๊ฒฐ์„ฑ (๋Œ€์ƒ์ด ์—†๊ฑฐ๋‚˜ ์„œ๋น„์Šค ๋ถˆ๋Šฅ ์ƒํƒœ์ผ ๊ฒฝ์šฐ)

    • ๋น„์‹ ๋ขฐ์„ฑ (ํŒจํ‚ท์ด ์‚ฌ๋ผ์ง€๊ฑฐ๋‚˜, ์ˆœ์„œ๊ฐ€ ์ง€์ผœ์ง€์ง€ ์•Š์„ ๊ฒฝ์šฐ)

  • ํ”„๋กœ๊ทธ๋žจ ๊ตฌ๋ถ„

TCP, UDP

  • ์ฐธ๊ณ  > ํ”„๋กœํ† ์ฝœ ๊ณ„์ธต ์ˆœ์„œ

    • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ณ„์ธต (๋ธŒ๋ผ์šฐ์ €, ์ฑ„ํŒ…, ๊ฒŒ์ž„ ๋“ฑ)

      • HTTP, FTP

    • OS

      • ์ „์†ก ๊ณ„์ธต : TCP, UDP

      • ์ธํ„ฐ๋„ท ๊ณ„์ธต : IP

    • ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค

      • LAN ๋“œ๋ผ์ด๋ฒ„/์žฅ๋น„

  • TCP (Transmission Control Protocol) ํŠน์ง•

    • ์—ฐ๊ฒฐ์ง€ํ–ฅ (3 Way Handshake)

    • ๋ฐ์ดํ„ฐ ์ „๋‹ฌ ๋ณด์ฆ

    • ์ˆœ์„œ ๋ณด์žฅ ๋“ฑ..

    • IP์˜ ํ•œ๊ณ„๋ฅผ ํ•ด๊ฒฐ. ๋Œ€๋ถ€๋ถ„์ด ์‚ฌ์šฉ

  • UDP (User Datagram Protocol)

    • ๊ธฐ๋Šฅ์ด ๊ฑฐ์˜ ์—†์ง€๋งŒ, ์ถ”๊ฐ€ ์„ค์ • ๊ฐ€๋Šฅ

    • ๋‹จ์ˆœํ•˜๊ณ  ๋น ๋ฆ„

    • IP์™€ ๋™์ผํ•˜์ง€๋งŒ PORT, ์ฒดํฌ์„ฌ ์ •๋„ ์ถ”๊ฐ€

PORT

  • TCP/IP ํŒจํ‚ท

    • IP๋กœ ๋ชฉ์ ์ง€ ์„œ๋ฒ„ ์ฐพ๊ธฐ

    • PORT๋กœ ๊ฐ™์€ ์„œ๋ฒ„ ์•ˆ์—์„œ ํ”„๋กœ์„ธ์Šค ๊ตฌ๋ถ„

    • ํด๋ผ์ด์–ธํŠธ IP : 100.100.1:1010

    • ์„œ๋ฒ„ IP : 200.200.200:80

  • 0 ~ 65535 ๊นŒ์ง€ ํ• ๋‹น ๊ฐ€๋Šฅ

  • 0 ~ 1023 ์€ ์ž˜ ์•Œ๋ ค์ง„ ํฌํŠธ์ด๋ฏ€๋กœ, ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์„ ์ถ”์ฒœ

    • FTP : 20, 21

    • TELNET : 23

    • HTTP : 80

    • HTTPS : 443

DNS

  • Domain Name System

  • ๋„๋ฉ”์ธ๋ช…(์ด๋ฆ„)๊ณผ IP(์ „ํ™”๋ฒˆํ˜ธ)๊ฐ€ ์ €์žฅ๋œ ์ „ํ™”๋ฒˆํ˜ธ๋ถ€

๐Ÿ“‘

๋ณต์žกํ•œ ์ธํ„ฐ๋„ท ๋ง์„ ํ†ตํ•ด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด์„œ IP๊ฐ€ ํ•„์š”.
IP๋งŒ์œผ๋กœ๋Š” ์‹ ๋ขฐ๊ฐ€ ๋ถ€์กฑํ•˜๊ณ  ๊ตฌ๋ถ„์ด ํž˜๋“ค๊ธฐ ๋•Œ๋ฌธ์— TCP/UDP๊ฐ€ ํ•„์š”.
๊ฐ™์€ IP ์•ˆ์—์„œ ๋™์ž‘ํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์œ„ํ•ด PORT๊ฐ€ ํ•„์š”
IP๋Š” ๋ณ€ํ•˜๊ธฐ ์‰ฝ๊ณ  ์™ธ์šฐ๊ธฐ ์–ด๋ ต๊ธฐ ๋•Œ๋ฌธ์— DNS๊ฐ€ ํ•„์š”

URI๊ณผ ์›น ๋ธŒ๋ผ์šฐ์ € ์š”์ฒญ ํ๋ฆ„

URI (Uniform Resource Identifier)

  • ์ž์›์„ ์‹๋ณ„ํ•˜๋Š” ๋ฐฉ๋ฒ•

  • URI๋Š”

    • UResourceLocator : ๋ฆฌ์†Œ์Šค๊ฐ€ ์žˆ๋Š” ์œ„์น˜๋ฅผ ์ง€์ •

      • foo://example.com:8042/over/there?name=ferret#nose

    • UResourceName : ๋ฆฌ์†Œ์Šค์— ์ด๋ฆ„์„ ๋ถ€์—ฌ

      • urn:example:animal:ferret:nose

    • ๋˜๋Š” ๋‘˜ ๋‹ค ์ถ”๊ฐ€๋กœ ๋ถ„๋ฅ˜๋  ์ˆ˜ ์žˆ์Œ.

  • URL ๋ฌธ๋ฒ•

    • https://www.google.com:433/search?q=hello&hl=ko

      • https : ํ”„๋กœํ† ์ฝœ (http, https, ftp ๋“ฑ)

      • www.google.com : ํ˜ธ์ŠคํŠธ๋ช…

      • 433 : ํฌํŠธ ๋ฒˆํ˜ธ (http๋Š” 80, https๋Š” 443)

      • /search : Path (๋ฆฌ์†Œ์Šค ๊ฒฝ๋กœ)

      • q=hello&hl=ko : query parameter or query string ์œผ๋กœ ๋ถˆ๋ฆผ

์›น ๋ธŒ๋ผ์šฐ์ € ์š”์ฒญ ํ๋ฆ„

  • https://www.google.com:433/search?q=hello&hl=ko

    • www.google.com : DNS ์กฐํšŒ -> 200.200.200.2

      • 443 : HTTPS PORT ์ƒ๋žต

    • ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ HTTP ์š”์ฒญ ๋ฉ”์‹œ์ง€ ์ƒ์„ฑ

      • GET /search?q=hello&hl=ko HTTP/1.1

      • Host: www.google.com

    • socket ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ†ตํ•ด TCP/IP์— ์ „๋‹ฌ

    • TCP/IP ํŒจํ‚ท ์ƒ์„ฑ, HTTP ๋ฉ”์‹œ์ง€ ํฌํ•จ

    • ..

    • ์‘๋‹ต ๋ฉ”์‹œ์ง€


HTTP ๊ธฐ๋ณธ

HTTP

  • HyperText Transfer Protocol

  • HTTP์— ๊ฑฐ์˜ ๋ชจ๋“  ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•  ์ˆ˜ ์žˆ์Œ

    • HTML, TEXT, IMAGE, ์Œ์„ฑ, ์˜์ƒ, ํŒŒ์ผ, JSON, XML ...

  • ํŠน์ง•

    • ํด๋ผ์ด์–ธํŠธ ์„œ๋ฒ„ ๊ตฌ์กฐ

    • Stateless, connectionless

    • HTTP ๋ฉ”์‹œ์ง€๋กœ ํ†ต์‹ 

    • ๋‹จ์ˆœ, ํ™•์žฅ์„ฑ

ํด๋ผ์ด์–ธํŠธ ์„œ๋ฒ„ ๊ตฌ์กฐ

  • Request-Response ๊ตฌ์กฐ

  • ํด๋ผ์ด์–ธํŠธ๋Š” ์„œ๋ฒ„์— request ํ›„ response ๋Œ€๊ธฐ

  • ์„œ๋ฒ„๊ฐ€ request์— ๋Œ€ํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋งŒ๋“ค์–ด์„œ ์‘๋‹ต

Stateful, Stateless

Stateful

  • ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ์˜ ์ด์ „ ์ƒํƒœ๋ฅผ ๋ณด์กด

  • ex) ์ ์›์ด ๋ฐ”๋€Œ๋ฉด ๊ณ ๊ฐ์˜ ์ƒํƒœ๋ฅผ ์•Œ ์ˆ˜ ์—†์Œ (๋กœ๊ทธ์ธ)

    • ํ•ญ์ƒ ๊ฐ™์€ ์„œ๋ฒ„์™€ ์—ฐ๊ฒฐ

  • ์ผ๋ฐ˜์ ์œผ๋กœ ๋ธŒ๋ผ์šฐ์ € ์ฟ ํ‚ค์™€ ์„œ๋ฒ„ ์„ธ์…˜๋“ค์„ ์‚ฌ์šฉํ•ด ์ƒํƒœ ์œ ์ง€

  • ์ƒํƒœ ์œ ์ง€๋Š” ์ตœ์†Œํ•œ๋งŒ ์‚ฌ์šฉ

Stateless

  • ์„œ๋ฒ„๊ฐ€ ํด๋ผ์ด์–ธํŠธ์˜ ์ด์ „ ์ƒํƒœ๋ฅผ ๋ณด์กด X

  • ex) ์ ์›์ด ๋ฐ”๋€Œ์–ด๋„ ๊ณ ๊ฐ์˜ ์ƒํƒœ๋ฅผ ์•Œ ์ˆ˜ ์žˆ์Œ (์†Œ๊ฐœ ํŽ˜์ด์ง€)

    • ์Šค์ผ€์ผ ์•„์›ƒ(์ˆ˜ํ‰ ํ™•์žฅ)์— ์œ ๋ฆฌ

  • ์žฅ: ์„œ๋ฒ„ ํ™•์žฅ์„ฑ์ด ๋†’์Œ, ์‘๋‹ต ์„œ๋ฒ„๋ฅผ ์‰ฝ๊ฒŒ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Œ

  • ๋‹จ: ํด๋ผ์ด์–ธํŠธ๊ฐ€ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ง€์†์ ์œผ๋กœ ์ „์†ก

๋น„ ์—ฐ๊ฒฐ์„ฑ(connectionless)

  • Connectionless

    • ์„œ๋ฒ„ ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜๋Š” ๋ชจ๋ธ

      • ์„œ๋ฒ„ ์ž์› ์†Œ๋ชจ

    • ์„œ๋ฒ„ ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜์ง€ ์•Š๋Š” ๋ชจ๋ธ

      • ์ตœ์†Œํ•œ์˜ ์ž์› ์œ ์ง€

  • HTTP๋Š” ๊ธฐ๋ณธ์ด ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜์ง€ ์•Š๋Š” ๋ชจ๋ธ

  • ์„œ๋ฒ„์˜ ์ž์›์„ ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉ

  • HTTP ์ง€์† ์—ฐ๊ฒฐ(Persistent Connections)๋กœ TCP/IP์˜ 3 way handshake ์‹œ๊ฐ„ ์†Œ์š” ํ•ด๊ฒฐ

  • HTTP/2, HTTP/3 ์—์„œ ์ตœ์ ํ™”

HTTP ๋ฉ”์‹œ์ง€

  • HTTP ๋ฉ”์‹œ์ง€ ๊ตฌ์กฐ

    • ์‹œ์ž‘ ๋ผ์ธ (start-line)

    • ํ—ค๋” (header)

    • ๊ณต๋ฐฑ ๋ผ์ธ (empty line, CRLF)

    • message body

Start-Line

  • request-line (GET /search?q=hello&hl=ko HTTP/1.1)

    • HTTP ๋ฉ”์„œ๋“œ -GET, POST, PUT, DELETE

    • ์š”์ฒญ ๋Œ€์ƒ (absolute-path[?query])

    • HTTP Version

    // ์š”์ฒญ ๋ฉ”์‹œ์ง€
    GET /search?q=hello&hl=ko HTTP/1.1
    Host: www.google.com
  • status-line

    • HTTP ๋ฒ„์ „

    • HTTP ์ƒํƒœ ์ฝ”๋“œ

      • 200, 400, 500

    • ์ด์œ  ๋ฌธ๊ตฌ

    // ์‘๋‹ต ๋ฉ”์‹œ์ง€
    HTTP/1.1 200 OK
    Content-Type: text/html;charset=UTF-8
    Content-Length: 3423
    
    <html>
        <body>...</body>
    </html>

HTTP Header

  • HTTP ์ „์†ก์— ํ•„์š”ํ•œ ๋ชจ๋“  ๋ถ€๊ฐ€์ •๋ณด

    • message body๋ฅผ ์ œ์™ธํ•˜๊ณ  ํ•„์š”ํ•œ ๋ชจ๋“  ๋ฉ”ํƒ€ ์ •๋ณด

Message Body

  • ์‹ค์ œ ์ „์†กํ•  ๋ฐ์ดํ„ฐ

    • HTML ๋ฌธ์„œ, ์ด๋ฏธ์ง€, ์˜์ƒ, JSON ๋“ฑ๋“ฑ (Byte ํ‘œํ˜„ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ)

Last updated