TIL: HyperText Transfer Protocol (HTTP)

김하성·2021년 1월 26일
0
post-thumbnail

HyperText Transfer Protocol (HTTP)

HyperText is also included in the abbreviation, HTML, which stands for HyperText Markup Language. HTML documents contain tags that provide links to other HTML documents. It is a form of communication used by web browsers to create webpages. HTTP is a transfer protocol, or transfer agreement/code between computers that allow computers to receive and send HTML files. HTTP and HTML are thus inherently related! HTTP is simply a standard communication code (like any human language, including Korean and English) used by computers to send and receive HTML files. Without HTTP, we would only be able to share HTML files within our own local desktop or disk, which would be rather meaningless!

TWO THINGS TO REMEMBER:

  1. HTTP is made up of resquests and responses.
  2. Stateless. Each HTTP request and response is independent and is therefore unaware of previous requests and responses. It's like when two people have to introduce themselves to each other every time they meet. That's why computers have things like login tokens, browser cookies, and local storage for situations where data processing must be continued for a user (i.e. online shopping).텍스트

Requests vs Responses (Structure)

Requests
START LINE (made up of three parts)
1. HTTP Method - the three most commonly used are GET, POST, and DELETE
2. Status Code - the target URL
3. HTTP Version - the HTTP version that is being used
i.e. GET /login HTTP/1.1
HEADERS

  • contains meta data in the form of key: value pairs (dictionary)
    i.e.
    Headers: {
    Host: 요청을 보내는 목표(타겟)의 주소. 즉, 요청을 보내는 웹사이트의 기본 주소가 된다
    (ex. www.apple.co.kr)
    User-Agent: 요청을 보내는 클라이언트의 대한 정보 (ex. chrome, firefox, safari, explorer)
    Content-Type: 해당 요청이 보내는 메세지 body의 타입 (ex. application/json)
    Content-Length: body 내용의 길이
    Authorization: 회원의 인증/인가를 처리하기 위해 로그인 토큰을 Authroization 에 담는다
    }
    BODY
    The actual content of the request. Depending on the type of the request, a body might not be needed.

Responses
START LINE (made up of three parts)
1. HTTP Version - the HTTP version that is being used
2. Status Code: the status code of the reponse (404, 200, 201, etc.)
3. Status Text: brief text message that explains the status of the request (Not Found, SUCCESS)
HTTP/1.1 200 SUCCESS
HEADERS
Contains meta data that further describes the request (i.e. information about the server)
BODY
Contains the main content/data of the response. Like requests, responses don't always hava bodies.

profile
#mambamentality 🐍

0개의 댓글