본문 바로가기

HTTP 웹 기본 지식

URI와 웹 브라우저 요청 흐름

URI(Uniform Resource Identifier)

- 리소스를 식별하는 통합된 방법

- Uniform : 리소스 식별하는 통일된 방식

- Resource : 자원, URI로 식별할 수 있는 모든 것(제한 없음)

- Identifier : 다른 항목과 구분하는데 필요한 정보

 

- URI는 locator, name 또는 둘다 추가로 분류될 수 있음

- URL(Resource Locator) : 리소스가 있는 위치를 지정

- URN(Resource Name) :  리소스에 이름을 부여

- 위치는 변할 수 있지만, 이름은 변하지 않음

- URN 이름만으로 실제 리소스를 찾을 수 있는 방법이 보편화 되지 않음

- URI를 URL과 같은 의미로 생각 가능

 

 

URL 전체 문법

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko  

 

- 프로토콜(https)

- 호스트명(www.google.com)

- 포트 번호(443)

- 패스(/search)

- 쿼리 파라미터(q=hello&hl=ko)

 

URL scheme

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko  

 

- 주로 프로토콜 사용

- 프로토콜 : 어떤 방식으로 자원에 접근할 것인가 하는 약속 규칙 

ex) http, https, ftp 등등

- http는 80포트, https는 443포트를 주로 사용, 포트는 생략 가능

- https는 http에 보안 추가(HTTP Secure)

 

 

URL userinfo

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko  

 

- URL에 사용자 정보를 포함해서 인증

- 거의 사용하지 않음

 

 

URL host

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko  

 

- 호스트명

- 도메인명 또는 IP주소를 직접 사용가능

 

 

URL PORT

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko    

- 포트(PORT)
- 접속 포트

- 일반적으로 생략, 생략시 http는 80, https는 443

 

 

URL path

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko 

 

- 리소스 경로(paht), 계층적 구조

ex)

/home/file1.jpg

/members

 

 

URL query

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://www.google.com:443/search?q=hello&hl=ko   


- key=value 형태

- ?로 시작, &로 추가 가능 

ex) ?keyA=valueA&keyB=valueB

- query parameter, query string 등으로 불림, 웹서버에 제공하는 파라미터, 문자 형태

 

 

URL fragment

scheme://[userinfo@]host[:port][/path][?query][#fragment]

https://docs.spring.io/spring-boot/docs/current/reference/html/gettingstarted.html#getting-started-introducing-spring-boot

 

- fragment

- html 내부 북마크 등에 사용

- 서버에 전송하는 정보 X

 

 

웹 브라우저 요청 흐름

https://www.google.com:443/search?q=hello&hl=ko  

 

1. 웹 브라우저가 DNS 조회, HTTPS PORT 생략

ex) DNS 조회 www.google.com:443  -> IP : 200.200.200.2

 

2. HTTP 요청 메시지 생성

ex)

GET /search?q=hello&hl=ko HTTP/1.1

Host: www.google.com  

 

3. HTTP 메시지 전송

    1) 웹 브라우저가 HTTP 메시지 생성

    2) SOCKET 라이브러리를 통해 전달

        A : TCP/IP 연결(IP, PORT)

        B : 데이터 전달

    3) TCP/IP 패킷 생성, HTTP 메시지 포함

    ex)

    출발지 IP, PORT

    목적지 IP, PORT

    GET /search?q=hello&hl=ko HTTP/1.1

    Host: www.google.com  

 

4. 웹 브라우저에서 요청 패킷 전달

5. 서버에서 요청 패킷 도착

    1) TCP/IP 패킷을 버리고, HTTP 메시지를 읽고 해석

    2) HTTP 응답 메시지 전달

    ex)

    HTTP/1.1 200 OK (정상 응답)

    Content-Type: text/html;charset=UTF-8 (응답하는 데이터가 html 형식, 언어는 UTF-8)

    Content-Length: 3423 (실제 html 파일 길이)

    <html>

        <body>....</body>

    </html>

 

6. 웹 브라우저에서 응답 패킷 확인

- 웹 브라우저 HTML 렌더링

 

 

출처 : https://www.inflearn.com/course/http-%EC%9B%B9-%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%81%AC

'HTTP 웹 기본 지식' 카테고리의 다른 글

HTTP 상태코드  (0) 2021.07.28
HTTP 메서드 활용  (0) 2021.07.27
HTTP 메서드  (0) 2021.07.26
HTTP 기본  (0) 2021.07.25
인터넷 네트워크  (0) 2021.07.25