Code Monkey home page Code Monkey logo

jwp-dashboard-http's Introduction

ํ†ฐ์บฃ ๊ตฌํ˜„ํ•˜๊ธฐ

๊ธฐ๋Šฅ ์š”๊ตฌ ์‚ฌํ•ญ

1๋‹จ๊ณ„ - HTTP ์„œ๋ฒ„ ๊ตฌํ˜„ํ•˜๊ธฐ

  • http://localhost:8080/index.html ํŽ˜์ด์ง€์— ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋‹ค.
    • Http Method๊ฐ€ GET์ธ์ง€ ํ™•์ธํ•œ๋‹ค.
    • / ์ผ ๊ฒฝ์šฐ ์•ˆ๋…• ๋ฌธ์ž์—ด์„ ์‘๋‹ตํ•˜๊ณ  ๊ทธ ์™ธ์—๋Š” ํŒŒ์ผ์„ ์ฝ์–ด์˜จ๋‹ค.
  • ์ ‘๊ทผํ•œ ํŽ˜์ด์ง€์˜ js, css ํŒŒ์ผ์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.
    • css: text/css
    • js: application/javascript
  • uri์˜ QueryString์„ ํŒŒ์‹ฑํ•˜๋Š” ๊ธฐ๋Šฅ์ด ์žˆ๋‹ค.
    • http://localhost:8080/login?account=gugu&password=password์œผ๋กœ ์ ‘์†ํ•˜๋ฉด ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€(login.html) ํŽ˜์ด์ง€์— ๋ณด์—ฌ์ค€๋‹ค.
    • Query String์„ ํŒŒ์‹ฑํ•ด์„œ ์•„์ด๋””, ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜๋ฉด ํšŒ์›์„ ์กฐํšŒํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
    • Query String ํ˜•์‹์— ๋Œ€ํ•œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

2๋‹จ๊ณ„ - ๋กœ๊ทธ์ธ ๊ตฌํ˜„ํ•˜๊ธฐ

  • ๋กœ๊ทธ์ธ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.
    • ์ƒํƒœ ์‘๋‹ต ์ฝ”๋“œ๋ฅผ 302๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
    • ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•˜๋ฉด /index.html๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค.
    • ๋กœ๊ทธ์ธ์— ์‹คํŒจํ•˜๋ฉด 401.html๋กœ ๋ฆฌ์•„๋””๋ ‰ํŠธํ•œ๋‹ค.
  • http://localhost:8080/register์œผ๋กœ ์ ‘์†ํ•˜๋ฉด ํšŒ์›๊ฐ€์ž… ํŽ˜์ด์ง€(register.html)๋ฅผ ๋ณด์—ฌ์ค€๋‹ค.
  • POST ๋ฐฉ์‹์œผ๋กœ ํšŒ์›๊ฐ€์ž…์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.
    • request header๋ฅผ ์ฝ๋Š”๋‹ค.
    • request body๋ฅผ ์ฝ๋Š”๋‹ค.
    • request body๋ฅผ Content-Type์— ๋งž๊ฒŒ ํŒŒ์‹ฑํ•œ๋‹ค.
    • ํšŒ์›๊ฐ€์ž…์„ ์™„๋ฃŒํ•˜๋ฉด /index.html๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค.
    • ํšŒ์›๊ฐ€์ž…์— ์‹คํŒจํ•˜๋Š” ๊ฒฝ์šฐ /register.html๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค. (์ค‘๋ณต๋œ ์•„์ด๋””)
  • ๋กœ๊ทธ์ธ์„ POST ๋ฐฉ์‹์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.
  • ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•˜๋ฉด HTTP Reponse์˜ ํ—ค๋”์— Set-Cookie๊ฐ€ ์กด์žฌํ•œ๋‹ค.
    • HTTP Request Header์˜ Cookie์— JSESSIONID๊ฐ€ ์—†๋ฏ€๋ฉด HTTP Response Header์— Set-Cookie๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.
    • ์ด๋ฏธ ์žˆ์œผ๋ฉด ๋กœ๊ทธ์ธํ•œ ์‚ฌ์šฉ์ž๋กœ ๊ฐ„์ฃผํ•˜๊ณ  /index.html๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค.
  • ์„œ๋ฒ„์— ์„ธ์…˜์„ ๊ด€๋ฆฌํ•˜๋Š” ํด๋ž˜์Šค๊ฐ€ ์žˆ๊ณ , ์ฟ ํ‚ค๋กœ๋ถ€ํ„ฐ ์ „๋‹ฌ ๋ฐ›์€ JSESSIONID ๊ฐ’์ด ์ €์žฅ๋œ๋‹ค.
    • ๋กœ๊ทธ์ธ๋œ ์ƒํƒœ์—์„œ /login ํŽ˜์ด์ง€์— GET์œผ๋กœ ์ ‘๊ทผํ•˜๋ฉด ์ด๋ฏธ ๋กœ๊ทธ์ธํ•œ ์ƒํƒœ์ด๊ธฐ ๋•Œ๋ฌธ์— /index.html๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค.

3๋‹จ๊ณ„ - ๋ฆฌํŒฉํ„ฐ๋ง

  • HTTP Request, HTTP Response ํด๋ž˜์Šค๋กœ ๋‚˜๋ˆ ์„œ ๊ตฌํ˜„ํ–ˆ๋‹ค.
  • Controller ์ธํ„ฐํŽ˜์ด์Šค์™€ RequestMapping ํด๋ž˜์Šค๋ฅผ ํ™œ์šฉํ•˜์—ฌ if์ ˆ์„ ์ œ๊ฑฐํ–ˆ๋‹ค.
    • ๊ธฐ์กด์˜ Controller ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋ณ€ํ˜•ํ•ด request, response๋ฅผ ๋ฐ›๋„๋ก ๋ณ€๊ฒฝํ•œ๋‹ค.
    • Controller ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” AbstractController๋ฅผ ๋งŒ๋“ค๊ณ  ์—ฌ๊ธฐ์„œ ๋ฉ”์„œ๋“œ์— ๋”ฐ๋ฅธ ๋ถ„๊ธฐ๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค.
    • ๊ฐ Controller ๊ตฌํ˜„์ฒด์—๋Š” doGet(), doPost() ๋งŒ์„ ๊ตฌํ˜„ํ•œ๋‹ค.

4๋‹จ๊ณ„ - ๋™์‹œ์„ฑ ํ™•์žฅํ•˜๊ธฐ

  • ์Šค๋ ˆ๋“œ ํ’€์„ ์‚ฌ์šฉํ•ด ์Šค๋ ˆ๋“œ๋ฅผ ์žฌ์‚ฌ์šฉํ•˜๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค.
    • acceptCount(์ตœ์†Œ 100), maxThreads(์ตœ์†Œ 200)๋ฅผ ์„ค์ •ํ•œ๋‹ค.
  • SessionManager์—์„œ session๋ฅผ ์Šค๋ ˆ๋“œ ์„ธ์ดํ”„ํ•˜๊ฒŒ ๊ตฌํ˜„ํ•œ๋‹ค.
    • ๋™์‹œ์„ฑ ์ปฌ๋ ‰์…˜(Concurrent Collections)๋ฅผ ์ ์šฉํ•œ๋‹ค.

์ถ”๊ฐ€๋กœ ๊ณ ๋ คํ•ด๋ณผ ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„

  • ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์„ธ๋ถ„ํ™” ํ•œ๋‹ค.
    • ์ง€์›ํ•˜์ง€ ์•Š๋Š” HTTP Method์ธ ๊ฒฝ์šฐ 405 ์ฝ”๋“œ์™€ index.html์„ ์‘๋‹ตํ•œ๋‹ค.
    • NOT FOUND๋Š” 404 ์ฝ”๋“œ์™€ 404.html์„ ์‘๋‹ตํ•œ๋‹ค.
  • ๋” ๋‹ค์–‘ํ•œ Content Type์„ ์ง€์›ํ•œ๋‹ค.
    • svg
  • RFC2616์„ ์ฐธ๊ณ ํ•ด ์ด๋ฆ„์„ ๋ฆฌํŒฉํ† ๋งํ•œ๋‹ค.
  • ๋น„์ง€๋‹ˆ์Šค ๋กœ์ง ์ƒ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ•œ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด 500.html๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธํ•œ๋‹ค.
    • ๋ฌดํ•œ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ด 500 ์ฝ”๋“œ๋ฅผ ์‘๋‹ตํ•˜๋„๋ก ๋ณ€๊ฒฝํ•œ๋‹ค.
  • DTO๋ฅผ ๋งŒ๋“ค์–ด ์š”์ฒญ ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ๊ฒ€์ฆ์„ ํ•œ๋‹ค.
  • BufferedReader์™€ ๊ฐ™์€ ์ž์›์„ ๋ช…์‹œ์ ์œผ๋กœ ํšŒ์ˆ˜ํ•œ๋‹ค.
  • Controller, Service๋ฅผ ์‹ฑ๊ธ€ํ†ค์œผ๋กœ ๋งŒ๋“ ๋‹ค.

์š”์ฒญ ์ฒ˜๋ฆฌ ๊ณผ์ •

IMG_6336

jwp-dashboard-http's People

Contributors

rianaeh avatar kang-hyungu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.