[ν’€μŠ€νƒ] HTTP/1.1 intro / URL, TCP/IP

2023. 4. 18. 17:12ㆍComputerScience/FullStackProgramming

 

 

 

Web Client and Servers

Basic components of the WWW

  • INTERNET
    • 컴퓨터λ₯Ό μ μœΌλ‘œ μ°κ³ , μ κ³Ό μ μ„ μ—°κ²°ν•˜λ©΄ μ»΄ν“¨ν„° λ„€νŠΈμ›Œν¬κ°€ λœλ‹€.
    • 인터넷(IP protocol)으둜 μ΄λ“€μ„ μ—°κ²°ν•œ κ²ƒ
  • WEB
    • μ›Ή λΈŒλΌμš°μ € ν™”면을 μ±„μš°κ³  μžˆλŠ” ν™”λ©΄ 
    • μ›Ή νŽ˜μ΄μ§€ - μ›Ή νŽ˜μ΄μ§€ κ°„ κ΄€κ³„ -> Web
    • 정보와 μ •λ³΄λ₯Ό μ—°κ²°ν•˜λŠ” κ²ƒ 
  • ν•¨μˆ˜ ν˜ΈμΆœ κ³Όμ •κ³Ό κ΅‰μž₯히 μœ μ‚¬
  • ν΄λΌμ΄μ–ΈνŠΈκ°€ μ •λ³΄λ₯Ό λ³΄λ‚΄λ©΄, httpκ°€ μ‘닡을 μ€Œ
  • 물리학과 κ΄€λ ¨λœ μ—°κ΅¬ μžλ£Œλ“€μ„ μ£Όκ³  λ°›μ„ μˆ˜ μžˆλ„둝
  • νŒ€ λ²„λ‚˜μŠ€λ¦¬

 

 

 

Resources

A resource is any kind of content source

  • Static content
    • File system
    • MS word file, image file, Video Clip
    • Full μ˜μƒμ„ μͺΌκ°œμ„œ κ°€μ Έμ˜€λŠ” 것
    • μ‹€μ‹œκ°„ 슀트리밍 μ˜μƒλ„, μ‹€μ‹œκ°„μœΌλ‘œ μ„œλ²„ 파일(static)을 λ³΄λ‚΄λŠ” 것
  • Dynamic content
    • generated by SW program
    • Live image, Trade Stocks, etc
    • ν˜„ μ‹œκ°, λ‚΄ κ³„μ’Œμ˜ μž”κ³ λ₯Ό 보고 μ‹Άλ‹€
    • ν•΄λ‹Ή μ‹œμ μ— μ„œλ²„κ°€ 보내쀄 정보λ₯Ό μ°Ύμ•„μ„œ μ£ΌλŠ” 것

 

 

  • URI (Uniform Resource Identifier)
    • Server resource name
      • Addresses of the Internet
      • Uniquely identifying
      • Locating information resource
    •  URL and URN

 

  • URI
    • 컨셉
    • μ–΄λŠ μ„œλ²„(컴퓨터)에 μžˆλŠ” μ–΄λ–€ νŒŒμΌμ„ μ§€μΉ­ν•  μˆ˜ μžˆλŠ” κ²ƒ 
    • κ·Έ μ»΄ν“¨ν„°μ— μ†ν•œ κ·Έ νŒŒμΌ -> μœ λ‹ˆν¬ ν•΄μ•Ό 함 
  • URL - locator
    • μ›Ή λΈŒλΌμš°μ €κ°€ μžˆμœΌλ©΄, μœ λ‹ˆν¬ν•˜κ²Œ μ΄ μ»΄ν“¨ν„° μ•„λž˜μ˜ νŒŒμΌμ„ μ§€μΉ­ν•˜λŠ” λͺ…λͺ…법
    • locator -> μœ λ‹ˆν¬ν•œ μœ„μΉ˜λ₯Ό 기반으둜 함
  • URN - name
    • 전세계 λͺ¨λ“  νŒŒμΌμ—κ²Œ (μœ„μΉ˜ μ •λ³΄κ°€ μ•„λ‹Œ) μœ λ‹ˆν¬ν•œ μ΄λ¦„을 μ§€μ–΄μ£Όμž
    • μ΄λŸ¬ν•œ κΈ°λ²•μ€ ν˜„μ‘΄ν•˜μ§€ μ•ŠμŒ 
    •  URL이 μ‚΄μ•„남은 κ²ƒ - μ£Όμ†Œμ°½μ„ μ΄λ ‡κ²Œ λΆ€λ₯΄λŠ” μ΄μœ 
    • μ–΄λŠ μ»΄ν“¨ν„°μ˜ μ–΄λŠ μœ„μΉ˜μ˜ νŒŒμΌμ„ λ‹¬λΌ!

 

 

 

Transactions

Requests and Responses between HTTP Client/Server

  • HTTP messages
    • request
    • response

 

< request >

  • GET (λ©”μ†Œλ“œ)
    λ¦¬μ†ŒμŠ€λ₯Ό μš”μ²­ν•œλ‹€
    루트 directory λ°‘μ˜ ~~ νŒŒμΌμ„ μ£Όμ„Έμš”
    -> λ©”μ†Œλ“œμ™€ URL 
    host -> μ ‘μ†ν•˜λŠ” μ„œλ²„μ˜ μ£Όμ†Œλ„ λ„£μ€ κ²ƒ 

 

< response >

  • 파일이 μžˆκ³ , length
  • λ„€κ°€ μš”μ²­ν•œ get은 μ„±κ³΅μ μœΌλ‘œ λλ‚¬μ–΄ 
  • 200 OK -> λ‘˜ λ‹€ μ˜λ―Έ(성곡)λ₯Ό λ³΄λ‚΄μ£ΌλŠ” κ²ƒ
  • ν•¨μˆ˜μ— λŒ€ν•œ λ¦¬ν„΄κ°’μ²˜λŸΌ λŒλ €μ€€λ‹€ 
  • HTTP ν”„λ‘œν† μ½œλ‘œ μ‘λ‹΅ν•˜λ©°, λ‚˜μ˜ λ²„전은 1.0이야

 

 

 

  • HTTP methods
    • supports several request commands
    • server whar action to perform
    • GET - 기본적인 λ™μž‘, get request - send named resource from the server to the client
    • PUT - μ—…λ‘œλ“œ, μ„œλ²„μ— λ¦¬μ†ŒμŠ€λ₯Ό μ˜¬λ¦¬λŠ” 것 - store data from client into a named server resource.
    • DELETE - μ„œλ²„μ— μžˆλŠ” λ¦¬μ†ŒμŠ€λ₯Ό μ§€μš°λŠ” 것 - delete the named resource from a server
    • POST - send client data into a server gateway application
    • HEAD - send just the HTTP headers from the response for the named resource
  • μ£Όκ³  λ°›λŠ”κ²Œ νŒŒμΌμ΄ μ•„λ‹Œ κ²½μš° -> μ‘°κ±΄λ¬Έ 같은 url ν˜•μ‹
  • νŒŒμΌμ„ μ£Όκ³  λ°›λŠ”κ²Œ μ•„λ‹ˆλΌ, μ •λ³΄λ₯Ό μ£Όκ³  λ°›λŠ” 것 (κΈ€μž μΉ˜κ³  enter)
  • ν•¨μˆ˜ μ΄λ¦„κ³Ό parameter μ£ΌλŠ” 것과 μœ μ‚¬ν•œ 양식 -> POST
  • 둜직이 λ°›μ•„ μ²˜λ¦¬ν•  λ°μ΄ν„°λ₯Ό λ³΄λ‚΄λŠ” κ²ƒ
    • gateway, logic(dynamic 처리), DB(static μ €μž₯) μ΄λ ‡κ²Œ 3개둜 ꡬ성됨 

 

 

 

Requests and Responses between HTTP Client/Server

  • Status codes 
    • HTTP response contain status code
    • Three - digit numeric code
    • Explanatory textual "reason phrase"
  • 200 - OK
  • 302 - μ„œλ²„λ‘œ μ™”λŠ”λ°, 본인이 직접 μ²˜λ¦¬ν•˜μ§€ μ•Šκ³ , λ‹€λ₯Έ 곳으둜 λ³΄λ‚΄λŠ” 것 ex) ꡬ글 둜그인 μ°½ μƒ₯μƒ₯
  • 404 - not found - λ„€κ°€ μš”μ²­ν•œ κ·Έ νŒŒμΌμ€ λ‚˜μ—κ²Œ μ—†μ–΄

 

  •  Web pages can consist of multiple objects
  • ꡉμž₯히 λ§Žμ€ μ„œλ²„듀이 ν™”λ©΄ μ»¨ν…μΈ λ₯Ό κ΅¬μ„±ν•˜λŠ” κ²ƒ
  • 개발자 λ„ꡬ -> λ„€νŠΈμ›Œν¬ (reload)

 

 

 

Messages

Requests and Responses between HTTP Client/Server

  • Request and Response
  • No other kinds of HTTP Messages
  • Line-oriented sequences of characters
  • Easy for humans to read and write
  • μ„œλ²„λŠ” ν΄λΌμ΄μ–ΈνŠΈκ°€ 보낸 쑰건 μš”μ²­μ„ 보고, 쑰건적 λŒ€μ‘μ„ ν•  수 μžˆλ‹€.
    • μ˜μ–΄ & ν”„λž‘μŠ€μ–΄ μš”μ²­ -> λ‚œ ν•œκΈ€λ§Œ μžˆμ–΄! λ“±λ“± 

 

 

 

https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview

 

 

 

  • mozilla foundation 
    firefox web browser
    User agent - λ‚΄κ°€ μ§€μ›ν•˜λŠ” λΈŒλΌμš°μ €λ₯Ό μ•Œλ €μ£ΌλŠ” κ²ƒ 
  • www -> m
    λͺ¨λ°”일 λ””λ°”μ΄μŠ€μ— λ§žλŠ” ν™˜κ²½ (κΈ°μ’… 선택도 κ°€λŠ₯! μ‹ κΈ°ν•˜λ‹€)
  • 결ꡭ은 μ΄ μ•žμͺ½ user agentλ₯Ό κ³ λ €ν•œ 것
    λͺ¨λ°”μΌμ—μ„œ PCλͺ¨λ“œλ₯Ό λ³Ό μˆ˜ μžˆλŠ” κ²ƒλ„ λ™μΌν•œ μ›λ¦¬

 

  • Server - 잘 μ•Œλ €μ€Œ -> ν•΄ν‚Ή
  • Last modified - 이 파일이 μ΅œμ’…μ μœΌλ‘œ μˆ˜μ •λœ μ‹œκ°„
    캐쉬λ₯Ό μ‚¬μš©ν•  수 μžˆλŠ” 이유! 
    μ„±λŠ₯, 속도 ν–₯상 κ°€λŠ₯

 

  • 1) ν¬νŠΈ μŠ€μΊλ„ˆ
    ν¬νŠΈκ°€ μ—΄λ ΈλŠ”지 λ‹«ν˜”λŠ”μ§€ ν™•μΈν•˜λŠ” ν”„λ‘œκ·Έλž¨
    OS λ‹¨κ³„μ˜ μœ λ‹‰μŠ€ λ¦¬λˆ…μŠ€λŠ” λŒ€λΆ€λΆ„ λ§€μš° μ•ˆμ •μ μž„
    λ‚¨μ˜ μ„œλ²„λ₯Ό μŠ€μΊλ‹ν•˜λŠ” 것 자체둜 λΆˆλ²• 
  • 2) μ›Ή -> κ³„속 λ²„μ „μ—…
    application λ³΄μ•ˆ λ¬Έμ œμ  λ°œμƒ
    DB -> νŒ¨μΉ˜ μ•ˆλ˜μ—ˆμœΌλ‹ˆ, κ·Έκ±Έ λš«μ„ 수 μžˆλŠ” 것

 

 

 

Connections

Transport layer under HTTP

TCP/IP

  •  Reliable Data Transfer (μ—°κ²° μ„€μ • O)
  • In Order Transfer
  • Connection Oriented
  • Bidirectional Byte Stream
  • Flow control
  • Congestion control

 

νŒ€ λ²„λ‚˜μŠ€ λ¦¬
error κ°™μ€ μƒν™©μ„ λ³΅μž‘ν•˜κ²Œ κ³ λ €ν•˜κ³  μ‹Άμ§€ μ•Šμ•˜λ‹€ 
μˆœμˆ˜ν•˜κ²Œ μ •λ³΄λ₯Ό λ³΄λ‚΄κ³ , λ°›λŠ” κ²ƒ

μ—λŸ¬ κ²€μΆœ λ° λ³΅κ΅¬ 
μˆœμ„œ λ§žμΆ°μ£Όκ³ , μ—°κ²° μ„€μ •, flow control
λ”°λΌμ„œ http1.1은 ν•­μƒ tcp/ipλ₯Ό κΉ”κ³  κ°„λ‹€

 

  • TCP/IP의 단점 κ³ μŠ€λž€νžˆ
    • 1) μ΄ˆλ°˜μ—λŠ” ν•­μƒ λŠλ¦¬λ‹€ -> slow start 
    • 2) μ„±λŠ₯을 보μž₯ν•  수 μ—†λ‹€. 
    • ν†±λ‹ˆλ°”ν€΄ (항상 κ³ μ†μ˜, μΌμ •ν•œ data rateλ₯Ό μœ μ§€ν•˜λŠ”κ²Œ λΆˆκ°€λŠ₯)
    • + human readable -> 200 OK -> λ‚­λΉ„ 
    • 결ꡭ은 μ„±λŠ₯이 μ•ˆ λ‚˜μ˜¨κ²ƒ // μ§€κΈˆμ€ 3κΉŒμ§€
  • TCPλŠ” HTTP ν•˜λ‹¨μ— κΉ”λ¦°λ‹€. 
  • μ’…μ’… HTTPS -> security
  • μ•”ν˜Έν™” κΈ°λŠ₯이 μΆ”가됨 (TLS, SSL)
  • TPC : transport layer -> HTTP : Application layer
    • μ •ν™•νžˆ HTTPκ°€ 뭐지? 
    • Hyper Text Transfer Protocol
    • HTML λ¬Έμ„œλ₯Ό μ£Όκ³  λ°›λŠ” 데 μ“°μ΄λŠ” 톡신 ν”„λ‘œν† μ½œ (κ·œμ•½) 
    • ν΄λΌμ΄μ–ΈνŠΈμ™€ μ„œλ²„ μ‚¬μ΄μ˜ μš”μ²­κ³Ό 응닡에 λŒ€ν•œ ν”„λ‘œν† μ½œ

 

 

 

  • Connections process
    • TCP - connection oriented 
      μ–Έμ œ μ–΄λ–»κ²Œ μ—°κ²°λ κΉŒ? 
    • URL νƒ€μž… -> DNSλ₯Ό ν†΅ν•΄ IP μ£Όμ†Œ κ°€μ Έμ˜΄ 
    • HTTP λ¦¬ν€˜μŠ€νŠΈκ°€ λ‚˜κ°€κΈ° μ „에, μƒλŒ€λ°© μ„œλ²„μ™€ TCP μ—°κ²° μš”청을 λ¨Όμ € 함
    • 이후 HTTP GET request λ₯Ό λ³΄λ‚΄κ³ , μ‘닡을 λ°›μŒ
    • TCP μ—°κ²°μ„ λŠλŠ” κ³Όμ •
      • timer - μΌμ • μ‹œκ°„ μ§€λ‚¬λŠ”데, ν΄λΌμ΄μ–ΈνŠΈ μš”μ²­ μ—†μœΌλ©΄ 
      • 1. μ„œλ²„ μΈ‘μ—μ„œ μ—°κ²°μ„ λŠκ±°λ‚˜
      • 2. ν΄λΌμ΄μ–ΈνŠΈκ°€ μ—°κ²° ν•΄μ œ μš”μ²­
    •  μ‚¬μš©μžκ°€ λŠλΌλŠ” μ—°κ²° μ§€μ—°μ΄λΌλŠ” κ°œλ…μ΄ λ“±μž₯!