[Network] HTTP 정리

Parker cho·2022년 6월 1일
0

Web and HTTP

Review

  • Web page consist of objects
  • object can be HTML file, JPEG image, audio file…
  • web page consists of base HTML file which includes several referenced objects

HTTP Oerview

HTTP: hypertext transfer protocol

  • client: send request and displays web objects
  • server: send responses to client

Features

  • HTTP is stateless
    • server maintains no information about past client
  • HTTP uses TCP
    • client init TCP connection
    • server accepts TCP connection from client
    • HTTP message exchanged between client and server

HTTP Connection

Non-persistent HTTP (HTTP 1.0)

  1. HTTP client initiate TCP connection to HTTP server port 80
  2. HTTP server at host accepts connection and notifying client
  3. request
  4. response
  5. TCP Close
  6. Steps 1-5 repeated for each of objects

Features

  • requires 2 RTTs per object
  • OS overhead for each TCP connection

Persistent HTTP (HTTP 1.1)

Features

  • server leaves connection open after sending response
  • as little as one RTT for all the referenced objects (cutting response time in half)

pipelined GETs (HTTP 1.1)

HTTP request message

  • Two types of HTTP messages: request, response
  • HTTP request message
    • ASCII (human-readable format)

HTTP request message: general format

Other HTTP request messages

  • POST (no idempotent)
    POST /cat HTTP/1.1
    
    { "age": 3 }
    
    HTTP/1.1 201 Created
    • user input sent from client to server in entity body of HTTP POST request message
  • GET
    • include user data in URL field of HTTP GET request message
  • HEAD
    • requests headers (only)
  • PUT (idempotent)
    POST /cat/1 HTTP/1.1
    
    { "age": 3 }
    
    HTTP/1.1 201 Created
    • client know`s resources url
    • uploads new object to server
    • completely replaces file that exists at specified URL

HTTP response message

HTTP response status codes

status code appears in 1st line

  • 200: OK
  • 301: Moved Permanently
  • 400: Bad Request
  • 404: Not Found
  • 505: HTTP Version Not Supported
profile
true nobility is being superior to your former self

0개의 댓글