2022/05/01 HTTP스펙에 대해서 알아보자

김석진·2022년 5월 1일
0

다시 초심으로

목록 보기
7/19

HTTP(Hyper Text Transfer Protocol)

그냥 문자가 아닌 Hyper텍스트를 전송하는데 활용하는 프로토콜(약속된 정의이다)
요청과 응답의 정의에 대해서만 간략히 설명
HTTP메세지는 서버와 클라이언트 간에 데이터가 교환되는 방식이다

메세지타입(Request, Response)

요청(Request)는 클라이언트가 서버로 전달해서 서버의 액션이 일어나게끔 하는 메세지
응답(Response)는 요청에 대한 서버의 답변이다

HTTP Request메세지 스펙예시

POST /create-developer HTTP/1.1
Content-Type: application/json
Accept: application/json

{
  "developerLevel": "JUNIOR",
  "developerSkillType": "FULL_STACK",
  "experienceYears": 2,
  "memberId": "sunny.flower",
  "name": "sun",
  "age": 36
}
  • 첫번째줄: 요청라인이다(Http메서드들이 들어감(GET,PUT,POST등))
  • 두번째줄부터 줄바꿈 나오기전({)까지:Header(User-Agent,Accept등)
  • 헤더에서 줄바꿈 이후: Request Body

HTTP Response 메세지 스펙예시

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Date: Sat, 17 Jul 2021 15:33:34 GMT
Keep-Alive: timeout=60
Connection: keep-alive

{
  "developerLevel": "JUNIOR",
  "developerSkillType": "FULL_STACK",
  "experienceYears": 2,
  "memberId": "sunny.flo1wer",
  "name": "sun",
  "age": 36
}
  • 첫번째줄: 상태라인(200,500,등)
  • 두번째줄부터 줄바꿈 나오기 전까지: header
  • 헤더줄바꿈이후:Response body
profile
주니어 개발자 되고싶어요

0개의 댓글