이 글은 [모든 개발자를 위한 HTTP 웹 기본 지식]을 듣고 정리한 내용입니다
📌 URI
- URI (Uniform Resource Identifier)
- URI는 로케이터(locator), 이름(name) 또는 둘 다 추가로 분류될 수 있다.
![](https://media.vlpt.us/images/somyeong0623/post/e085df76-3965-4463-9e9c-8b926fe72a4d/image.png)
- URL: Resource Locator, 즉 리소스의 위치
- URN: Resource Name, 리소스의 이름
![](https://media.vlpt.us/images/somyeong0623/post/1a3e7899-ab90-4006-91d9-f6d9839b3e51/image.png)
URI 단어 뜻
- Uniform: 리소스 식별하는 통일된 방식
- Resource: 자원, URI로 식별할 수 있는 모든것 (제한 없음)
- Identifier: 다른 항목과 구분하는데 필요한 정보
- URL: Uniform Resource Locator
- URN: Uniform Resource Name
URL, URN
- URL: Locator, 리소스가 있는 위치를 지정
- URN: Name, 리소스에 이름 부여
- 위치는 변할 수 있지만, 이름은 변하지 않는다.
- URN 이름만으로 실제 리소스를 찾을 수 있는 방법이 보편화되지 않음.
- 보통 URI와 URL 같은 의미로 쓰인다.
🌱 URL 문법
Scheme
scheme
://[userinfo@]host[:port][/path][?query][#fragment]
ex) https
://www.google.com:443/search?q=hello&hl=ko
- 주로 프로토콜 사용
- 프로토콜: 어떤 방식으로 자원에 접근할 것인가 하는 약속 규칙
ex) http, https, ftp 등등
- http는 80번 포트, https는 443번 포트를 주로 사용.(포트는 생략 가능)
- https는 http에 보안 추가(HTTP Secure)
userinfo
- scheme://
[userinfo@]
host[:port][/path][?query][#fragment]
ex) https://www.google.com:443/search?q=hello&hl=ko
(이 예제에서는 사용하지 않음)
- URL에 사용자 정보를 포함해서 인증
- 거의 사용하지 않음
host
- scheme://[userinfo@]
host
[:port][/path][?query][#fragment]
ex) https://www.google.com
:443/search?q=hello&hl=ko
- 호스트명
- 도메인명 또는 IP 주소를 직접 사용가능
PORT
-
scheme://[userinfo@]host[:port]
[/path][?query][#fragment]
ex) https://www.google.com:443
/search?q=hello&hl=ko
-
접속 포트
-
일반저긍로 생략, 생략시 http는 80, https는 443
path
- scheme://[userinfo@]host[:port]
[/path]
[?query][#fragment]
ex) https://www.google.com:443/search
?q=hello&hl=ko
- 리소스 경로(path), 계층적 구조
ex)
/home/file1.png
/members/100
query
-
scheme://[userinfo@]host[:port][/path][?query]
[#fragment]
ex) https://www.google.com:443/search?q=hello&hl=ko
-
key=value 형태
-
?로 시작, &로 추가 가능
ex) ?keyA=value1&keyB=value2
-
query parameter, query string 등으로 불림. 웹서버에 제공하는 파라미터, 문자 형태
fragment
- scheme://[userinfo@]host[:port][/path][?query]
[#fragment]
ex) https://docs.spring.io/spring-boot/docs/current/reference/html/getting-
started.html#getting-started-introducing-spring-boot
- html 내부 북마크 등에 사용
- 서버에 전송하는 정보는 아니다.
📌 웹 브라우저 요청 흐름
![](https://media.vlpt.us/images/somyeong0623/post/a6447b93-62cb-40ff-a5ed-89833b59f934/image.png)
![](https://media.vlpt.us/images/somyeong0623/post/66b44894-2a0f-40dd-b64a-95cd4a9a0593/image.png)
🌱 패킷 전송 과정
![](https://media.vlpt.us/images/somyeong0623/post/1a49b51e-80c8-4dad-ab55-47ddc65867ea/image.png)
- 웹 브라우저에서 서버로 요청 패킷을 전달한다.
- 서버에 요청 패킷이 도착한다.
![](https://media.vlpt.us/images/somyeong0623/post/fb758f71-a9bf-4013-84ae-6a763619514d/image.png)
- 서버에서 응답 패킷을 웹 브라우저에게 전달한다.
- 웹 브라우저에 응답 패킷이 도착한다.
- 웹 브라우저에서 HTTP응답 메세지에 있는 내용을 토대로 HTML을 랜더링한다.