J1Yun
ZU-TECHLOG
J1Yun
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
  • ๐Ÿ“‘ Category (135)
    • Algorithm (61)
      • ๐Ÿ“š Concept (6)
      • ๐Ÿ“˜ Baekjoon Judge (53)
      • ๐Ÿ“— Programmers (2)
    • Computer Science (42)
      • ๐Ÿ”’ Operating System (14)
      • ๐Ÿ“ก Network (15)
      • ๐Ÿ’พ Database (8)
      • ๐Ÿงฉ Design Pattern (4)
      • ๐Ÿ”‘ Security (1)
    • Activities (12)
      • ๐Ÿฆ ๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ 9๊ธฐ (6)
      • ๐Ÿ’ป SW๋งˆ์—์ŠคํŠธ๋กœ 13๊ธฐ (6)
    • Infra (1)
      • โ˜๏ธ AWS (1)
    • Languages (1)
      • ๐Ÿ’™ Python (1)
    • Backend (7)
      • ๐Ÿ”ต Django (4)
      • ๐ŸŸข Node.js (3)
    • Ect. (8)
      • ๐Ÿ’ฌ Talk (0)
      • ๐Ÿ—‚๏ธ ๊ฐœ๋ฐœ์ง๊ตฐ ์ทจ์—… ์ค€๋น„์ž๋ฃŒ (8)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

250x250
hELLO ยท Designed By ์ •์ƒ์šฐ.
J1Yun

ZU-TECHLOG

[๋„คํŠธ์›Œํฌ] HTTP ์ฃผ์š” ๋ฉ”์„œ๋“œ - GET, POST, PUT, PATCH, DELETE
Computer Science/๐Ÿ“ก Network

[๋„คํŠธ์›Œํฌ] HTTP ์ฃผ์š” ๋ฉ”์„œ๋“œ - GET, POST, PUT, PATCH, DELETE

728x90

HTTP ๋ฉ”์„œ๋“œ

HTTP ๋ฉ”์„œ๋“œ๋ž€ ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„ ์‚ฌ์ด์— ์ด๋ฃจ์–ด์ง€๋Š” ์š”์ฒญ(Request)๊ณผ ์‘๋‹ต(Response) ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

HTTP ๋ฉ”์„œ๋“œ์˜ ์ข…๋ฅ˜๋Š” ์ด 9๊ฐ€์ง€์ธ๋ฐ, ์ด์ค‘ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์†Œ๋“œ 5๊ฐ€์ง€์™€ ๊ธฐํƒ€ ๋ฉ”์„œ๋“œ 4๊ฐ€์ง€๋กœ ๊ตฌ๋ถ„๋œ๋‹ค.

์ฃผ์š” ๋ฉ”์„œ๋“œ

  • GET: ๋ฆฌ์†Œ์Šค ์กฐํšŒ
  • POST: ์š”์ฒญ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ, ์ฃผ๋กœ ๋“ฑ๋ก์— ์‚ฌ์šฉ
  • PUT: ๋ฆฌ์†Œ์Šค๋ฅผ ๋Œ€์ฒดํ•˜๋ฉฐ ํ•ด๋‹น ๋ฆฌ์†Œ์Šค๊ฐ€ ์—†์œผ๋ฉด ์ƒ์„ฑ
  • PATCH: ๋ฆฌ์†Œ์Šค ๋ถ€๋ถ„ ๋ณ€๊ฒฝ
  • DELETE: ๋ฆฌ์†Œ์Šค ์‚ญ์ œ

๊ธฐํƒ€ ๋ฉ”์„œ๋“œ

  • HEAD: GET๊ณผ ๋™์ผํ•˜์ง€๋งŒ ๋ฉ”์‹œ์ง€(body) ๋ถ€๋ถ„์„ ์ œ์™ธํ•˜๊ณ  ์ƒํƒœ ์ค„๊ณผ ํ—ค๋”๋งŒ ๋ฐ˜ํ™˜
  • OPTIONS: ๋Œ€์ƒ ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ํ†ต์‹  ๊ฐ€๋Šฅ ์˜ต์…˜์„ ์„ค๋ช… (์ฃผ๋กœ CORS์—์„œ ์‚ฌ์šฉ)
  • CONNECT: ๋Œ€์ƒ ์ž์›์œผ๋กœ ์‹๋ณ„๋˜๋Š” ์„œ๋ฒ„์— ๋Œ€ํ•œ ํ„ฐ๋„์„ ์„ค์ •
  • TRACE: ๋Œ€์ƒ ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ๊ฒฝ๋กœ๋ฅผ ๋”ฐ๋ผ ๋ฉ”์‹œ์ง€ ๋ฃจํ”„๋ฐฑ ํ…Œ์ŠคํŠธ ์ˆ˜ํ–‰

 

HTTP ๋ฉ”์„œ๋“œ ํŠน์ง•

  • ์•ˆ์ „์„ฑ(Safe)
    • ์•ˆ์ „ํ•œ ๋ฉ”์„œ๋“œ์˜ ๋ชฉ์ ์€ ์„œ๋ฒ„์— ์˜ํ–ฅ์„ ์ค„ ์ˆ˜ ์žˆ๋Š” ๋ฉ”์„œ๋“œ๊ฐ€ ์‚ฌ์šฉ๋  ๋•Œ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ๊ทธ ์‚ฌ์‹ค์„ ์•Œ๋ ค์ค„ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฒƒ
    • ์ฝ๊ธฐ ์ „์šฉ์ผ ๋•Œ ์•ˆ์ „ํ•œ ๋ฉ”์„œ๋“œ๋กœ ๊ฐ„์ฃผ
    • Ex) GET, HEAD, OPTIONS, TRACE
  • ๋ฉฑ๋“ฑ์„ฑ(Idempotent)
    • ํŠน์ • ๋ฉ”์„œ๋“œ์˜ ์š”์ฒญ์„ ์—ฌ๋Ÿฌ๋ฒˆ ํ•˜๋”๋ผ๋„ ๋™์ผํ•œ ๊ฒฐ๊ณผ๊ฐ€ ๋ฐ˜ํ™˜๋  ๋•Œ ๋ฉฑ๋“ฑํ•˜๋‹ค๊ณ  ํ•จ
    • Ex) GET, PUT, DELETE, HEAD, OPTIONS, TRACE
  • ์บ์‹œ ๊ฐ€๋Šฅ์„ฑ
    • ์ถ”ํ›„ ์žฌ์‚ฌ์šฉ์„ ์œ„ํ•ด ์‘๋‹ต์„ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Œ์„ ๋‚˜ํƒ€๋ƒ„
    • Ex) GET, POST, PATCH, HEAD

 

 

1. GET

  • ๋ฆฌ์†Œ์Šค ์กฐํšŒ / ๋ฐ์ดํ„ฐ ๊ฒ€์ƒ‰ (Read)
  • ์„œ๋ฒ„์— ์ „๋‹ฌํ•˜๊ณ  ์‹ถ์€ ๋ฐ์ดํ„ฐ๋Š” ์ฟผ๋ฆฌ ์ŠคํŠธ๋ง(Query-String)์„ ํ†ตํ•ด ์ „๋‹ฌ
    • Ex) GET /users/10?username=jiyun&age=24
  • ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋™์ผํ•œ ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด ๋งค๋ฒˆ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ์ƒ์„ฑ (๋ฉฑ๋“ฑ์„ฑ)
  • ์บ์‹ฑ์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐ์ดํ„ฐ ์กฐํšŒ ์‹œ GET์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์œ ๋ฆฌ

 

2. POST

  • ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€/์ƒ์„ฑ/์ฒ˜๋ฆฌ (Create/Insert)
  • ๋ฉ”์‹œ์ง€ ๋ฐ”๋””(body)๋ฅผ ํ†ตํ•ด ์„œ๋ฒ„๋กœ ์š”์ฒญ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ -> ์„œ๋ฒ„๋Š” ์š”์ฒญ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜์—ฌ ์—…๋ฐ์ดํŠธ
  • ์ฃผ๋กœ ์‹ ๊ทœ ๋ฆฌ์†Œ์Šค ๋“ฑ๋ก, ํ”„๋กœ์„ธ์Šค ์ฒ˜๋ฆฌ์— ์‚ฌ์šฉ
  • ๋ฉฑ๋“ฑ์„ฑ์„ ๊ฐ€์ง€์ง€ ์•Š์•„ ๋™์ผํ•œ POST ์š”์ฒญ์„ ํ•˜์—ฌ๋„ ๋‹ค๋ฅธ ๋ฆฌ์†Œ์Šค๊ฐ€ ์ƒ์„ฑ

 

3. PUT

  • ๊ธฐ์กด ๋ฆฌ์†Œ์Šค ์ˆ˜์ • / ๋ฐ์ดํ„ฐ ๊ฐฑ์‹  (Update)
  • ๋ฉ”์‹œ์ง€ ๋ฐ”๋”” ๋‚ด์˜ ๋ฆฌ์†Œ์Šค๊ฐ€ ์žˆ์œผ๋ฉด ๋ฎ์–ด์“ฐ๊ณ , ์—†์œผ๋ฉด ์ƒˆ๋กœ ์ƒ์„ฑ
  • ํด๋ผ์ด์–ธํŠธ๋Š” ๋ฆฌ์†Œ์Šค์˜ ๊ตฌ์ฒด์ ์ธ ๊ฒฝ๋กœ๋ฅผ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ•จ
    • Ex) PUT /users/10: 10๋ฒˆ ์œ ์ € ์ˆ˜์ •

 

4. PATCH

  • ๋ฆฌ์†Œ์Šค์˜ ์ผ๋ถ€ ๋ถ€๋ถ„ ๋ณ€๊ฒฝ (Update)
  • ๋ฉ”์‹œ์ง€ ๋ฐ”๋”” ๋‚ด์˜ ๋ฆฌ์†Œ์Šค๋งŒ์„ ๋ถ€๋ถ„์ ์œผ๋กœ ์—…๋ฐ์ดํŠธ (PATCH๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ POST๋กœ ๋Œ€์ฒด)

 

5. DELETE

  • ๊ธฐ์กด ๋ฆฌ์†Œ์Šค ์‚ญ์ œ (Delete)
  • ์ž์› ์‚ญ์ œ ํ›„ ํ•ด๋‹น ์ž์›์ด ์‚ฌ๋ผ์ ธ ์‘๋‹ตํ•  ๋‚ด์šฉ์ด ์—†๋Š”๊ฒฝ์šฐ 204(NO CONTENT) ๋ฐ˜ํ™˜

 

 

โ€ป GET๊ณผ POST์˜ ์ฐจ์ด

GET์€ ์„œ๋ฒ„ ์ƒ์˜ ๋ฐ์ดํ„ฐ๋‚˜ ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝ์‹œํ‚ค์ง€ ์•Š์•„์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์กฐํšŒ๋ฅผ ์œ„ํ•ด์„œ๋งŒ ์‚ฌ์šฉํ•˜์ง€๋งŒ, POST๋Š” ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€/์ƒ์„ฑ/์ฒ˜๋ฆฌ ๋“ฑ์„ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค. 

GET์€ ๋ฉฑ๋“ฑ์„ฑ์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋งค ์š”์ฒญ ์‹œ๋งˆ๋‹ค ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ๋‚ด์ง€๋งŒ POST๋Š” ๋ฉฑ๋“ฑ์„ฑ์ด ์—†๋‹ค.

GET๊ณผ POST์˜ ์ž์„ธํ•œ ํŠน์ง•๊ณผ ์ฐจ์ด๋Š” ์•„๋ž˜ ํฌ์ŠคํŒ…์— ์ž์„ธํžˆ ์ •๋ฆฌํ•ด๋†“์•˜๋‹ค.
https://zu-techlog.tistory.com/65

 

[๋„คํŠธ์›Œํฌ] GET ๋ฉ”์„œ๋“œ์™€ POST ๋ฉ”์„œ๋“œ ํŠน์ง•, ์ฐจ์ด

GET๊ณผ POST๋Š” HTTP ํ”„๋กœํ† ์ฝœ์„ ์ด์šฉํ•ด ์„œ๋ฒ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ๋ฐฉ์‹์ด๋‹ค. ๊ฐ๊ฐ GET๊ณผ POST ๋ฉ”์„œ๋“œ์˜ ํŠน์ง• ๋ฐ ์ฐจ์ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. GET ๋ฉ”์„œ๋“œ ๊ฐœ๋… ์ •๋ณด ์กฐํšŒ๋ฅผ ์œ„ํ•œ ๋ฉ”์„œ๋“œ ํด๋ผ์ด์–ธํŠธ๊ฐ€

zu-techlog.tistory.com

 

โ€ป POST์™€ PUT์˜ ์ฐจ์ด

POST๋Š” Create/Insert์˜ ๊ฐœ๋…์ด๊ณ , PUT์€ Update์˜ ๊ฐœ๋…์ด๋‹ค.

PUT์€ POST์™€ ๋‹ฌ๋ฆฌ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ฆฌ์†Œ์Šค์˜ ์œ„์น˜๋ฅผ ์•Œ๊ณ  URI๋ฅผ ์ง€์ •ํ•ด ์ฃผ์–ด์•ผ ํ•œ๋‹ค.

POST๋Š” ๋ฉฑ๋“ฑ์„ฑ์„ ๊ฐ€์ง€์ง€ ์•Š๋Š” ๋ฐ˜๋ฉด, PUT์€ ๋ฉฑ๋“ฑ์„ฑ์„ ๊ฐ€์ง„๋‹ค.

 

โ€ป PUT๊ณผ PATCH์˜ ์ฐจ์ด

PUT์€ ๋ฆฌ์†Œ์Šค ์ „์ฒด๋ฅผ ๊ต์ฒดํ•˜๊ณ , PATCH๋Š” ์ผ๋ถ€ ๋ฐ์ดํ„ฐ๋งŒ ๋ณ€๊ฒฝํ•œ๋‹ค.

PUT ์š”์ฒญ์—์„œ PATCH ์š”์ฒญ์ฒ˜๋Ÿผ ๋ฉ”์‹œ์ง€ ๋ฐ”๋””์— ์ผ๋ถ€ ๋ฐ์ดํ„ฐ๋งŒ ๋ช…์‹œํ•ด ๋ณ€๊ฒฝํ•˜๋ ค ํ•œ๋‹ค๋ฉด, ๋ช…์‹œ๋˜์ง€ ์•Š์€ ์ž์› ๋ฐ์ดํ„ฐ๋Š” ์‚ฌ๋ผ์ง„์ฑ„ ๋ฎ์–ด์”Œ์›Œ์ง„๋‹ค.

728x90
์ €์ž‘์žํ‘œ์‹œ (์ƒˆ์ฐฝ์—ด๋ฆผ)

'Computer Science > ๐Ÿ“ก Network' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[๋„คํŠธ์›Œํฌ] DNS(๋„๋ฉ”์ธ ๋„ค์ž„ ์‹œ์Šคํ…œ) ๊ตฌ์„ฑ์š”์†Œ, ๋™์ž‘๋ฐฉ์‹  (0) 2023.02.14
[๋„คํŠธ์›Œํฌ] SOP(Same Origin Policy)์™€ CORS(Cross-Origin Resource Sharing), CORS ์˜ค๋ฅ˜ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•  (0) 2023.02.13
[๋„คํŠธ์›Œํฌ] ํ† ํฐ ๊ธฐ๋ฐ˜ ์ธ์ฆ(+JWT), ์„œ๋ฒ„(์„ธ์…˜)๊ธฐ๋ฐ˜ ์ธ์ฆ  (0) 2023.02.10
[๋„คํŠธ์›Œํฌ] SSL/TLS ํ•ธ๋“œ์‰์ดํฌ - TLS 1.3  (0) 2023.02.09
[๋„คํŠธ์›Œํฌ] HTTP/1.X, HTTP2, HTTP3 ๋ฒ„์ „ ์ฐจ์ด, ํŠน์ง•  (0) 2023.02.07
    'Computer Science/๐Ÿ“ก Network' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€์ด๋‹ค
    • [๋„คํŠธ์›Œํฌ] DNS(๋„๋ฉ”์ธ ๋„ค์ž„ ์‹œ์Šคํ…œ) ๊ตฌ์„ฑ์š”์†Œ, ๋™์ž‘๋ฐฉ์‹
    • [๋„คํŠธ์›Œํฌ] SOP(Same Origin Policy)์™€ CORS(Cross-Origin Resource Sharing), CORS ์˜ค๋ฅ˜ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•
    • [๋„คํŠธ์›Œํฌ] ํ† ํฐ ๊ธฐ๋ฐ˜ ์ธ์ฆ(+JWT), ์„œ๋ฒ„(์„ธ์…˜)๊ธฐ๋ฐ˜ ์ธ์ฆ
    • [๋„คํŠธ์›Œํฌ] SSL/TLS ํ•ธ๋“œ์‰์ดํฌ - TLS 1.3
    J1Yun
    J1Yun
    ๊ฐœ๋ฐœ ๊ด€๋ จ ๊ธฐ์ˆ  ๋ฐ ๊ณต๋ถ€ ๋‚ด์šฉ ๊ธฐ๋ก์žฅ

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”