๋ชฉํ
์ด ํ์ค์ ๋ชฉํ๋ ์น ํ๋ซํผ ์ ๋ฐ์ ๊ฑธ์ณ ํจ์นญ์ ํตํฉํ๊ณ , ์ด์ ๊ด๋ จ๋ ๋ชจ๋ ๊ฒ์ ๋ํด ์ผ๊ด๋ ์ฒ๋ฆฌ๋ฅผ ์ ๊ณตํ๋ ๊ฒ์ ๋๋ค. ์ฌ๊ธฐ์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค:
- URL ์คํด
- ๋ฆฌ๋๋ ์
- ๊ต์ฐจ ์ถ์ฒ(Cross-origin) ์๋ฏธ
- CSP [CSP]
- ํจ์น ๋ฉํ๋ฐ์ดํฐ [FETCH-METADATA]
- ์๋น์ค ์์ปค [SW]
- ํผํฉ ์ฝํ ์ธ [MIX]
- ๋น๋ณด์ ์์ฒญ ์ ๊ทธ๋ ์ด๋ [UPGRADE-INSECURE-REQUESTS]
- `
Referer` [REFERRER]
์ด๋ฅผ ์ํด HTTP `Origin` ํค๋ ์๋ฏธ๋ฅผ
์๋ The Web Origin Concept์์ ์ ์ํ๋ ๊ฒ๋ณด๋ค ๋์ฒดํฉ๋๋ค. [ORIGIN]
1. ์๋ฌธ
์์ ๊ด์ ์์ ๋ฆฌ์์ค๋ฅผ ํจ์นญํ๋ ๊ฒ์ ๊ฝค ๋จ์ํ ์์ ์ ๋๋ค. ์์ฒญ์ด ๋ค์ด๊ฐ๊ณ , ์๋ต์ด ๋์ต๋๋ค. ํ์ง๋ง ๊ทธ ์์ ์ ์ธ๋ถ์ฌํญ์ ๋งค์ฐ ๋ณต์กํ๋ฉฐ, ์์ ์๋ ๋ช ํํ๊ฒ ๋ฌธ์ํ๋์ง ์์๊ณ API๋ง๋ค ๋ค๋ฅด๊ฒ ๋์ํ์ต๋๋ค.
์๋ง์ API๊ฐ ๋ฆฌ์์ค๋ฅผ ํจ์นํ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. ์๋ฅผ ๋ค๋ฉด HTML์ img์
script ์์, CSS์ cursor์ list-style-image,
navigator.sendBeacon() ๋ฐ self.importScripts() ๊ฐ์ JavaScript
API๋ค์ด ์์ต๋๋ค. ํจ์น ํ์ค์ ์ด๋ฌํ ๊ธฐ๋ฅ๋ค์ ์ํ ํตํฉ๋ ์ํคํ
์ฒ๋ฅผ ์ ๊ณตํ์ฌ, ๋ฆฌ๋๋ ์
๋ฐ
CORS ํ๋กํ ์ฝ ๋ฑ ํจ์นญ์ ๋ค์ํ ์ธก๋ฉด์์ ๋ชจ๋ ์ผ๊ด์ฑ์ ๊ฐ๋๋ก ํฉ๋๋ค.
ํจ์น ํ์ค์ ๋ํ fetch() JavaScript API๋ฅผ ์ ์ํ๋ฉฐ,
์ด๋ ๋๋ถ๋ถ์ ๋คํธ์ํน ๊ธฐ๋ฅ์ ๋น๊ต์ ๋ฎ์ ์ถ์ํ ์์ค์์ ๋
ธ์ถํฉ๋๋ค.
2. ์ธํ๋ผ์คํธ๋ญ์ฒ
์ด ๋ช ์ธ๋ Infra ํ์ค์ ์์กดํฉ๋๋ค. [INFRA]
์ด ๋ช ์ธ๋ ABNF, Encoding, HTML, HTTP, MIME Sniffing, Streams, URL, Web IDL, WebSockets, ๊ทธ๋ฆฌ๊ณ WebTransport์์ ์ฉ์ด๋ฅผ ์ฌ์ฉํฉ๋๋ค. [ABNF] [ENCODING] [HTML] [HTTP] [MIMESNIFF] [STREAMS] [URL] [WEBIDL] [WEBSOCKETS] [WEBTRANSPORT]
ABNF๋ HTTP์์ ํ์ฅ๋ ABNF(ํนํ
#์ ์ถ๊ฐ)์ RFC 7405๋ฅผ ์๋ฏธํฉ๋๋ค. [RFC7405]
์ธ์ฆ ์ ๋ณด(Credentials)๋ HTTP ์ฟ ํค, TLS ํด๋ผ์ด์ธํธ ์ธ์ฆ์, ๊ทธ๋ฆฌ๊ณ ์ธ์ฆ ํญ๋ชฉ(HTTP ์ธ์ฆ์ฉ)์ ๋๋ค. [COOKIES] [TLS] [HTTP]
fetch params๋ struct๋ก, fetch ์๊ณ ๋ฆฌ์ฆ์์ ๋ถ๊ธฐ ์ฉ๋๋ก ์ฌ์ฉ๋ฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ ํญ๋ชฉ์ ๊ฐ์ง๋๋ค:
- request
- request.
- ์์ฒญ ๋ณธ๋ฌธ ์ฒญํฌ ๊ธธ์ด ์ฒ๋ฆฌ
(๊ธฐ๋ณธ๊ฐ null)
- process request end-of-body (๊ธฐ๋ณธ๊ฐ null)
- process early hints response (๊ธฐ๋ณธ๊ฐ null)
- process response (๊ธฐ๋ณธ๊ฐ null)
- process response end-of-body (๊ธฐ๋ณธ๊ฐ null)
- process response consume body (๊ธฐ๋ณธ๊ฐ null)
- process request end-of-body (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ ์๊ณ ๋ฆฌ์ฆ.
- task destination (๊ธฐ๋ณธ๊ฐ null)
- Null, global object, ๋๋ parallel queue.
- cross-origin isolated capability (๊ธฐ๋ณธ๊ฐ false)
- ๋ถ๋ฆฌ์ธ ๊ฐ.
- controller (๊ธฐ๋ณธ๊ฐ ์ fetch controller)
- fetch controller.
- timing info
- fetch timing info.
- preloaded response candidate (๊ธฐ๋ณธ๊ฐ null)
- Null, "
pending", ๋๋ response.
fetch controller๋ struct๋ก, fetch ํธ์ถ์๊ฐ ์์ ํ ํน์ ์์ ์ ์ํํ ์ ์๋๋ก ํฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ ํญ๋ชฉ์ ๊ฐ์ง๋๋ค:
- state (๊ธฐ๋ณธ๊ฐ "
ongoing") - "
ongoing", "terminated", ๋๋ "aborted" - full timing info (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ fetch timing info.
- report timing steps (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ global object๋ฅผ ์ธ์๋ก ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ.
- serialized abort reason (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ Record (StructuredSerialize ๊ฒฐ๊ณผ).
- next manual redirect steps (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ ์ธ์๋ฅผ ๋ฐ์ง ์๋ ์๊ณ ๋ฆฌ์ฆ.
ํน์ fetch controller controller์ ๋ํด ํ์ด๋ฐ ๋ณด๊ณ (report timing)๋ฅผ ํ๋ ค๋ฉด, global object global์ ๋ฐ์ ๋ค์์ ์คํํฉ๋๋ค:
-
Assert: controller์ report timing steps๊ฐ null์ด ์๋์ ํ์ธํฉ๋๋ค.
-
controller์ report timing steps๋ฅผ global๊ณผ ํจ๊ป ํธ์ถํฉ๋๋ค.
ํน์ fetch controller controller์ ๋ํด ๋ค์ ์๋ ๋ฆฌ๋๋ ํธ ์ฒ๋ฆฌ๋ฅผ ํ๋ ค๋ฉด:
-
Assert: controller์ next manual redirect steps๊ฐ null์ด ์๋์ ํ์ธํฉ๋๋ค.
-
controller์ next manual redirect steps๋ฅผ ํธ์ถํฉ๋๋ค.
fetch controller controller์ ๋ํด ์ ์ฒด ํ์ด๋ฐ ์ ๋ณด ์ถ์ถ์ ํ๋ ค๋ฉด:
-
Assert: controller์ full timing info๊ฐ null์ด ์๋์ ํ์ธํฉ๋๋ค.
-
controller์ full timing info๋ฅผ ๋ฐํํฉ๋๋ค.
ํน์ fetch controller controller์ ๋ํด ์ ํ์ error์ ํจ๊ป abort ํ๋ ค๋ฉด:
-
controller์ state๋ฅผ "
aborted"๋ก ์ค์ ํฉ๋๋ค. -
fallbackError๋ฅผ "
AbortError"DOMException์ผ๋ก ๋ก๋๋ค. -
error๊ฐ ์ฃผ์ด์ง์ง ์์๋ค๋ฉด fallbackError๋ก ์ค์ ํฉ๋๋ค.
-
serializedError๋ฅผ StructuredSerialize(error)๋ก ๋ก๋๋ค. ์์ธ๊ฐ ๋ฐ์ํ๋ฉด serializedError๋ฅผ StructuredSerialize(fallbackError)๋ก ๋ก๋๋ค.
-
controller์ serialized abort reason์ serializedError๋ก ์ค์ ํฉ๋๋ค.
null ๋๋ Record abortReason ๋ฐ realm realm์ด ์ฃผ์ด์ก์ ๋ serialize๋ abort reason ์ญ์ง๋ ฌํ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
fallbackError๋ฅผ "
AbortError"DOMException์ผ๋ก ๋ก๋๋ค. -
deserializedError๋ฅผ fallbackError๋ก ๋ก๋๋ค.
-
abortReason์ด null์ด ์๋๋ฉด, deserializedError๋ฅผ StructuredDeserialize(abortReason, realm)๋ก ๋ก๋๋ค. ์์ธ๊ฐ ๋ฐ์ํ๊ฑฐ๋ undefined๋ฅผ ๋ฐํํ๋ฉด deserializedError๋ฅผ fallbackError๋ก ๋ก๋๋ค.
-
deserializedError๋ฅผ ๋ฐํํฉ๋๋ค.
fetch controller
controller๋ฅผ ์ข
๋ฃ(terminate)ํ๋ ค๋ฉด, controller์ state๋ฅผ
"terminated"๋ก ์ค์ ํฉ๋๋ค.
fetch params
fetchParams๋, ๊ทธ controller์ state๊ฐ
"aborted"์ผ ๋ ์ค๋จ(aborted) ์ํ์
๋๋ค.
fetch params
fetchParams๋, ๊ทธ controller์ state๊ฐ
"aborted" ๋๋ "terminated"์ผ ๋ ์ทจ์(canceled) ์ํ์
๋๋ค.
fetch timing info๋ struct๋ก, Resource Timing๊ณผ Navigation Timing์ ํ์ํ ํ์ด๋ฐ ์ ๋ณด๋ฅผ ์ ์งํฉ๋๋ค. ๋ค์์ ํญ๋ชฉ์ ๊ฐ์ง๋๋ค: [RESOURCE-TIMING] [NAVIGATION-TIMING]
- start time (๊ธฐ๋ณธ๊ฐ 0)
- redirect start time (๊ธฐ๋ณธ๊ฐ 0)
- redirect end time (๊ธฐ๋ณธ๊ฐ 0)
- post-redirect start time (๊ธฐ๋ณธ๊ฐ 0)
- final service worker start time (๊ธฐ๋ณธ๊ฐ 0)
- final network-request start time (๊ธฐ๋ณธ๊ฐ 0)
- first interim network-response start time (๊ธฐ๋ณธ๊ฐ 0)
- final network-response start time (๊ธฐ๋ณธ๊ฐ 0)
- end time (๊ธฐ๋ณธ๊ฐ 0)
- redirect start time (๊ธฐ๋ณธ๊ฐ 0)
DOMHighResTimeStamp.- final connection timing info (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ connection timing info.
- ์๋น์ค ์์ปค ํ์ด๋ฐ ์ ๋ณด (๊ธฐ๋ณธ๊ฐ null)
- Null ๋๋ ์๋น์ค ์์ปค ํ์ด๋ฐ ์ ๋ณด.
- server-timing headers (๊ธฐ๋ณธ๊ฐ ยซ ยป)
- ๋ฌธ์์ด์ list.
- render-blocking (๊ธฐ๋ณธ๊ฐ false)
- ๋ถ๋ฆฌ์ธ ๊ฐ.
response body info ๋ struct๋ก, Resource Timing๊ณผ Navigation Timing์ ํ์ํ ์ ๋ณด๋ฅผ ์ ์งํฉ๋๋ค. ๋ค์์ ํญ๋ชฉ์ ๊ฐ์ง๋๋ค: [RESOURCE-TIMING] [NAVIGATION-TIMING]
- encoded size
(๊ธฐ๋ณธ๊ฐ 0)
- decoded size (๊ธฐ๋ณธ๊ฐ 0)
- ์ซ์.
- content type (๊ธฐ๋ณธ๊ฐ ๋น ๋ฌธ์์ด)
- ASCII ๋ฌธ์์ด.
- content encoding (๊ธฐ๋ณธ๊ฐ ๋น ๋ฌธ์์ด)
- ASCII ๋ฌธ์์ด.
๋ถํฌ๋ช ํ์ด๋ฐ ์ ๋ณด๋ฅผ ์์ฑํ๋ ค๋ฉด, ํ์น ํ์ด๋ฐ ์ ๋ณด timingInfo๊ฐ ์ฃผ์ด์ก์ ๋, ์๋ก์ด ํ์น ํ์ด๋ฐ ์ ๋ณด๋ฅผ ๋ฐํํ๋ค. ํด๋น ์ ๋ณด์ ์์ ์๊ฐ๊ณผ ๋ฆฌ๋๋ ์ ํ ์์ ์๊ฐ์ timingInfo์ ์์ ์๊ฐ์ด๊ณ , ์ข ๋ฃ ์๊ฐ์ timingInfo์ ์ข ๋ฃ ์๊ฐ์ด๋ฉฐ, ๋ ๋๋ง ์ฐจ๋จ์ timingInfo์ ๋ ๋๋ง ์ฐจ๋จ์ด๋ค.
์๊ณ ๋ฆฌ์ฆ algorithm, global object ๋๋ parallel queue taskDestination์ด ์ฃผ์ด์ก์ ๋ fetch ํ์คํฌ ํ์(queue a fetch task)์ ๋ค์๊ณผ ๊ฐ์ด ์คํํฉ๋๋ค:
-
taskDestination์ด parallel queue๋ผ๋ฉด, enqueue algorithm์ taskDestination์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, ๊ธ๋ก๋ฒ ํ์คํฌ(global task)๋ฅผ networking task source์ taskDestination๊ณผ algorithm์ผ๋ก ํ์ํฉ๋๋ค.
ํ๊ฒฝ ์ค์ ๊ฐ์ฒด environment ์คํ๋ผ์ธ ์ฌ๋ถ ํ์ธ:
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ธํฐ๋ท ์ฐ๊ฒฐ์ด ์๋ค๊ณ ๊ฐ์ ํ๋ฉด, true๋ฅผ ๋ฐํํ๋ค.
-
environment์ WebDriver BiDi ๋คํธ์ํฌ ์คํ๋ผ์ธ ์ฌ๋ถ๋ฅผ ๋ฐํํ๋ค.
์ ์ ์ง๋ ฌํ(serialize an integer)๋, ์ ์๋ฅผ ๊ฐ๋ฅํ ๊ฐ์ฅ ์งง์ ์ญ์ง์ ๋ฌธ์์ด๋ก ํํํ๋ ๊ฒ์ ๋๋ค.
์ด ๋ถ๋ถ์ Infra์์ ๋ ์์ธํ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ๊ต์ฒด๋ ์์ ์ ๋๋ค. infra/201 ์ฐธ๊ณ .
2.1. URL
๋ก์ปฌ ์คํด(local scheme)์
"about", "blob", ๋๋
"data"์
๋๋ค.
URL์ด ๋ก์ปฌ์(is local)์ ํด๋น ์คํด์ด ๋ก์ปฌ ์คํด์ผ ๋์ ๋๋ค.
์ด ์ ์๋ Referrer Policy์์๋ ์ฌ์ฉ๋ฉ๋๋ค. [REFERRER]
HTTP(S) ์คํด์
"http" ๋๋
"https"์
๋๋ค.
ํจ์น ์คํด(fetch scheme)์
"about", "blob",
"data", "file", ๋๋ HTTP(S) ์คํด์
๋๋ค.
HTTP(S) ์คํด๊ณผ ํจ์น ์คํด ์ญ์ HTML์์ ์ฌ์ฉ๋ฉ๋๋ค. [HTML]
2.2. HTTP
ํจ์นญ์ HTTP์๋ง ๊ตญํ๋์ง ์์ง๋ง,
HTTP์์ ์ฌ๋ฌ ๊ฐ๋
์ ์ฐจ์ฉํ์ฌ ๋ค๋ฅธ
๋ฐฉ์(์: data URL)์ผ๋ก ํ๋ํ ๋ฆฌ์์ค์๋ ์ ์ฉํฉ๋๋ค.
HTTP ํญ ๋๋ ๊ณต๋ฐฑ(HTTP tab or space)์ U+0009 TAB ๋๋ U+0020 SPACE์ ๋๋ค.
HTTP ๊ณต๋ฐฑ(HTTP whitespace)์ U+000A LF, U+000D CR, ๋๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ์ ๋๋ค.
HTTP ๊ณต๋ฐฑ์ HTTP ํค๋ ๋งฅ๋ฝ ์ด์ธ์์ ์ฌ์ฌ์ฉ๋๋ ํน์ ๊ตฌ์กฐ์๋ง ์ ์ฉํฉ๋๋ค(์: MIME ํ์ ). HTTP ํค๋ ๊ฐ์๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ์ฌ์ฉ์ ๊ถ์ฅํ๋ฉฐ, ๊ทธ ์ธ ๋งฅ๋ฝ์์๋ ASCII ๊ณต๋ฐฑ์ ๊ถ์ฅํฉ๋๋ค. ASCII ๊ณต๋ฐฑ๊ณผ ๋ฌ๋ฆฌ U+000C FF๋ ์ ์ธ๋ฉ๋๋ค.
HTTP ์ค๋ฐ๊ฟ ๋ฐ์ดํธ(HTTP newline byte)๋ 0x0A (LF) ๋๋ 0x0D (CR)์ ๋๋ค.
HTTP ํญ ๋๋ ๊ณต๋ฐฑ ๋ฐ์ดํธ(HTTP tab or space byte)๋ 0x09 (HT) ๋๋ 0x20 (SP)์ ๋๋ค.
HTTP ๊ณต๋ฐฑ ๋ฐ์ดํธ(HTTP whitespace byte)๋ HTTP ์ค๋ฐ๊ฟ ๋ฐ์ดํธ ๋๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ๋ฐ์ดํธ์ ๋๋ค.
HTTP ๋ฐ์ดํ ๋ฌธ์์ด ์์ง(collect an HTTP quoted string) ์ ํ๋ ค๋ฉด ๋ฌธ์์ด(string) input, ์์น ๋ณ์(position variable) position, ์ ํ์ ๋ถ๋ฆฌ์ธ extract-value (๊ธฐ๋ณธ๊ฐ false)๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์์ ์ํํฉ๋๋ค:
-
positionStart๋ฅผ position์ผ๋ก ๋ก๋๋ค.
-
value๋ฅผ ๋น ๋ฌธ์์ด๋ก ๋ก๋๋ค.
-
Assert: input์ position์ ์๋ ์ฝ๋ ํฌ์ธํธ๊ฐ U+0022 (")์์ ํ์ธํฉ๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
๋ค์์ด ์ฐธ์ธ ๋์:
-
U+0022 (") ๋๋ U+005C (\)๊ฐ ์๋ ์ฝ๋ ํฌ์ธํธ ์ํ์ค ์์ง ๊ฒฐ๊ณผ๋ฅผ input, position์ผ๋ก๋ถํฐ value์ ์ถ๊ฐํฉ๋๋ค.
-
position์ด input์ ๋์ ์ง๋ ๊ฒฝ์ฐ, breakํฉ๋๋ค.
-
quoteOrBackslash๋ฅผ input์ position์ ์๋ ์ฝ๋ ํฌ์ธํธ๋ก ๋ก๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
quoteOrBackslash๊ฐ U+005C (\)์ด๋ฉด:
-
position์ด input์ ๋์ ์ง๋ ๊ฒฝ์ฐ U+005C (\)๋ฅผ value์ ์ถ๊ฐํ๊ณ breakํฉ๋๋ค.
-
input์ position์ ์๋ ์ฝ๋ ํฌ์ธํธ๋ฅผ value์ ์ถ๊ฐํฉ๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
-
extract-value๊ฐ true๋ผ๋ฉด value๋ฅผ ๋ฐํํฉ๋๋ค.
-
input์ positionStart๋ถํฐ position๊น์ง(ํฌํจ)์ ์ฝ๋ ํฌ์ธํธ๋ค์ ๋ฐํํฉ๋๋ค.
| ์ ๋ ฅ | ์ถ๋ ฅ | extract-value๊ฐ true์ผ ๋์ ์ถ๋ ฅ | ์ต์ข ์์น ๋ณ์ ๊ฐ |
|---|---|---|---|
""\"
| ""\"
| "\"
| 2 |
""Hello" World"
| ""Hello""
| "Hello"
| 7 |
""Hello \\ World\"""
| ""Hello \\ World\"""
| "Hello \ World""
| 18 |
์ด ์์์์ ์์น ๋ณ์๋ ํญ์ 0์์ ์์ํฉ๋๋ค.
2.2.1. ๋ฉ์๋
๋ฉ์๋(method)๋ ๋ฐ์ดํธ ์ํ์ค๋ก, method ํ ํฐ ์์ฑ์์ ๋ง์กฑํ๋ ๊ฒ์ ๋๋ค.
CORS-์์ ๋ชฉ๋ก ๋ฉ์๋(CORS-safelisted method)๋
๋ฉ์๋ ์ค
`GET`,
`HEAD`, ๋๋ `POST`์ธ ๊ฒ์
๋๋ค.
๊ธ์ง๋ ๋ฉ์๋(forbidden
method)๋
๋ฉ์๋ ์ค
๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด `CONNECT`, `TRACE`, ๋๋
`TRACK`์ ์ผ์นํ๋ ๊ฒ์
๋๋ค.
[HTTPVERBSEC1], [HTTPVERBSEC2],
[HTTPVERBSEC3]
๋ฉ์๋ ์ ๊ทํ(normalize)๋ฅผ ํ๋ ค๋ฉด,
๋ฉ์๋๊ฐ ๋ฐ์ดํธ ๋์๋ฌธ์
๊ตฌ๋ถ ์์ด
`DELETE`, `GET`,
`HEAD`, `OPTIONS`, `POST`, ๋๋
`PUT`์ ์ผ์นํ๋ค๋ฉด, ๋๋ฌธ์ ๋ฐ์ดํธ(byte-uppercase)๋ก ๋ณํํฉ๋๋ค.
์ ๊ทํ๋ ๊ณผ๊ฑฐ์์ ํธํ์ฑ ๋ฐ API ๊ฐ์ ์ผ๊ด์ฑ์ ์ํด ์ํ๋๋ฉฐ, ๋ฉ์๋๋ ์ค์ ๋ก "๋์๋ฌธ์ ๊ตฌ๋ถ"์ ๋๋ค.
`patch`๋ฅผ ์ฌ์ฉํ๋ฉด `405 Method Not Allowed`๊ฐ ๋ฐ์ํ ๊ฐ๋ฅ์ฑ์ด ๋์ต๋๋ค. ๋ฐ๋ฉด `PATCH`๋ ์ฑ๊ณต
๊ฐ๋ฅ์ฑ์ด ํจ์ฌ ๋ ๋์ต๋๋ค.
๋ฉ์๋์๋ ์ ํ์ด ์์ต๋๋ค. `CHICKEN`๋ ์๋ฒฝํ๊ฒ ํ์ฉ๋ฉ๋๋ค(๊ทธ๋ฆฌ๊ณ
`CHECKIN`์ ์คํ๊ฐ ์๋๋๋ค). ์ ๊ทํ๋๋ ๊ฒ ์ธ์๋ ๋์๋ฌธ์ ์ ํ๋ ์์ต๋๋ค.
`Egg`๋ `eGg`๋ ๊ด์ฐฎ์ง๋ง, ์ผ๊ด์ฑ์ ์ํด ๋๋ฌธ์๋ฅผ ๊ถ์ฅํฉ๋๋ค.
2.2.2. ํค๋
HTTP๋ ์ผ๋ฐ์ ์ผ๋ก ํค๋๋ฅผ "ํ๋(field)" ๋๋ "ํค๋ ํ๋(header field)"๋ผ๊ณ ๋ถ๋ฆ ๋๋ค. ์น ํ๋ซํผ์์๋ ๋ ๊ตฌ์ด์ฒด์ธ "ํค๋(header)"๋ผ๋ ์ฉ์ด๋ฅผ ์ฌ์ฉํฉ๋๋ค. [HTTP]
ํค๋ ๋ชฉ๋ก(header list)์ ๋ฆฌ์คํธ(list)์ด๋ฉฐ, 0๊ฐ ์ด์์ ํค๋(header)๋ฅผ ํฌํจํฉ๋๋ค. ์ฒ์์๋ ยซ ยป์ ๋๋ค.
ํค๋ ๋ชฉ๋ก์ ๋ณธ์ง์ ์ผ๋ก ํน์ํ ๋ฉํฐ๋งต: ํค-๊ฐ ์์ ์์ ์๋ ๋ฆฌ์คํธ๋ก, ํค๊ฐ ์ค๋ณต๋ ์ ์์ต๋๋ค.
`Set-Cookie`๋ฅผ ์ ์ธํ ํค๋๋ ํด๋ผ์ด์ธํธ ์ธก JavaScript์ ๋
ธ์ถ๋ ๋ ํญ์ ํฉ์ณ์ง๋ฏ๋ก, ๊ตฌํ์ฒด๋ `Set-Cookie` ํค๋์ฉ ๋ณ๋
๋ฐ์ดํฐ ๊ตฌ์กฐ๋ง ์ง์ํ๋ฉด ๋ ํจ์จ์ ์ธ ํํ์ ์ ํํ ์ ์์ต๋๋ค.
๊ตฌ์กฐํ ํ๋ ๊ฐ ๊ฐ์ ธ์ค๊ธฐ(get a structured field value) ๋ฅผ ํ๋ ค๋ฉด ํค๋ ์ด๋ฆ name๊ณผ ๋ฌธ์์ด type์ด ํค๋ ๋ชฉ๋ก list์์ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค. ๊ฒฐ๊ณผ๋ null ๋๋ ๊ตฌ์กฐํ ํ๋ ๊ฐ(structured field value)์ ๋๋ค.
-
Assert: type์ "
dictionary", "list", ๋๋ "item" ์ค ํ๋์ ๋๋ค. -
value๋ฅผ ํค๋ ๋ชฉ๋ก์์ name์ ๊ฐ์ ธ์จ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
value๊ฐ null์ด๋ฉด null์ ๋ฐํํฉ๋๋ค.
-
result๋ฅผ ๊ตฌ์กฐํ ํ๋ ํ์ฑ(parsing structured fields)์ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. input_string์ value, header_type์ type์ ๋๋ค.
-
ํ์ฑ์ ์คํจํ๋ค๋ฉด null์ ๋ฐํํฉ๋๋ค.
-
result๋ฅผ ๋ฐํํฉ๋๋ค.
๊ตฌ์กฐํ ํ๋ ๊ฐ ๊ฐ์ ธ์ค๊ธฐ๋ ํด๋น ํค๋๊ฐ ์กด์ฌํ์ง ์๋ ๊ฒ๊ณผ ๊ฐ์ด ๊ตฌ์กฐํ ํ๋ ๊ฐ์ผ๋ก ํ์ฑ์ ์คํจํ ๊ฒ์ ์๋์ ์ผ๋ก ๊ตฌ๋ถํ์ง ์์ต๋๋ค. ์ด๋ ์น ํ๋ซํผ ์ ๋ฐ์์ ์ผ๊ด๋ ์ฒ๋ฆฌ๋ฅผ ๋ณด์ฅํฉ๋๋ค.
๊ตฌ์กฐํ ํ๋ ๊ฐ ์ค์ (set a structured field value) ์ ํ๋ ค๋ฉด ํํ(tuple) (ํค๋ ์ด๋ฆ name, ๊ตฌ์กฐํ ํ๋ ๊ฐ structuredValue)๊ณผ ํค๋ ๋ชฉ๋ก list๊ฐ ์ฃผ์ด์ง๋๋ค:
-
serializedValue๋ฅผ ๊ตฌ์กฐํ ํ๋ ์ง๋ ฌํ(serializing structured fields) ์๊ณ ๋ฆฌ์ฆ์ structuredValue์ ์ ์ฉํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
Set (name, serializedValue) ๋ฅผ list์ ์ ์ฉํฉ๋๋ค.
๊ตฌ์กฐํ ํ๋ ๊ฐ์ HTTP๊ฐ(๊ฒฐ๊ตญ) ํฅ๋ฏธ๋กญ๊ณ ํจ์จ์ ์ผ๋ก ์ง๋ ฌํํ ์ ์๋ ๊ฐ์ฒด๋ก ์ ์๋์ด ์์ต๋๋ค. ํ์ฌ Fetch๋ ํค๋ ๊ฐ๋ง ๋ฐ์ดํธ ์ํ์ค๋ก ์ง์ํ๋ฏ๋ก, ์ด ๊ฐ์ฒด๋ค์ ์ง๋ ฌํ๋ฅผ ํตํด์๋ง ํค๋ ๋ชฉ๋ก์ ์ค์ ํ ์ ์๊ณ , ํ์ฑ์ ํตํด์๋ง ํค๋ ๋ชฉ๋ก์์ ์ป์ ์ ์์ต๋๋ค. ์์ผ๋ก๋ ๊ฐ์ฒด ์ํ๊ฐ ๋๊น์ง ์ ์ง๋ ์๋ ์์ต๋๋ค. [RFC9651]
ํค๋ ๋ชฉ๋ก list๊ฐ ํค๋๋ฅผ ํฌํจ(contains)ํ๋์ง ์ฌ๋ถ๋ ํค๋ ์ด๋ฆ name์ด list์ ํฌํจ๋ ํค๋ ์ค name์ด ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด name๊ณผ ์ผ์นํ๋ ๊ฒ์ด ์๋์ง๋ก ํ๋จํฉ๋๋ค.
๊ฐ์ ธ์ค๊ธฐ(get)๋ ํค๋ ์ด๋ฆ name๊ณผ ํค๋ ๋ชฉ๋ก list๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค. ๊ฒฐ๊ณผ๋ null ๋๋ ํค๋ ๊ฐ์ ๋๋ค.
-
list๊ฐ name์ ํฌํจํ์ง ์์ผ๋ฉด null์ ๋ฐํํฉ๋๋ค.
-
list์์ ํค๋ ์ค name์ด ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด name๊ณผ ์ผ์นํ๋ ๋ชจ๋ ๊ฐ์ 0x2C 0x20(์ผํ+๊ณต๋ฐฑ)์ผ๋ก ๊ตฌ๋ถํ์ฌ ์์๋๋ก ๋ฐํํฉ๋๋ค.
๊ฐ์ ธ์ค๊ธฐ, ๋์ฝ๋ ๋ฐ ๋ถํ (get, decode, and split) ์ ํค๋ ์ด๋ฆ name๊ณผ ํค๋ ๋ชฉ๋ก list๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค. ๊ฒฐ๊ณผ๋ null ๋๋ ๋ฆฌ์คํธ ( ๋ฌธ์์ด(string) )์ ๋๋ค.
-
value๋ฅผ name์ ๊ฐ์ ธ์จ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
value๊ฐ null์ด๋ฉด null์ ๋ฐํํฉ๋๋ค.
-
get, decode, and split์ value์ ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
๋ค์์ get, decode, and split์ด ์ค์ ๋ก ์ด๋ป๊ฒ ๋์ํ๋์ง,
name ์ธ์๊ฐ `A`์ผ ๋์ ์์์
๋๋ค:
| ํค๋(๋คํธ์ํฌ ์) | ์ถ๋ ฅ |
|---|---|
| ยซ "nosniff", "" ยป
|
| |
| ยซ "" ยป |
| null |
| ยซ "text/html;", x/x" ยป
|
| |
| ยซ "x/x;test="hi"", "y/y" ยป
|
| |
| ยซ "x / x", "", "", "1" ยป
|
| |
| ยซ ""1,2"", "3" ยป
|
|
get, decode, and split ์ ํค๋ ๊ฐ(header value) value์ ๋ํด ์คํํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ฆ ๋๋ค. ๋ฐํ ๊ฐ์ ๋ฌธ์์ด๋ฆฌ์คํธ์ ๋๋ค.
-
input์ isomorphic decoding value ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
position์ ์์น ๋ณ์(position variable)๋ก, input์ ์์ ์์น๋ก ์ง์ ํฉ๋๋ค.
-
values๋ฅผ ๋ฌธ์์ด๋ฆฌ์คํธ๋ก, ์ฒ์์๋ ยซ ยป๋ก ๋ก๋๋ค.
-
temporaryValue๋ฅผ ๋น ๋ฌธ์์ด๋ก ๋ก๋๋ค.
-
๋ค์์ด ์ฐธ์ธ ๋์ ๋ฐ๋ณตํฉ๋๋ค:
-
U+0022 (") ๋๋ U+002C (,)๊ฐ ์๋ ์ฝ๋ ํฌ์ธํธ ์ํ์ค ์์ง ๊ฒฐ๊ณผ๋ฅผ input, position์ผ๋ก๋ถํฐ temporaryValue์ ์ถ๊ฐํฉ๋๋ค.
์ด ๊ฒฐ๊ณผ๋ ๋น ๋ฌธ์์ด์ผ ์๋ ์์ต๋๋ค.
-
position์ด input์ ๋์ ์ง๋์ง ์์๊ณ , position ์์น์ ์ฝ๋ ํฌ์ธํธ๊ฐ U+0022 (")์ด๋ฉด:
-
temporaryValue์ HTTP ๋ฐ์ดํ ๋ฌธ์์ด ์์ง ๊ฒฐ๊ณผ๋ฅผ input, position์ผ๋ก๋ถํฐ ์ถ๊ฐํฉ๋๋ค.
- position์ด ๋์ ์ง๋์ง ์์๋ค๋ฉด continueํฉ๋๋ค.
-
-
temporaryValue์ ์์๊ณผ ๋์์ HTTP ํญ ๋๋ ๊ณต๋ฐฑ์ ๋ชจ๋ ์ ๊ฑฐํฉ๋๋ค.
-
Append temporaryValue๋ฅผ values์ ์ถ๊ฐํฉ๋๋ค.
-
temporaryValue๋ฅผ ๋น ๋ฌธ์์ด๋ก ์ค์ ํฉ๋๋ค.
-
position์ด input์ ๋์ ์ง๋ฌ๋ค๋ฉด values๋ฅผ ๋ฐํํฉ๋๋ค.
-
Assert: input์ position ์์น์ ์ฝ๋ ํฌ์ธํธ๊ฐ U+002C (,)์์ ํ์ธํฉ๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
ํน์ ํ์ฉ๋ ํธ์ถ์ง(blessed call sites)๋ฅผ ์ ์ธํ๊ณ , ์ ์๊ณ ๋ฆฌ์ฆ์ ์ง์ ํธ์ถํ์ง ์์์ผ ํฉ๋๋ค. ๋์ get, decode, and split์ ์ฌ์ฉํ์ธ์.
append๋ ํค๋(header) (name, value)๋ฅผ ํค๋ ๋ชฉ๋ก(header list) list์ ์ถ๊ฐํ๋ ์๊ณ ๋ฆฌ์ฆ์ ๋๋ค:
-
list๊ฐ name์ ํฌํจํ๋ฉด, name์ ์ฒซ ๋ฒ์งธ ํด๋น ํค๋์ name์ผ๋ก ์ค์ ํฉ๋๋ค.
์ด๋ ๊ฒ ํ๋ฉด list์ ์ด๋ฏธ ์กด์ฌํ๋ ํค๋์ name์ ๋์๋ฌธ์๊ฐ ์ฌ์ฌ์ฉ๋ฉ๋๋ค. ์ฌ๋ฌ ๊ฐ๊ฐ ์ผ์นํ๋ฉด ํค๋์ name์ ๋ชจ๋ ๋์ผํฉ๋๋ค.
-
Append (name, value)๋ฅผ list์ ์ถ๊ฐํฉ๋๋ค.
delete๋ ํค๋ ์ด๋ฆ(header name) name์ ํค๋ ๋ชฉ๋ก(header list) list์์ ์ ๊ฑฐํ๋ ์๊ณ ๋ฆฌ์ฆ์ ๋๋ค. ์ด๋ ํค๋์ name์ด ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด name๊ณผ ์ผ์นํ๋ ๋ชจ๋ ํค๋๋ฅผ list์์ ์ ๊ฑฐํฉ๋๋ค.
set์ ํค๋(header) (name, value)๋ฅผ ํค๋ ๋ชฉ๋ก(header list) list์ ์ค์ ํ๋ ๋ฐฉ๋ฒ์ ๋๋ค:
-
list๊ฐ name์ ํฌํจํ๋ฉด, ์ฒซ ๋ฒ์งธ ํด๋น ํค๋(header)์ ๊ฐ(value)์ value๋ก ์ค์ ํ๊ณ , ๋๋จธ์ง ํด๋น ํค๋๋ค์ ์ ๊ฑฐํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, append (name, value)๋ฅผ list์ ์ถ๊ฐํฉ๋๋ค.
combine์ ํค๋(header) (name, value)๋ฅผ ํค๋ ๋ชฉ๋ก(header list) list์ ๊ฒฐํฉํ๋ ๋ฐฉ๋ฒ์ ๋๋ค:
-
list๊ฐ name์ ํฌํจํ๋ฉด, ์ฒซ ๋ฒ์งธ ํด๋น ํค๋์ value ๋ค์ 0x2C 0x20(์ผํ+๊ณต๋ฐฑ), value๋ฅผ ์์๋๋ก ์ด์ด๋ถ์ ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, append (name, value)๋ฅผ list์ ์ถ๊ฐํฉ๋๋ค.
combine์ XMLHttpRequest
๋ฐ
WebSocket ํ๋กํ ์ฝ ํธ๋์
ฐ์ดํฌ์์ ์ฌ์ฉ๋ฉ๋๋ค.
ํค๋ ์ด๋ฆ์ ์ ๋ ฌ๋ ์๋ฌธ์ ์งํฉ์ผ๋ก ๋ณํ(convert header names to a sorted-lowercase set)ํ๋ ค๋ฉด, ๋ฆฌ์คํธ(list)์ ์ด๋ฆ๋ค headerNames๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ฆ ๋๋ค. ๋ฐํ๊ฐ์ ์์ ์๋ ์งํฉ(ordered set)์ ํค๋ ์ด๋ฆ์ ๋๋ค.
-
headerNamesSet์ ์๋ก์ด ์์ ์๋ ์งํฉ์ผ๋ก ๋ก๋๋ค.
-
๊ฐ name์ ๋ํด, ๋ฐ์ดํธ ์๋ฌธ์ํ(byte-lowercasing) name์ headerNamesSet์ appendํฉ๋๋ค.
-
์ค๋ฆ์ฐจ์ ์ ๋ ฌ์ headerNamesSet์ ๋ฐ์ดํธ ๋น๊ต(byte less than)๋ก ์ ์ฉํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
sort and combine์ ํค๋ ๋ชฉ๋ก(header list) list๋ฅผ ์ ๋ ฅ๋ฐ์, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค. ๋ฐํ๊ฐ์ ํค๋ ๋ชฉ๋ก(header list)์ ๋๋ค.
-
headers๋ฅผ ํค๋ ๋ชฉ๋ก(header list)์ผ๋ก ๋ก๋๋ค.
-
names๋ฅผ ํค๋ ์ด๋ฆ์ ์ ๋ ฌ๋ ์๋ฌธ์ ์งํฉ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. ์ด๋ list ๋ด ํค๋๋ค์ ์ด๋ฆ์ ์ฌ์ฉํฉ๋๋ค.
-
๊ฐ name์ ๋ํด:
-
name์ด `
set-cookie`๋ผ๋ฉด: -
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
-
headers๋ฅผ ๋ฐํํฉ๋๋ค.
ํค๋(header)๋ ํํ(tuple)๋ก, ์ด๋ฆ(name) (ํค๋ ์ด๋ฆ)๊ณผ ๊ฐ(value) (ํค๋ ๊ฐ)์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค.
ํค๋ ์ด๋ฆ(header name)์ ๋ฐ์ดํธ ์ํ์ค๋ก, field-name ํ ํฐ ์์ฑ์์ ๋ง์กฑํฉ๋๋ค.
ํค๋ ๊ฐ(header value)์ ๋ฐ์ดํธ ์ํ์ค๋ก, ๋ค์ ์กฐ๊ฑด์ ๋ชจ๋ ๋ง์กฑํด์ผ ํฉ๋๋ค:
-
์ ํ ๋๋ ํํ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ๋ฐ์ดํธ๊ฐ ์์ด์ผ ํฉ๋๋ค.
-
0x00 (NUL) ๋๋ HTTP ์ค๋ฐ๊ฟ ๋ฐ์ดํธ๋ฅผ ํฌํจํ์ง ์์์ผ ํฉ๋๋ค.
ํค๋ ๊ฐ์ ์ ์๋ field-value ํ ํฐ ์์ฑ์์ ๋ฐ๋ฅด์ง ์๋ ๊ฒ์ด, ๋ฐฐํฌ๋ ์ฝํ ์ธ ์ ํธํ๋์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
ํค๋ ๊ฐ ์ ๊ทํ(normalize)๋ ๋ฐ์ดํธ ์ํ์ค potentialValue์์ ์ ํ ๋ฐ ํํ HTTP ๊ณต๋ฐฑ ๋ฐ์ดํธ๋ฅผ ์ ๊ฑฐํ๋ ๊ฒ์ ๋๋ค.
ํค๋ (name, value) ๊ฐ CORS-์์ ๋ชฉ๋ก ์์ฒญ ํค๋(CORS-safelisted request-header)์ธ์ง ํ๋จํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค:
-
value์ ๊ธธ์ด๊ฐ 128์ ์ด๊ณผํ๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
-
๋ฐ์ดํธ ์๋ฌธ์ํ(Byte-lowercase)ํ name์ ๋ฐ๋ผ ๋ถ๊ธฐํฉ๋๋ค:
- `
accept` -
value์ CORS-๋น์์ ์์ฒญ ํค๋ ๋ฐ์ดํธ๊ฐ ์์ผ๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
- `
accept-language`- `
content-language` - `
-
value์ 0x30 (0)~0x39 (9), 0x41 (A)~0x5A (Z), 0x61 (a)~0x7A (z), 0x20 (SP), 0x2A (*), 0x2C (,), 0x2D (-), 0x2E (.), 0x3B (;), 0x3D (=)์ ์ํ์ง ์๋ ๋ฐ์ดํธ๊ฐ ์์ผ๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
- `
content-type` -
-
value์ CORS-๋น์์ ์์ฒญ ํค๋ ๋ฐ์ดํธ๊ฐ ์์ผ๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
-
mimeType์ ํ์ฑ(parsing)ํ ๋ฑ๊ฐ ๋์ฝ๋ฉ(isomorphic decoding) value ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
mimeType์ด ์คํจ(failure)๋ผ๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
-
mimeType์ essence๊ฐ "
application/x-www-form-urlencoded", "multipart/form-data", ๋๋ "text/plain"์ด ์๋๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
์ด๋ MIME ํ์ ์ถ์ถ(extract a MIME type) ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํ์ง ์์ต๋๋ค. ํด๋น ์๊ณ ๋ฆฌ์ฆ์ ๊ด๋ํ๋ฉฐ, ์๋ฒ๊ฐ ์ด๋ฅผ ๊ตฌํํด์ผ ํ๋ค๊ณ ๊ธฐ๋ํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
MIME ํ์ ์ถ์ถ์ ์ฌ์ฉํ ๊ฒฝ์ฐ ์๋ ์์ฒญ์ CORS ํ๋ฆฌํ๋ผ์ดํธ ์์ด ์ฒ๋ฆฌ๋๊ณ , ์๋ฒ์ ๋จ์ ํ์๋ ์์ฒญ ๋ณธ๋ฌธ์ JSON์ผ๋ก ์ฒ๋ฆฌํ ์ ์์ต๋๋ค:
fetch( "https://victim.example/naรฏve-endpoint" , { method: "POST" , headers: [ [ "Content-Type" , "application/json" ], [ "Content-Type" , "text/plain" ] ], credentials: "include" , body: JSON. stringify( exerciseForTheReader) }); -
- `
range` -
-
rangeValue๋ฅผ ๋จ์ผ range ํค๋ ๊ฐ ํ์ฑ(parsing a single range header value) ์ value์ false๋ฅผ ๋๊ธด ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
rangeValue๊ฐ ์คํจ(failure)๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
-
rangeValue[0]์ด null์ด๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
์น ๋ธ๋ผ์ฐ์ ๋ `
bytes=-500`์ ๊ฐ์ range๋ฅผ ๋ด๋ณด๋ด์ง ์์ผ๋ฏ๋ก ์ด ์๊ณ ๋ฆฌ์ฆ์ ๊ทธ๋ฐ ๊ฒฝ์ฐ๋ฅผ safelistํ์ง ์์ต๋๋ค.
-
- ๊ธฐํ
-
false๋ฅผ ๋ฐํํฉ๋๋ค.
- `
-
true๋ฅผ ๋ฐํํฉ๋๋ค.
`Content-Type` ํค๋ safelist์๋ ์ ํ์ ์์ธ๊ฐ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ CORS ํ๋กํ ์ฝ ์์ธ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
CORS-๋น์์ ์์ฒญ ํค๋ ๋ฐ์ดํธ(CORS-unsafe request-header byte)๋ ๋ฐ์ดํธ byte๊ฐ ๋ค์ ์ค ํ๋์ ํด๋นํ ๋์ ๋๋ค:
-
byte๊ฐ 0x20 ๋ฏธ๋ง์ด๊ณ 0x09 HT๊ฐ ์๋ ๊ฒฝ์ฐ
-
byte๊ฐ 0x22 ("), 0x28 (์ผ์ชฝ ๊ดํธ), 0x29 (์ค๋ฅธ์ชฝ ๊ดํธ), 0x3A (:), 0x3C (<), 0x3E (>), 0x3F (?), 0x40 (@), 0x5B ([), 0x5C (\), 0x5D (]), 0x7B ({), 0x7D (}), ๋๋ 0x7F DEL์ธ ๊ฒฝ์ฐ.
CORS-๋น์์ ์์ฒญ ํค๋ ์ด๋ฆ(CORS-unsafe request-header names)์ ํค๋ ๋ชฉ๋ก headers์ ๋ํด ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ํฉ๋๋ค:
-
unsafeNames๋ฅผ ์ ๋ฆฌ์คํธ๋ก ๋ก๋๋ค.
-
potentiallyUnsafeNames๋ฅผ ์ ๋ฆฌ์คํธ๋ก ๋ก๋๋ค.
-
safelistValueSize๋ฅผ 0์ผ๋ก ๋ก๋๋ค.
-
๊ฐ headers์ header์ ๋ํด:
-
safelistValueSize๊ฐ 1024๋ฅผ ์ด๊ณผํ๋ฉด ๊ฐ potentiallyUnsafeNames์ name์ append๋ก unsafeNames์ ์ถ๊ฐํฉ๋๋ค.
-
ํค๋ ์ด๋ฆ์ ์ ๋ ฌ๋ ์๋ฌธ์ ์งํฉ์ผ๋ก ๋ณํํ unsafeNames๋ฅผ ๋ฐํํฉ๋๋ค.
CORS
non-wildcard ์์ฒญ ํค๋ ์ด๋ฆ(CORS non-wildcard request-header name)์ ํค๋ ์ด๋ฆ ์ค
๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด `Authorization`์ ์ผ์นํ๋ ๊ฒ์
๋๋ค.
ํน๊ถ no-CORS ์์ฒญ ํค๋ ์ด๋ฆ(privileged no-CORS request-header name)์ ํค๋ ์ด๋ฆ ์ค ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ๋ค์ ์ค ํ๋์ ์ผ์นํ๋ ๊ฒ์ ๋๋ค:
- `
Range`.
์ด๋ค์ ํน๊ถ API์์ ์ค์ ํ ์ ์์ผ๋ฉฐ, ๊ด๋ จ ์์ฒญ ๊ฐ์ฒด๊ฐ ๋ณต์ฌ๋ ๋๋ ๋ณด์กด๋์ง๋ง, ๊ถํ์ด ์๋ API๊ฐ ์์ฒญ์ ์์ ํ๋ ๊ฒฝ์ฐ ์ ๊ฑฐ๋ฉ๋๋ค.
`Range` ํค๋๋ ์ฃผ๋ก ๋ค์ด๋ก๋
๋ฐ ๋ฏธ๋์ด ํจ์น์์ ์ฌ์ฉ๋ฉ๋๋ค.
ํน์ ์์ฒญ์ range ํค๋ ์ถ๊ฐ๋ฅผ ์ํ ํฌํผ๊ฐ ์ ๊ณต๋ฉ๋๋ค.
CORS-์์ ๋ชฉ๋ก ์๋ต ํค๋ ์ด๋ฆ(CORS-safelisted response-header name)์ ๋ฆฌ์คํธ์ ํค๋ ์ด๋ฆ list์ ๋ํด, ๋ค์ ์ค ํ๋์ ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ์ผ์นํ๋ ํค๋ ์ด๋ฆ์ ๋๋ค:
- `
Cache-Control` - `
Content-Language` - `
Content-Length` - `
Content-Type` - `
Expires` - `
Last-Modified` - `
Pragma` - ๋ฆฌ์คํธ(list)์ ๋ชจ๋ ํญ๋ชฉ ์ค ๊ธ์ง๋ ์๋ต ํค๋ ์ด๋ฆ(forbidden response-header name)์ด ์๋ ๊ฒ.
no-CORS-์์ ๋ชฉ๋ก ์์ฒญ ํค๋ ์ด๋ฆ(no-CORS-safelisted request-header name)์ ํค๋ ์ด๋ฆ ์ค ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ๋ค์ ์ค ํ๋์ ์ผ์นํ๋ ๊ฒ์ ๋๋ค:
- `
Accept` - `
Accept-Language` - `
Content-Language` - `
Content-Type`
ํค๋ (name, value)๊ฐ no-CORS-์์ ๋ชฉ๋ก ์์ฒญ ํค๋(no-CORS-safelisted request-header)์ธ์ง ํ๋จํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค:
-
name์ด no-CORS-์์ ๋ชฉ๋ก ์์ฒญ ํค๋ ์ด๋ฆ์ด ์๋๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค.
-
(name, value)๊ฐ CORS-์์ ๋ชฉ๋ก ์์ฒญ ํค๋์ธ์ง ์ฌ๋ถ๋ฅผ ๋ฐํํฉ๋๋ค.
ํค๋ (name, value)๊ฐ ๊ธ์ง๋ ์์ฒญ ํค๋(forbidden request-header)์ธ์ง ํ๋จํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๊ฐ true๋ฅผ ๋ฐํํ๋ฉด ๋ฉ๋๋ค:
-
name์ด ๋ค์ ์ค ํ๋์ ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ์ผ์นํ๋ฉด:
- `
Accept-Charset` - `
Accept-Encoding` - `
Access-Control-Request-Headers` - `
Access-Control-Request-Method` - `
Connection` - `
Content-Length` - `
Cookie` - `
Cookie2` - `
Date` - `
DNT` - `
Expect` - `
Host` - `
Keep-Alive` - `
Origin` - `
Referer` - `
Set-Cookie` - `
TE` - `
Trailer` - `
Transfer-Encoding` - `
Upgrade` - `
Via`
true๋ฅผ ๋ฐํํฉ๋๋ค.
- `
-
name์ ๋ฐ์ดํธ ์๋ฌธ์ํํ์ฌ, proxy- ๋๋
sec-์ผ๋ก ์์ํ๋ฉด true๋ฅผ ๋ฐํํฉ๋๋ค. -
name์ด ๋ค์ ์ค ํ๋์ ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ์ผ์นํ๋ฉด:
- `
X-HTTP-Method` - `
X-HTTP-Method-Override` - `
X-Method-Override`
๋ค์ ์ ์ฐจ๋ฅผ ์คํํฉ๋๋ค:
-
parsedValues๋ฅผ get, decode, and split value์ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
๊ฐ parsedValues์ method์ ๋ํด, isomorphic encodingํ method๊ฐ ๊ธ์ง๋ ๋ฉ์๋(forbidden method)๋ผ๋ฉด true๋ฅผ ๋ฐํํฉ๋๋ค.
- `
-
false๋ฅผ ๋ฐํํฉ๋๋ค.
์ด ํค๋๋ค์ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์์ ํ ์ ์ดํ ์ ์๋๋ก ๊ธ์ง๋ฉ๋๋ค.
ํค๋ ์ด๋ฆ์ด
`Sec-`๋ก ์์ํ๋ ๊ฒฝ์ฐ, ํค๋๊ฐ
fetch ๋ฑ ๊ฐ๋ฐ์๊ฐ ํค๋๋ฅผ ์ ์ดํ ์
์๋ API์ ์ํด ์ฌ์ฉ๋ ๋, ์ ํค๋๊ฐ ์์ ํ๊ฒ ๋์
๋ ์ ์๋๋ก ์์ฝ๋์ด ์์ต๋๋ค. ์: XMLHttpRequest.
[XHR]
`Set-Cookie` ํค๋๋ ์๋ฏธ์ ์๋ต ํค๋์ด๋ฏ๋ก ์์ฒญ์์๋ ์ธ๋ชจ๊ฐ ์์ต๋๋ค. `Set-Cookie` ํค๋๋ ๊ฒฐํฉ(combine)๋
์ ์์ผ๋ฏ๋ก, Headers
๊ฐ์ฒด์์ ๋ ๋ณต์กํ๊ฒ ์ฒ๋ฆฌํด์ผ ํฉ๋๋ค. ์ฌ๊ธฐ์ ๊ธ์งํ๋ ์ด์ ๋ ์ด ๋ณต์ก์ฑ์ด ์์ฒญ์ผ๋ก ์์ด ๋๊ฐ๋ ๊ฒ์ ๋ง๊ธฐ ์ํจ์
๋๋ค.
๊ธ์ง๋ ์๋ต ํค๋ ์ด๋ฆ(forbidden response-header name)์ ํค๋ ์ด๋ฆ ์ค ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ๋ค์ ์ค ํ๋์ ์ผ์นํ๋ ๊ฒ์ ๋๋ค:
- `
Set-Cookie` - `
Set-Cookie2`
์์ฒญ ๋ณธ๋ฌธ ํค๋ ์ด๋ฆ(request-body-header name)์ ํค๋ ์ด๋ฆ ์ค ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ๋ค์ ์ค ํ๋์ ์ผ์นํ๋ ๊ฒ์ ๋๋ค:
- `
Content-Encoding` - `
Content-Language` - `
Content-Location` - `
Content-Type`
ํค๋ ๊ฐ ์ถ์ถ(extract header values) ์ ํค๋(header) header๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค:
ํค๋ ๋ชฉ๋ก ๊ฐ ์ถ์ถ(extract header list values) ์ ํค๋ ์ด๋ฆ name๊ณผ ํค๋ ๋ชฉ๋ก(header list) list๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค:
-
list๊ฐ name์ ํฌํจํ์ง ์์ผ๋ฉด null์ ๋ฐํํฉ๋๋ค.
-
name์ ๋ํ ABNF๊ฐ ๋จ์ผ ํค๋(header)๋ง ํ์ฉํ๊ณ , list๊ฐ name์ ์ค๋ณต ํฌํจํ๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
๋ค๋ฅธ ์ค๋ฅ ์ฒ๋ฆฌ๊ฐ ํ์ํ๋ค๋ฉด, ๋จผ์ ์ํ๋ ํค๋๋ฅผ ์ถ์ถํ์ธ์.
-
values๋ฅผ ๋น ๋ฆฌ์คํธ๋ก ๋ก๋๋ค.
-
list ์ ํฌํจ๋ ๊ฐ ํค๋ header ์ค ์ด๋ฆ ์ด name ์ธ ํค๋์ ๋ํด:
-
extract๋ฅผ ํค๋ ๊ฐ ์ถ์ถ์ header์ ์คํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
extract๊ฐ failure๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
-
extract์ ๊ฐ ๊ฐ์ ์์๋๋ก values์ ์ถ๊ฐํฉ๋๋ค.
-
-
values๋ฅผ ๋ฐํํฉ๋๋ค.
์ฝํ ์ธ ๋ฒ์ ์์ฑ(build a content range)์ ์ ์ rangeStart, ์ ์ rangeEnd, ์ ์ fullLength๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค:
-
contentRange๋ฅผ `
bytes`๋ก ๋ก๋๋ค. -
rangeStart๋ฅผ ์ง๋ ฌํ ๋ฐ ๋ฑ๊ฐ ์ธ์ฝ๋ฉ(isomorphic encoded) ํ์ฌ contentRange์ ์ถ๊ฐํฉ๋๋ค.
-
0x2D (-)๋ฅผ contentRange์ ์ถ๊ฐํฉ๋๋ค.
-
rangeEnd๋ฅผ ์ง๋ ฌํ ๋ฐ ๋ฑ๊ฐ ์ธ์ฝ๋ฉ ํ์ฌ contentRange์ ์ถ๊ฐํฉ๋๋ค.
-
0x2F (/)๋ฅผ contentRange์ ์ถ๊ฐํฉ๋๋ค.
-
fullLength๋ฅผ ์ง๋ ฌํ ๋ฐ ๋ฑ๊ฐ ์ธ์ฝ๋ฉ ํ์ฌ contentRange์ ์ถ๊ฐํฉ๋๋ค.
-
contentRange๋ฅผ ๋ฐํํฉ๋๋ค.
๋จ์ผ range ํค๋ ๊ฐ ํ์ฑ(parse a single range header value)์ ๋ฐ์ดํธ ์ํ์ค value์ ๋ถ๋ฆฌ์ธ allowWhitespace๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์์ ์คํํฉ๋๋ค:
-
data๋ฅผ ๋ฑ๊ฐ ๋์ฝ๋ฉ(isomorphic decoding) value ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
data๊ฐ "
bytes"๋ก ์์ํ์ง ์์ผ๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค. -
position์ ์์น ๋ณ์(position variable)๋ก, data์ 5๋ฒ์งธ ์ฝ๋ ํฌ์ธํธ ์์น๋ก ๋ก๋๋ค.
-
allowWhitespace ๊ฐ true๋ผ๋ฉด data ์ position ์ด ์ฃผ์ด์ก์ ๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ์ธ ์ฝ๋ ํฌ์ธํธ ์ํ์ค๋ฅผ ์์งํฉ๋๋ค .
-
data์ position ์์น ์ฝ๋ ํฌ์ธํธ๊ฐ U+003D (=)๊ฐ ์๋๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
allowWhitespace ๊ฐ true๋ผ๋ฉด data ์ position ์ด ์ฃผ์ด์ก์ ๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ์ธ ์ฝ๋ ํฌ์ธํธ ์ํ์ค๋ฅผ ์์งํฉ๋๋ค .
-
rangeStart ๋ฅผ data ์ position ์ด ์ฃผ์ด์ก์ ๋ ASCII ์ซ์ ์ธ ์ฝ๋ ํฌ์ธํธ ์ํ์ค๋ฅผ ์์ง ํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
rangeStartValue๋ฅผ rangeStart๊ฐ ๋น ๋ฌธ์์ด์ด ์๋๋ฉด 10์ง์๋ก ํด์ํ ๊ฐ, ์๋๋ฉด null๋ก ๋ก๋๋ค.
-
allowWhitespace ๊ฐ true๋ผ๋ฉด data ์ position ์ด ์ฃผ์ด์ก์ ๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ์ธ ์ฝ๋ ํฌ์ธํธ ์ํ์ค๋ฅผ ์์งํฉ๋๋ค .
-
data์ position ์์น ์ฝ๋ ํฌ์ธํธ๊ฐ U+002D (-)๊ฐ ์๋๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
allowWhitespace ๊ฐ true๋ผ๋ฉด data ์ position ์ด ์ฃผ์ด์ก์ ๋ HTTP ํญ ๋๋ ๊ณต๋ฐฑ ์ธ ์ฝ๋ ํฌ์ธํธ ์ํ์ค๋ฅผ ์์งํฉ๋๋ค .
-
rangeEnd ๋ฅผ data ์ position ์ด ์ฃผ์ด์ก์ ๋ ASCII ์ซ์ ์ธ ์ฝ๋ ํฌ์ธํธ ์ํ์ค๋ฅผ ์์ง ํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
rangeEndValue๋ฅผ rangeEnd๊ฐ ๋น ๋ฌธ์์ด์ด ์๋๋ฉด 10์ง์๋ก ํด์ํ ๊ฐ, ์๋๋ฉด null๋ก ๋ก๋๋ค.
-
position์ด data์ ๋์ ์ง๋์ง ์์๋ค๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
-
rangeEndValue์ rangeStartValue๊ฐ ๋ชจ๋ null์ด๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
-
rangeStartValue์ rangeEndValue๊ฐ ๋ชจ๋ ์ซ์์ด๊ณ , rangeStartValue๊ฐ rangeEndValue๋ณด๋ค ํฌ๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค.
-
(rangeStartValue, rangeEndValue)๋ฅผ ๋ฐํํฉ๋๋ค.
range ๋์ด๋ ์์์ด ์๋ต๋ ์ ์์ต๋๋ค. ์: `
bytes=0-` ๋๋ `bytes=-500`๋ ์ ํจํ range์ ๋๋ค.
๋จ์ผ range ํค๋ ๊ฐ ํ์ฑ์ ํ์ฉ๋ range ํค๋ ๊ฐ์ ์ผ๋ถ๋ง ์ฑ๊ณตํ์ง๋ง, ๋ฏธ๋์ด ์์ฒญ์ด๋ ๋ค์ด๋ก๋ ์ฌ๊ฐ ๋ฑ์์ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ๊ฐ์ฅ ์์ฃผ ์ฌ์ฉํ๋ ํ์์ ๋๋ค. ์ด range ํค๋ ๊ฐ ํ์์ range ํค๋ ์ถ๊ฐ๋ฅผ ํตํด ์ค์ ํ ์ ์์ต๋๋ค.
๊ธฐ๋ณธ
`User-Agent` ๊ฐ(default `User-Agent` value)์
๊ตฌํ ์ ์(implementation-defined) ํค๋ ๊ฐ์
๋๋ค (`User-Agent` ํค๋์ฉ).
์น ํธํ์ฑ ๋ฌธ์ ๋ก ์ธํด, ์น ๋ธ๋ผ์ฐ์ ๋ ์ด ๊ฐ์ด `Mozilla/5.0 (`๋ก ์์ํ๋๋ก ํ๊ณ , ์ผ๋ฐ์ ์ผ๋ก ๋ค๋ฅธ ์น ๋ธ๋ผ์ฐ์ ๋ฅผ
๋ฐ๋ผํ๋๋ก ๊ฐํ๊ฒ ๊ถ์ฅ๋ฉ๋๋ค.
environment settings object
environment์
environment default `User-Agent` value๋ฅผ
์ป์ผ๋ ค๋ฉด:
-
userAgent๋ฅผ WebDriver BiDi emulated User-Agent๋ก environment์ ๋ํด ์ค์ ํ๋ค.
-
userAgent๊ฐ null์ด ์๋๋ผ๋ฉด, userAgent๋ฅผ isomorphic encoded๋ ๊ฐ์ผ๋ก ๋ฐํํ๋ค.
-
default `
User-Agent` value๋ฅผ ๋ฐํํ๋ค.
๋ฌธ์
`Accept` ํค๋ ๊ฐ(document `Accept` header value)์
`text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`์
๋๋ค.
2.2.3. ์ํ
์ํ(status)๋ 0๋ถํฐ 999๊น์ง(ํฌํจ)์ ์ ์์ ๋๋ค.
HTTP/1์ status-code๋ฅผ ์ด ๊ฐ๋
์ ๋งคํํ ๋์ ๋ค์ํ ๊ฒฝ๊ณ ์ฌ๋ก๋ ์ด์ #1156์์ ๋
ผ์๋๊ณ ์์ต๋๋ค.
null ๋ณธ๋ฌธ ์ํ(null body status)๋ 101, 103, 204, 205, 304์ธ ์ํ์ ๋๋ค.
ok ์ํ(ok status)๋ 200๋ถํฐ 299๊น์ง(ํฌํจ)์ ์ํ์ ๋๋ค.
๋ฒ์ ์ํ๋ 206 ๋๋ 416์ธ ์ํ์ ๋๋ค.
๋ฆฌ๋๋ ์ ์ํ๋ 301, 302, 303, 307 ๋๋ 308์ธ ์ํ์ ๋๋ค.
2.2.4. ๋ณธ๋ฌธ
๋ณธ๋ฌธ(body)์ ๋ค์์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค:
-
์คํธ๋ฆผ(stream) (
ReadableStream๊ฐ์ฒด). -
์์ค(source) (null, ๋ฐ์ดํธ ์ํ์ค,
Blob๊ฐ์ฒด, ๋๋FormData๊ฐ์ฒด), ์ด๊ธฐ๊ฐ์ null. -
๊ธธ์ด(length) (null ๋๋ ์ ์), ์ด๊ธฐ๊ฐ์ null.
๋ณต์ (clone)๋ฅผ ๋ณธ๋ฌธ body์ ๋ํด ์คํํ๋ ค๋ฉด ๋ค์์ ๋ฐ๋ฆ ๋๋ค:
๋ฐ์ดํธ ์ํ์ค bytes๋ฅผ ๋ณธ๋ฌธ์ผ๋ก(as a body) ์ป์ผ๋ ค๋ฉด, ์์ ํ๊ฒ ์ถ์ถ(safely extracting) bytes์ ๊ฒฐ๊ณผ ์ค body๋ฅผ ๋ฐํํฉ๋๋ค.
์ ์ง์ ์ผ๋ก ์ฝ๊ธฐ(incrementally read)๋ ๋ณธ๋ฌธ(body) body์ ์๊ณ ๋ฆฌ์ฆ processBodyChunk, ์๊ณ ๋ฆฌ์ฆ processEndOfBody, ์๊ณ ๋ฆฌ์ฆ processBodyError, ์ต์ ์ผ๋ก null, parallel queue ๋๋ global object taskDestination (๊ธฐ๋ณธ๊ฐ null)์ด ์ฃผ์ด์ก์ ๋ ๋ค์์ ์คํํฉ๋๋ค. processBodyChunk๋ ๋ฐ์ดํธ ์ํ์ค๋ฅผ ์ธ์๋ก ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ฉฐ, processEndOfBody๋ ์ธ์ ์์ด, processBodyError๋ ์์ธ๋ฅผ ์ธ์๋ก ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํฉ๋๋ค.
-
taskDestination์ด null์ด๋ฉด ์ parallel queue ์์ ๊ฒฐ๊ณผ๋ฅผ taskDestination๋ก ๋ก๋๋ค.
-
reader๋ฅผ ๋ฆฌ๋(getting a reader)๋ก body์ ์คํธ๋ฆผ์ ๋ํด ๊ตฌํฉ๋๋ค.
์ด ๋์์ ์์ธ๋ฅผ ๋ฐ์์ํค์ง ์์ต๋๋ค.
-
์ ์ง์ ์ฝ๊ธฐ ๋ฃจํ(incrementally-read loop)๋ฅผ reader, taskDestination, processBodyChunk, processEndOfBody, processBodyError๋ก ์คํํฉ๋๋ค.
์ ์ง์ ์ฝ๊ธฐ
๋ฃจํ(incrementally-read loop)๋ฅผ ์คํํ๋ ค๋ฉด, ReadableStreamDefaultReader
๊ฐ์ฒด
reader, parallel queue ๋๋ global object
taskDestination, ์๊ณ ๋ฆฌ์ฆ processBodyChunk, ์๊ณ ๋ฆฌ์ฆ
processEndOfBody, ์๊ณ ๋ฆฌ์ฆ processBodyError๊ฐ ์ฃผ์ด์ง๋๋ค:
-
readRequest๋ฅผ ๋ค์ read request๋ก ๋ก๋๋ค:
- chunk steps (chunk)
-
-
continueAlgorithm์ null๋ก ๋ก๋๋ค.
-
chunk๊ฐ
Uint8Array๊ฐ์ฒด๊ฐ ์๋๋ผ๋ฉด, continueAlgorithm์ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค: processBodyError๋ฅผTypeError์ ํจ๊ป ์คํ. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
bytes๋ฅผ ๋ณต์ฌ(copy)๋ chunk๋ก ๋ก๋๋ค.
๊ตฌํ์ ์ด ๋ณต์ฌ๋ฅผ ํผํ๋ ์ ๋ต์ ์ฌ์ฉํ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ์ฅํฉ๋๋ค.
-
continueAlgorithm์ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค:
-
processBodyChunk๋ฅผ bytes๋ก ์คํ.
-
์ ์ง์ ์ฝ๊ธฐ ๋ฃจํ๋ฅผ reader, taskDestination, processBodyChunk, processEndOfBody, processBodyError๋ก ์ฌ๊ท ํธ์ถ.
-
-
-
fetch ํ์คํฌ ํ์์ continueAlgorithm, taskDestination์ ์คํํฉ๋๋ค.
-
- close steps
-
-
fetch ํ์คํฌ ํ์์ processEndOfBody, taskDestination์ ์คํํฉ๋๋ค.
-
- error steps (e)
-
-
fetch ํ์คํฌ ํ์์ processBodyError์ e์ taskDestination๋ก ์คํํฉ๋๋ค.
-
-
์ฒญํฌ ์ฝ๊ธฐ(Read a chunk)๋ฅผ reader์ readRequest๋ก ์คํํฉ๋๋ค.
์์ ํ ์ฝ๊ธฐ(fully read)๋ ๋ณธ๋ฌธ(body) body, ์๊ณ ๋ฆฌ์ฆ processBody, ์๊ณ ๋ฆฌ์ฆ processBodyError, ์ต์ ์ผ๋ก null, parallel queue ๋๋ global object taskDestination (๊ธฐ๋ณธ๊ฐ null)์ด ์ฃผ์ด์ก์ ๋ ๋ค์์ ์คํํฉ๋๋ค. processBody๋ ๋ฐ์ดํธ ์ํ์ค๋ฅผ ์ธ์๋ก ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ฉฐ, processBodyError๋ ์์ธ(์ต์ )๋ฅผ ์ธ์๋ก ๋ฐ์ ์ ์๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํฉ๋๋ค.
-
taskDestination์ด null์ด๋ฉด ์ parallel queue ์์ ๊ฒฐ๊ณผ๋ฅผ taskDestination๋ก ๋ก๋๋ค.
-
successSteps ๋ฅผ ๋ฐ์ดํธ ์ํ์ค bytes ๊ฐ ์ฃผ์ด์ก์ ๋ taskDestination ์ ๋์์ผ๋ก bytes ๋ฅผ ์ธ์๋ก processBody ๋ฅผ ์คํํ๋ fetch ํ์คํฌ๋ฅผ ํ์ ๋ฃ๋ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ๋ก๋๋ค.
-
errorSteps๋ฅผ fetch ํ์คํฌ ํ์์ processBodyError์ exception, taskDestination๋ก ์คํํ๋ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ๋ก๋๋ค.
-
reader๋ฅผ ๋ฆฌ๋(getting a reader)๋ก body์ ์คํธ๋ฆผ์ ๋ํด ๊ตฌํฉ๋๋ค. ์์ธ๊ฐ ๋ฐ์ํ๋ฉด errorSteps๋ฅผ ๊ทธ ์์ธ์ ํจ๊ป ์คํํ๊ณ ์ข ๋ฃํฉ๋๋ค.
-
๋ชจ๋ ๋ฐ์ดํธ ์ฝ๊ธฐ(Read all bytes)๋ฅผ reader, successSteps, errorSteps๋ก ์คํํฉ๋๋ค.
ํ์ ์ด ์๋ ๋ณธ๋ฌธ(body with type)์ ํํ๋ก, ๋ณธ๋ฌธ(body) (body)๊ณผ ํ์ (type) (ํค๋ ๊ฐ ๋๋ null)์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค.
์ฝํ ์ธ ์ฝ๋ฉ ์ฒ๋ฆฌ(handle content codings)๋ codings์ bytes๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
codings๊ฐ ์ง์๋์ง ์์ผ๋ฉด bytes๋ฅผ ๋ฐํํฉ๋๋ค.
-
HTTP์์ ์ค๋ช ํ ๋๋ก codings๋ก bytes๋ฅผ ๋์ฝ๋ฉํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. ๋์ฝ๋ฉ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ฉด failure๋ฅผ ๋ฐํํฉ๋๋ค. [HTTP]
2.2.5. ์์ฒญ
์ด ์ ์ ์์ฒญ์ด ์ด๋ป๊ฒ ๋์ํ๋์ง ์์ธํ ๋ฌธ์ํํฉ๋๋ค. ์์ํ๋ ค๋ฉด ์์ฒญ ์ค์ ์ ์ฐธ๊ณ ํ์ธ์.
fetch์ ์ ๋ ฅ๊ฐ์ ์์ฒญ(request)์ ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
๋ฉ์๋(method)๋ฅผ ๊ฐ์ง๋๋ค.
(method) ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด
`GET`์
๋๋ค.
๋ฆฌ๋ค์ด๋ ํธ ์ค HTTP fetch์์ ์ค๋ช
๋ ๋๋ก `GET`์ผ๋ก ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ URL (URL)์ ๊ฐ์ง๋๋ค.
๊ตฌํ์ URL ๋ชฉ๋ก ์ค ์ฒซ ๋ฒ์งธ ์์ฒญ์ URL ๋ชฉ๋ก์ ๊ฐ๋ฆฌํค๊ฒ ๋ง๋๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค. ์ด ํ๋๋ Fetch์ ์ฐ๊ฒฐ๋๋ ๋ค๋ฅธ ํ์ค์ ํธ์๋ฅผ ์ํด ๋ณ๋๋ก ์ ๊ณต๋ฉ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ ๋ก์ปฌ URL ์ ์ฉ ํ๋๊ทธ(local-URLs-only flag)๋ฅผ ๊ฐ์ง๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด ์ค์ ๋์ง ์์(unset)์ ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ ํค๋ ๋ชฉ๋ก(header list)์ ๊ฐ์ง๋๋ค. (header list) ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด ยซ ยป์ ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ unsafe-request ํ๋๊ทธ๋ฅผ ๊ฐ์ง๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด ์ค์ ๋์ง ์์(unset)์ ๋๋ค.
unsafe-request ํ๋๊ทธ๋
fetch() ๋ฐ XMLHttpRequest์
๊ฐ์ API์์ ์ค์ ๋์ด,
์ง์ ๋ ๋ฉ์๋ ๋ฐ ํค๋
๋ชฉ๋ก์ ๋ฐ๋ผ
CORS-ํ๋ฆฌํ๋ผ์ดํธ
fetch๊ฐ ์ํ๋จ์ ๋ณด์ฅํฉ๋๋ค. ์ด๋ API๊ฐ ๊ธ์ง๋ ๋ฉ์๋ ๋ฐ ๊ธ์ง๋ ์์ฒญ ํค๋๋ฅผ ํ์ฉํ์ง ์๋ ๊ฒ๊ณผ๋ ๋ณ๊ฐ์
๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ ๋ณธ๋ฌธ(body)์ ๊ฐ์ง๋๋ค. (null, ๋ฐ์ดํธ ์ํ์ค, ๋๋ body) ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด null์ ๋๋ค.
๋ฐ์ดํธ ์ํ์ค ๋ fetch ์ด๊ธฐ์ ๋ณธ๋ฌธ ์ผ๋ก ์์ ํ๊ฒ ์ถ์ถ ๋ฉ๋๋ค. HTTP fetch ๊ณผ์ ์์ ํน์ ๋ฆฌ๋ค์ด๋ ํธ๋ก ์ธํด ์ด ํ๋๊ฐ null๋ก ์ค์ ๋ ์๋ ์์ต๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ ํด๋ผ์ด์ธํธ(client)๋ฅผ ๊ฐ์ง๋๋ค. (null ๋๋ environment settings object)
์์ฒญ์๋ ์ฐ๊ฒฐ๋ ์์ฝ๋ ํด๋ผ์ด์ธํธ๊ฐ ์์ต๋๋ค. (null ๋๋ ํ๊ฒฝ). ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ null์ ๋๋ค.
์ด๋ ํ์ ์์ฒญ ๋ฐ ์์ปค ์์ฒญ์๋ง ์ฌ์ฉ๋๋ฉฐ, ์๋น์ค ์์ปค ์์ฒญ์๋ ์ฌ์ฉ๋์ง ์์ต๋๋ค.
์์ฒญ์๋ ์ฐ๊ฒฐ๋ ๋์ฒด ํด๋ผ์ด์ธํธ id๊ฐ ์์ต๋๋ค(๋ฌธ์์ด). ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ ๋น ๋ฌธ์์ด์ ๋๋ค.
์ด๋ ํ์ ์์ฒญ์๋ง ์ฌ์ฉ๋ฉ๋๋ค. ์ด๋ id์ด๋ฉฐ, ๋์ ๋ธ๋ผ์ฐ์ง ์ปจํ ์คํธ์ ํ์ฑ ๋ฌธ์์ ํ๊ฒฝ ์ค์ ๊ฐ์ฒด์ ๊ฒ์ ๋๋ค.
์์ฒญ์๋ ์ฐ๊ฒฐ๋
์ฌ์ฉ์ ํ๋กฌํํธ์ฉ ์ํ ๊ฐ๋ฅ ํญ๋ชฉ์ด ์์ผ๋ฉฐ, ์ด๋
"no-traversable", "client", ๋๋ ์ํ ๊ฐ๋ฅํ ๋ด๋น๊ฒ์ด๋ธ์
๋๋ค.
๋ฌ๋ฆฌ ๋ช
์๋์ง ์๋ ํ "client"์
๋๋ค.
์ด๋ ์ธ์ฆ ํ๋กฌํํธ๋ ํด๋ผ์ด์ธํธ ์ธ์ฆ์ ๋ํ ์์์ ๊ฐ์ด ์์ฒญ์ ํ์ํ UI๋ฅผ ํ์ํ ์ง ์ฌ๋ถ์ ํ์ํ ์์น๋ฅผ ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
- "
no-traversable" - UI๊ฐ ํ์๋์ง ์์ผ๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก ์์ฒญ์ ๋คํธ์ํฌ ์ค๋ฅ์ ํจ๊ป ์คํจํฉ๋๋ค.
- "
client" - ์ด ๊ฐ์ ํ์นํ๋ ๋์
์์ฒญ์ ํด๋ผ์ด์ธํธ์์ ํ์๋
"
no-traversable" ๋๋ ์ํ ๊ฐ๋ฅํ ๋ด๋น๊ฒ์ด๋ธ ์ค ํ๋๋ก ์๋ ๋ณ๊ฒฝ๋ฉ๋๋ค. ์ด๋ ํ์ค์์ ์์ฒญ์ ์ฌ์ฉ์ ํ๋กฌํํธ์ฉ ์ํ ๊ฐ๋ฅ ํญ๋ชฉ์ ๋ช ์์ ์ผ๋ก ์ค์ ํ์ง ์์๋ ๋๋ ํธ๋ฆฌํ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค. - ์ํ ๊ฐ๋ฅํ ๋ด๋น๊ฒ์ด๋ธ
- ํ์๋๋ UI๋ ํด๋น ์ํ ๊ฐ๋ฅํ ๋ด๋น๊ฒ์ด๋ธ์ ํ์ํ๋ ๋ธ๋ผ์ฐ์ ์ธํฐํ์ด์ค ์์์ ์ฐ๊ฒฐ๋ฉ๋๋ค.
์์ฒญ์ ์ฌ์ฉ์ ํ๋กฌํํธ์ฉ ์ํ ๊ฐ๋ฅ ํญ๋ชฉ์์ ํด๋น ์์ฒญ๊ณผ ์ฐ๊ฒฐ๋ ์ฌ์ฉ์ ์ธํฐํ์ด์ค๋ฅผ ํ์ํ ๋, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ฃผ์ ํ์์ค์ ์ ๋ฐ์ดํธํ์ฌ ์์ฒญ์ ํ์ฌ URL์์ ํ์๋ ํญ๋ชฉ์ ํ์ํด์ผ ํฉ๋๋ค(์๋ฅผ ๋ค์ด ์์ฒญ ๊ฐ์์์ URL์์ ํ์๋ ์ด์ ๊ฐ์ ๊ทธ๋๋ก ๋์ด์๋ ์ ๋ฉ๋๋ค). ๋ํ ์ฌ์ฉ์ ์์ด์ ํธ๋ ์์ฒญ์ ๊ฐ์์์์ ๊ฐ์ ธ์จ ์ฝํ ์ธ ๋ฅผ ์ฌ์ฉ์ ํ๋กฌํํธ์ฉ ์ํ ๊ฐ๋ฅ ํญ๋ชฉ์ ํ์ํ์ง ์๋ ๊ฒ์ด ์ข์ผ๋ฉฐ, ํนํ ๊ต์ฐจ ์ถ์ฒ ์์ฒญ์ ๊ฒฝ์ฐ ๊ทธ๋ฌํฉ๋๋ค. ์ด๋ฌํ ํ๋กฌํํธ ๋ค์ ๋น ํ์ด์ง๋ฅผ ํ์ํ๋ ๊ฒ์ ์ด ์๊ตฌ ์ฌํญ์ ์ถฉ์กฑํ๋ ์ข์ ๋ฐฉ๋ฒ์ ๋๋ค. ์ด๋ฌํ ์ง์นจ์ ๋ฐ๋ฅด์ง ์์ผ๋ฉด ์ด๋ค ์ถ์ฒ๊ฐ ํ๋กฌํํธ๋ฅผ ๋ด๋นํ๋์ง ์ฌ์ฉ์๊ฐ ํผ๋ํ ์ ์์ต๋๋ค.
์์ฒญ์๋ ์ฐ๊ฒฐ๋ ๋ถ๋ฆฌ์ธ keepalive๊ฐ ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ false์ ๋๋ค.
์ด๋ ์์ฒญ์ด
ํ๊ฒฝ ์ค์ ๊ฐ์ฒด๋ณด๋ค ์ค๋ ์ ์ง๋๋๋ก ํ์ฉํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด,
navigator.sendBeacon()๊ณผ HTML
img ์์๊ฐ ์ด๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด ๊ฐ์ด true๋ก ์ค์ ๋ ์์ฒญ์๋ ์ถ๊ฐ
์ฒ๋ฆฌ ์๊ตฌ ์ฌํญ์ด ์ ์ฉ๋ฉ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
initiator type์ ๊ฐ์ง๋๋ค. ๊ฐ์ null,
"audio",
"beacon",
"body",
"css",
"early-hints",
"embed",
"fetch",
"font",
"frame",
"iframe",
"image",
"img",
"input",
"link",
"object",
"ping",
"script",
"track",
"video",
"xmlhttprequest", ๋๋
"other" ์ค ํ๋์
๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด null์
๋๋ค. [RESOURCE-TIMING]
์์ฒญ์ ์ฐ๊ด๋
service-workers mode๋ฅผ ๊ฐ์ง๋๋ค.
๊ฐ์ "all" ๋๋ "none" ์ค ํ๋์
๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด "all"์
๋๋ค.
์ด ๊ฐ์ ์ด๋ค ์๋น์ค ์์ปค๊ฐ ์ด fetch์ ๋ํด fetch
์ด๋ฒคํธ๋ฅผ ๋ฐ์์ง ๊ฒฐ์ ํฉ๋๋ค.
- "
all" - ํด๋น ์๋น์ค ์์ปค๊ฐ ์ด fetch์ ๋ํด
fetch์ด๋ฒคํธ๋ฅผ ๋ฐ๊ฒ ๋ฉ๋๋ค. - "
none" - ์ด๋ค ์๋น์ค ์์ปค๋ ์ด fetch์ ๋ํด ์ด๋ฒคํธ๋ฅผ ๋ฐ์ง ์์ต๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
initiator๋ฅผ ๊ฐ์ง๋๋ค. ๊ฐ์ ๋น ๋ฌธ์์ด,
"download",
"imageset",
"manifest",
"prefetch",
"prerender", ๋๋
"xslt" ์ค ํ๋์
๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด ๋น ๋ฌธ์์ด์
๋๋ค.
์์ฒญ์ initiator๋ ํ์ฌ๋ก์๋ ๋ค๋ฅธ ๋ช ์ธ์์ ๋ ์ธ๋ถํ๊ฐ ํ์ํ์ง ์์ ๋น๊ต์ ๋จ์ํฉ๋๋ค. ์ฃผ๋ก CSP์ ํผํฉ ์ฝํ ์ธ ์ ์๋ฅผ ๋๋ ๋ช ์ธ ์ฅ์น์ ๋๋ค. JavaScript์๋ ๋ ธ์ถ๋์ง ์์ต๋๋ค. [CSP] [MIX]
destination type์
๋ค์ ์ค ํ๋์ด๋ค:
๋น ๋ฌธ์์ด,
"audio",
"audioworklet",
"document",
"embed",
"font",
"frame",
"iframe",
"image",
"json",
"manifest",
"object",
"paintworklet",
"report",
"script",
"serviceworker",
"sharedworker",
"style",
"text",
"track",
"video",
"webidentity",
"worker", ๋๋
"xslt".
์์ฒญ์ ์ฐ๊ด๋ ๋์(destination)์ ๊ฐ์ง๋๋ค. (destination type) ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด ๋น ๋ฌธ์์ด์ ๋๋ค.
์ด ๊ฐ๋ค์ RequestDestination
์ ๋ฐ์๋ฉ๋๋ค. ๋จ, "serviceworker"์ "webidentity"๋ ํด๋น destination์ผ๋ก์ fetch๊ฐ ์๋น์ค ์์ปค๋ฅผ
๊ฑด๋๋๋๋ค.
์์ฒญ์ destination์ด
์คํฌ๋ฆฝํธ๋ฅ(script-like)์ด๋ฉด, ๊ฐ์ด "audioworklet",
"paintworklet", "script", "serviceworker",
"sharedworker", "worker" ์ค ํ๋์
๋๋ค.
์๊ณ ๋ฆฌ์ฆ์์ ์คํฌ๋ฆฝํธ๋ฅ๋ฅผ ์ฌ์ฉํ ๋๋ "xslt"๋ ์คํฌ๋ฆฝํธ ์คํ์ ์ ๋ฐํ ์ ์์์
๊ณ ๋ คํด์ผ ํฉ๋๋ค. ๋ค๋ง ํญ์ ๊ด๋ จ๋์ง ์์ผ๋ฉฐ ๋ณ๋ ๋์์ด ํ์ํ ์ ์์ด ๋ชฉ๋ก์ ํฌํจํ์ง ์์์ต๋๋ค.
๋ค์ ํ๋ ์์ฒญ์ initiator, destination, CSP ์ง์์ด, ๊ทธ๋ฆฌ๊ณ ๊ธฐ๋ฅ(feature) ๊ฐ์ ๊ด๊ณ๋ฅผ ๋ณด์ฌ์ค๋๋ค. ์ด ํ๋ ๋ชจ๋ ๊ธฐ๋ฅ์ ํฌ๊ดํ์ง ์์ต๋๋ค. ๊ฐ ๊ธฐ๋ฅ์ ํด๋น ํ์ค์์ ๊ด๋ จ ๊ฐ์ ์ ์ํด์ผ ํฉ๋๋ค.
| Initiator | Destination | CSP ์ง์์ด | ๊ธฐ๋ฅ(Features) |
|---|---|---|---|
| "" | "report"
| โ | CSP, NEL ๋ณด๊ณ ์. |
"document"
| HTML์ navigate ์๊ณ ๋ฆฌ์ฆ(์ต์์๋ง). | ||
"frame"
| child-src
| HTML์ <frame>
| |
"iframe"
| child-src
| HTML์ <iframe>
| |
| "" | connect-src
| navigator.sendBeacon(), EventSource,
HTML์ <a ping="">, <area ping="">,
fetch(), fetchLater(), XMLHttpRequest,
WebSocket,
WebTransport,
Cache API
| |
"object"
| object-src
| HTML์ <object>
| |
"embed"
| object-src
| HTML์ <embed>
| |
"audio"
| media-src
| HTML์ <audio>
| |
"font"
| font-src
| CSS์ @font-face
| |
"image"
| img-src
| HTML์ <img src>, /favicon.ico ๋ฆฌ์์ค,
SVG์ <image>, CSS์ background-image, CSS์
cursor, CSS์ list-style-image ๋ฑ
| |
"audioworklet"
| script-src
| audioWorklet.addModule()
| |
"paintworklet"
| script-src
| CSS.paintWorklet.addModule()
| |
"script"
| script-src
| HTML์ <script>, importScripts()
| |
"serviceworker"
| child-src, script-src, worker-src
| navigator.serviceWorker.register()
| |
"sharedworker"
| child-src, script-src, worker-src
| SharedWorker
| |
"webidentity"
| connect-src
| Federated Credential Management ์์ฒญ
| |
"worker"
| child-src, script-src, worker-src
| Worker
| |
"json"
| connect-src
| import "..." with { type: "json" }
| |
"style"
| style-src
| HTML์ <link rel=stylesheet>, CSS์ @import,
import "..." with { type: "css" }
| |
"text"
| connect-src
| import "..." with { type: "text" }
| |
"track"
| media-src
| HTML์ <track>
| |
"video"
| media-src
| HTML์ <video> ์์
| |
"download"
| "" | โ | HTML์ download="", "๋ค๋ฅธ ์ด๋ฆ์ผ๋ก ๋งํฌ ์ ์ฅโฆ" UI
|
"imageset"
| "image"
| img-src
| HTML์ <img srcset>, <picture>
|
"manifest"
| "manifest"
| manifest-src
| HTML์ <link rel=manifest>
|
"prefetch"
| "" | default-src (ํน์ ์ง์์ด ์์)
| HTML์ <link rel=prefetch>
|
"prerender"
| HTML์ <link rel=prerender>
| ||
"xslt"
| "xslt"
| script-src
| <?xml-stylesheet>
|
CSP์ form-action์ HTML์ navigate ๋๋ form ์ ์ถ ์๊ณ ๋ฆฌ์ฆ์ ์ง์ ์ฐ๊ฒฐ๋์ด์ผ ํฉ๋๋ค.
CSP๋ ๋ํ ๋ค์ํ CSP ์ง์์ด์ ๋ํด ์์ฒญ์ client์
global object์ ์ฐ๊ด Document์
์กฐ์ navigable์ ํ์ธํด์ผ ํฉ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
์ฐ์ ์์(priority)๋ฅผ ๊ฐ์ง๋๋ค. ๊ฐ์ "high", "low",
"auto" ์ค ํ๋์ด๋ฉฐ, ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด "auto"์
๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ ๋ด๋ถ ์ฐ์ ์์(internal priority)(null ๋๋ ๊ตฌํ ์ ์(implementation-defined) ๊ฐ์ฒด) ๊ฐ์ ๊ฐ์ง๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด null์ ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
origin์ ๊ฐ์ง๋๋ค. ๊ฐ์ "client" ๋๋ origin์
๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด "client"์
๋๋ค.
"client"๋ origin์ผ๋ก fetch ์ค์ ๋ณ๊ฒฝ๋ฉ๋๋ค. ์ด๋ฅผ ํตํด ํ์ค์์ ์์ฒญ์ origin์ ์ง์ ์ค์ ํ์ง ์์๋ ๋ฉ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ ์ต์์ navigation initiator origin(top-level navigation initiator origin)์ ๊ฐ์ง๋๋ค. ๊ฐ์ origin ๋๋ null์ ๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด null์ ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
policy container๋ฅผ ๊ฐ์ง๋๋ค. ๊ฐ์ "client" ๋๋ policy container์ด๋ฉฐ, ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด "client"์
๋๋ค.
"client"๋ policy container๋ก fetch ์ค์ ๋ณ๊ฒฝ๋ฉ๋๋ค. ์ด๋ฅผ ํตํด ํ์ค์์ ์์ฒญ์ policy
container๋ฅผ ์ง์ ์ค์ ํ์ง ์์๋ ๋ฉ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋
referrer๋ฅผ ๊ฐ์ง๋๋ค. ๊ฐ์ "no-referrer",
"client", ๋๋ URL์
๋๋ค. ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด "client"์
๋๋ค.
"client"๋ URL ๋๋
"no-referrer"๋ก fetch ์ค์ ๋ณ๊ฒฝ๋ฉ๋๋ค. ์ด๋ฅผ ํตํด ํ์ค์์ ์์ฒญ์ referrer๋ฅผ ์ง์ ์ค์ ํ์ง ์์๋ ๋ฉ๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ referrer policy๋ฅผ ๊ฐ์ง๋๋ค. ๊ฐ์ referrer policy์ด๋ฉฐ, ๋ณ๋์ ์ธ๊ธ์ด ์์ผ๋ฉด ๋น ๋ฌธ์์ด์ ๋๋ค. [REFERRER]
์ด ๊ฐ์ ํด๋น ์์ฒญ์ ์ฌ์ฉํ referrer policy๋ฅผ ๋ฎ์ด์ธ ๋ ์ฌ์ฉ๋ ์ ์์ต๋๋ค.
request๋
์ฐ๊ด๋
mode๋ฅผ ๊ฐ๊ณ ์์ผ๋ฉฐ,
์ด ๊ฐ์ "same-origin", "cors", "no-cors",
"navigate", "websocket", ๋๋ "webtransport" ์ค ํ๋์
๋๋ค.
๋ณ๋๋ก ๋ช
์๋์ง ์๋ ํ, ๊ธฐ๋ณธ๊ฐ์ "no-cors"์
๋๋ค.
- "
same-origin" - ๋์ผ ์ถ์ฒ URL์ ๋ํ ์์ฒญ์์ ๋ณด์ฅํฉ๋๋ค. fetch๋ ๋์ผ ์ถ์ฒ๊ฐ ์๋๋ฉด ๋คํธ์ํฌ ์ค๋ฅ(network error)๋ฅผ ๋ฐํํฉ๋๋ค.
- "
cors" - response tainting์ด "
cors"๋ก ์ค์ ๋ ์์ฒญ์ ์ฌ์ฉ๋๋ฉฐ, CORS ์์ฒญ์ด ๋์ด, fetch๋ ์์ฒญ๋ ๋ฆฌ์์ค๊ฐ CORS ํ๋กํ ์ฝ์ ์ดํดํ์ง ๋ชปํ๊ฑฐ๋ CORS ํ๋กํ ์ฝ์ ์ผ๋ถ๋ฌ ์ฐธ์ฌํ์ง ์๋ ๊ฒฝ์ฐ ๋คํธ์ํฌ ์ค๋ฅ๋ฅผ ๋ฐํํฉ๋๋ค. - "
no-cors" - CORS-์์ ๋ชฉ๋ก ๋ฉ์๋์ CORS-์์ ๋ชฉ๋ก ์์ฒญ ํค๋๋ง ์ฌ์ฉํ ์ ์๋๋ก ์ ํํฉ๋๋ค. ์ฑ๊ณต ์ fetch๋ opaque ํํฐ๋ง๋ ์๋ต์ ๋ฐํํฉ๋๋ค.
- "
navigate" - ๋ฌธ์ ๊ฐ ํ์(navigating)์๋ง ์ฌ์ฉ๋๋ ํน์ ๋ชจ๋์ ๋๋ค.
- "
websocket" - ์น์์ผ ์ฐ๊ฒฐ(WebSocket connection)์ ์ค์ ํ ๋๋ง ์ฌ์ฉ๋๋ ํน์ ๋ชจ๋์ ๋๋ค.
- "
webtransport" - ์ด๊ฒ์
WebTransport(url, options)์์๋ง ์ฌ์ฉ๋๋ ํน์ ๋ชจ๋์ ๋๋ค.
๊ธฐ๋ณธ ์์ฒญ์ mode๊ฐ
"no-cors"์ด๊ธฐ๋ ํ์ง๋ง,
ํ์ค์์๋ ์๋ก์ด ๊ธฐ๋ฅ์ ์ด ๋ชจ๋ ์ฌ์ฉ์ ์ ๊ทน ๊ถ์ฅํ์ง ์์ต๋๋ค. ์ด ๋ชจ๋๋ ์์ ํ์ง ์์ต๋๋ค.
์์ฒญ์ ์ฐ๊ด๋ use-CORS-preflight ํ๋๊ทธ๋ฅผ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ์ค์ ๋์ง ์์ ์ํ๋ค.
use-CORS-preflight ํ๋๊ทธ๊ฐ ์ค์ ๋ ๊ฒ์ CORS-ํ๋ฆฌํ๋ผ์ดํธ ์์ฒญ์ด ๋ฐ์ํ๋ ์ฌ๋ฌ ์กฐ๊ฑด ์ค
ํ๋์ด๋ค. use-CORS-preflight ํ๋๊ทธ๋ XMLHttpRequestUpload
๊ฐ์ฒด์ ํ๋ ์ด์์ ์ด๋ฒคํธ ๋ฆฌ์ค๋๊ฐ ๋ฑ๋ก๋์๊ฑฐ๋, ReadableStream
๊ฐ์ฒด๊ฐ ์์ฒญ์ ์ฌ์ฉ๋ ๊ฒฝ์ฐ ์ค์ ๋๋ค.
์์ฒญ์
์ฐ๊ด๋
credentials mode
๋ฅผ ๊ฐ์ง๋ค. ๊ฐ์ "omit", "same-origin", "include" ์ค ํ๋์ด๋ฉฐ, ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด
"same-origin"์ด๋ค.
- "
omit" - ์ด ์์ฒญ์ credentials๋ฅผ ํฌํจํ์ง ์์ผ๋ฉฐ, ์๋ต์ ํฌํจ๋ credentials๋ ๋ฌด์๋๋ค.
- "
same-origin" - ๋์ผ ์ถ์ฒ URL์ ๋ํ ์์ฒญ์๋ credentials๋ฅผ ํฌํจํ๊ณ , ๋์ผ ์ถ์ฒ ์๋ต์ ํฌํจ๋ credentials๋ ์ฌ์ฉํ๋ค.
- "
include" - ์ด ์์ฒญ์๋ ํญ์ credentials๋ฅผ ํฌํจํ๊ณ , ์๋ต์ ํฌํจ๋ credentials๋ ํญ์ ์ฌ์ฉํ๋ค.
์์ฒญ์ credentials mode๋ fetch ์ค credentials์ ํ๋ฆ์ ์ ์ดํ๋ค. ์์ฒญ์ mode๊ฐ "navigate"์ด๋ฉด
credentials mode๋ "include"๋ก ๊ฐ์ฃผ๋๋ฉฐ,
fetch๋ ํ์ฌ ๋ค๋ฅธ ๊ฐ์ ๊ณ ๋ คํ์ง ์๋๋ค.
HTML์ด ์ด ๋ถ๋ถ์ ๋ณ๊ฒฝํ๋ฉด ์ด ํ์ค๋ ๊ทธ์ ๋ง๊ฒ ๋ณ๊ฒฝ๋์ด์ผ ํ๋ค.
์์ฒญ์ ์ฐ๊ด๋ use-URL-credentials ํ๋๊ทธ ๋ฅผ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ์ค์ ๋์ง ์์ ์ํ๋ค.
์ด ํ๋๊ทธ๊ฐ ์ค์ ๋ ๊ฒฝ์ฐ, ์์ฒญ์ URL์ username๊ณผ password๊ฐ ์๊ณ , ํด๋น ์์ฒญ์ ์ฌ์ฉ ๊ฐ๋ฅํ ์ธ์ฆ ํญ๋ชฉ(authentication entry)์ด ์กด์ฌํ๋ค๋ฉด, URL์ credentials๊ฐ ์ธ์ฆ ํญ๋ชฉ์ credentials๋ณด๋ค ์ฐ์ ๋๋ค. ์ต์ ๋ช ์ธ์์๋ URL์ credentials๋ฅผ ๋ฃ๋ ๊ฒ์ ๊ถ์ฅํ์ง ์์ผ๋ฏ๋ก ์ด ํ๋๊ทธ๋ฅผ ์ ์ฌ์ฉํ์ง ์์ง๋ง, ๊ณผ๊ฑฐ ํธํ์ฑ ๋๋ฌธ์ ์ค์ ํ๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
์์ฒญ์
์ฐ๊ด๋
cache mode๋ฅผ ๊ฐ์ง๋ค. ๊ฐ์
"default", "no-store", "reload",
"no-cache", "force-cache", "only-if-cached" ์ค ํ๋์ด๋ฉฐ, ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด
"default"์ด๋ค.
- "
default" - fetch๋ ๋คํธ์ํฌ๋ก ๊ฐ๊ธฐ ์ ์ HTTP ์บ์๋ฅผ ๊ฒ์ฌํ๋ค. ์บ์์ ์ผ์นํ๋ fresh response๊ฐ ์์ผ๋ฉด ์ด๋ฅผ ๋ฐํํ๋ค. stale-while-revalidate response๊ฐ ์์ผ๋ฉด ๋ฐํ ํ ์กฐ๊ฑด๋ถ ๋คํธ์ํฌ fetch๋ก ์บ์๋ฅผ ๊ฐฑ์ ํ๋ค. stale response๊ฐ ์์ผ๋ฉด ์กฐ๊ฑด๋ถ ๋คํธ์ํฌ fetch๋ก ์บ์๋ฅผ ๊ฐฑ์ ํ๋ค. ์์ผ๋ฉด ์กฐ๊ฑด ์๋ ๋คํธ์ํฌ fetch๋ก ์บ์๋ฅผ ๊ฐฑ์ ํ๋ค. [HTTP] [HTTP-CACHING] [STALE-WHILE-REVALIDATE]
- "
no-store" - fetch๋ HTTP ์บ์๊ฐ ์ ํ ์๋ ๊ฒ์ฒ๋ผ ๋์ํ๋ค.
- "
reload" - fetch๋ ๋คํธ์ํฌ๋ก ๊ฐ๊ธฐ ์ HTTP ์บ์๊ฐ ์๋ ๊ฒ์ฒ๋ผ ๋์ํ๋ค. ์ฆ, ์ผ๋ฐ ์์ฒญ์ ๋ง๋ค๊ณ , ์๋ต์ผ๋ก ์บ์๋ฅผ ๊ฐฑ์ ํ๋ค.
- "
no-cache" - HTTP ์บ์์ ์๋ต์ด ์์ผ๋ฉด ์กฐ๊ฑด๋ถ ์์ฒญ์, ์์ผ๋ฉด ์ผ๋ฐ ์์ฒญ์ ๋ง๋ ๋ค. ๊ทธ๋ฐ ๋ค ์๋ต์ผ๋ก ์บ์๋ฅผ ๊ฐฑ์ ํ๋ค.
- "
force-cache" - HTTP ์บ์์ ํด๋น ์์ฒญ์ ์ผ์นํ๋ ์๋ต์ด ์์ผ๋ฉด ๋ฌด์กฐ๊ฑด ์ฌ์ฉํ๋ค(์ค๋๋๋์ง ์ ๊ฒฝ์ฐ์ง ์์). ์์ผ๋ฉด ์ผ๋ฐ ์์ฒญ์ ๋ง๋ค๊ณ , ์๋ต์ผ๋ก ์บ์๋ฅผ ๊ฐฑ์ ํ๋ค.
- "
only-if-cached" - HTTP ์บ์์ ํด๋น ์์ฒญ์ ์ผ์นํ๋ ์๋ต์ด ์์ผ๋ฉด ๋ฌด์กฐ๊ฑด ์ฌ์ฉํ๋ค(์ค๋๋๋์ง ์ ๊ฒฝ์ฐ์ง ์์). ์์ผ๋ฉด ๋คํธ์ํฌ ์ค๋ฅ๋ฅผ ๋ฐํํ๋ค. (์์ฒญ์ mode๊ฐ
"
same-origin"์ผ ๋๋ง ์ฌ์ฉ ๊ฐ๋ฅ. ์บ์๋ ๋ฆฌ๋ค์ด๋ ํธ๋ ์์ฒญ์ redirect mode๊ฐ "follow"์ด๊ณ ๋ฆฌ๋ค์ด๋ ํธ๊ฐ ์์ฒญ์ mode๋ฅผ ์๋ฐํ์ง ์์ผ๋ฉด ๋ฐ๋ผ๊ฐ.)
ํค๋
๋ชฉ๋ก์ด ๋ค์ ์ค
ํ๋๋ฅผ ํฌํจํ๋ฉด:
`If-Modified-Since`,
`If-None-Match`,
`If-Unmodified-Since`,
`If-Match`, ๋๋
`If-Range`,
fetch๋
cache
mode๊ฐ "default"๋ผ๋ฉด "no-store"๋ก ์ค์ ํ๋ค.
์์ฒญ์
์ฐ๊ด๋
redirect mode๋ฅผ ๊ฐ์ง๋ค.
๊ฐ์ "follow", "error", "manual" ์ค ํ๋์ด๋ฉฐ, ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด
"follow"์ด๋ค.
- "
follow" - ๋ฆฌ์์ค๋ฅผ ํจ์นญํ ๋ ๋ฐ์ํ๋ ๋ชจ๋ ๋ฆฌ๋ค์ด๋ ํธ๋ฅผ ๋ฐ๋ฅธ๋ค.
- "
error" - ์์ฒญ์ด ๋ฆฌ๋ค์ด๋ ํธ์ ๋ถ๋ชํ๋ฉด ๋คํธ์ํฌ ์ค๋ฅ(network error)๋ฅผ ๋ฐํํ๋ค.
- "
manual" - ์์ฒญ์ด ๋ฆฌ๋ค์ด๋ ํธ์ ๋ถ๋ชํ๋ฉด ์๋น์ค ์์ปค๊ฐ ์คํ๋ผ์ธ์ผ๋ก ๋ฆฌ๋ค์ด๋ ํธ๋ฅผ ์ฌ์ํ ์ ์๋๋ก opaque-redirect ํํฐ๋ง๋ ์๋ต์ ๊ฐ์ ธ์จ๋ค. ์ด ์๋ต์ ๋คํธ์ํฌ ์ค๋ฅ์ ๊ตฌ๋ณํ ์ ์๋ค. (์์์ HTTP ๋ฆฌ๋ค์ด๋ ํธ ์ฒ๋ฆฌ๋ฅผ ์๋ฐํ์ง ์๊ธฐ ์ํด.)
์์ฒญ์ ์ฐ๊ด๋ integrity metadata (๋ฌธ์์ด)์ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ๋น ๋ฌธ์์ด์ด๋ค.
์์ฒญ์ ์ฐ๊ด๋ ์ํธํ์ nonce metadata(cryptographic nonce metadata) (๋ฌธ์์ด)์ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ๋น ๋ฌธ์์ด์ด๋ค.
์์ฒญ์
์ฐ๊ด๋
ํ์ ๋ฉํ๋ฐ์ดํฐ(parser metadata)
๋ฅผ ๊ฐ์ง๋ค. ๊ฐ์ ๋น ๋ฌธ์์ด, "parser-inserted", "not-parser-inserted" ์ค ํ๋์ด๋ฉฐ, ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ๋น
๋ฌธ์์ด์ด๋ค.
์์ฒญ์ ์ํธํ์ nonce metadata์ ํ์ ๋ฉํ๋ฐ์ดํฐ๋ ์ผ๋ฐ์ ์ผ๋ก ํด๋น ์์ฒญ์ ์์ฑํ HTML ์์์ ์์ฑ ๋ฐ ํ๋๊ทธ์์ ์ฑ์์ง๋ค. ์ด๋ ์ฝํ ์ธ ๋ณด์ ์ ์ฑ (Content Security Policy)์ ์ฌ๋ฌ ์๊ณ ๋ฆฌ์ฆ์์ ํน์ ๋งฅ๋ฝ์์ ์์ฒญ ๋๋ ์๋ต์ ์ฐจ๋จํ ์ง ํ๋จํ๋ ๋ฐ ์ฌ์ฉ๋๋ค. [CSP]
์์ฒญ์ ์ฐ๊ด๋ reload-navigation ํ๋๊ทธ ๋ฅผ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ์ค์ ๋์ง ์์ ์ํ๋ค.
์ด ํ๋๊ทธ๋ HTML์ navigate ์๊ณ ๋ฆฌ์ฆ์์๋ง ์ฌ์ฉ๋๋ค. [HTML]
์์ฒญ์ ์ฐ๊ด๋ history-navigation ํ๋๊ทธ ๋ฅผ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด ์ค์ ๋์ง ์์ ์ํ๋ค.
์ด ํ๋๊ทธ๋ HTML์ navigate ์๊ณ ๋ฆฌ์ฆ์์๋ง ์ฌ์ฉ๋๋ค. [HTML]
์์ฒญ์ ์ฐ๊ด๋ ๋ถ๋ฆฌ์ธ user-activation ์ ๊ฐ์ง๋ค. ๋ณ๋ ์ธ๊ธ์ด ์์ผ๋ฉด false๋ค.
์ด ๊ฐ์ HTML์ navigate ์๊ณ ๋ฆฌ์ฆ์์๋ง ์ฌ์ฉ๋๋ค. [HTML]
request์๋ WebDriver navigation id (null ๋๋ ๋ฌธ์์ด)์ด ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ null์ ๋๋ค.
์ด ๊ฐ์ HTML์ navigate ์๊ณ ๋ฆฌ์ฆ์์๋ง ๋ ์ ์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค. [HTML]
request์๋ boolean ํ์ ์ render-blocking์ด ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ false์ ๋๋ค.
์ด ํ๋๊ทธ๋ HTML์ render-blocking ๋ฉ์ปค๋์ฆ์์๋ง ๋ ์ ์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค. [HTML]
request์๋ WebTransport-hash list (WebTransport-hash list)๊ฐ ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์์ผ๋ฉด ยซ ยป์ ๋๋ค.
WebTransport-hash list๋ ๋ฆฌ์คํธ๋ก, 0๊ฐ ์ด์์ WebTransport-hashes๋ก ๊ตฌ์ฑ๋ฉ๋๋ค.
WebTransport-hash๋ ํํ์ด๋ฉฐ, algorithm (๋ฌธ์์ด)๊ณผ value (๋ฐ์ดํธ ์ํ์ค)๋ก ๊ตฌ์ฑ๋ฉ๋๋ค.
์ด ๋ฆฌ์คํธ๋ WebTransport(url, options)๊ฐ
options์ serverCertificateHashes
๋ฅผ ํฌํจํ ๋์๋ง ๋
์ ์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.
request์๋ URL list (ํ๋ ์ด์์ URL๋ก ์ด๋ฃจ์ด์ง ๋ฆฌ์คํธ)๊ฐ ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, request์ URL์ ๋ณต์ฌ๋ณธ ํ๋๋ฅผ ํฌํจํ๋ ๋ฆฌ์คํธ์ ๋๋ค.
์์ฒญ ์๋ ์ฐ๊ด๋ ํ์ฌ URL ์ด ์์ต๋๋ค. ์ด๋ ์์ฒญ ์ URL ๋ฆฌ์คํธ ์์ ๋ง์ง๋ง URL ์ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ์ ๋๋ค.
request์๋ redirect count๊ฐ ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ 0์ ๋๋ค.
request์๋
response tainting์ด ์ฐ๊ด๋์ด ์์ต๋๋ค.
์ด๋ "basic", "cors", "opaque" ์ค ํ๋์
๋๋ค.
๋ฌ๋ฆฌ ๋ช
์๋์ง ์๋ ํ, "basic"์
๋๋ค.
request์๋ prevent no-cache cache-control header modification flag๊ฐ ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ์ค์ ๋์ง ์์ต๋๋ค.
request์๋ done flag๊ฐ ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ์ค์ ๋์ง ์์ต๋๋ค.
request์๋ timing allow failed flag๊ฐ ์ฐ๊ด๋์ด ์์ต๋๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ์ค์ ๋์ง ์์ต๋๋ค.
A ์์ฒญ์๋ ์ฐ๊ด๋ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก(๋ชฉ๋ก์ ๋ชฉ๋ก์ผ๋ก, ๋ฌธ์์ด๋ก ์ด๋ฃจ์ด์ง)์ด ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ยซ ยป์ด๋ค.
ํญ๋ชฉ ๊ฐ๊ฐ์ ๋ด๋น๊ฒ์ด์
ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์์
๋ด๋น๊ฒ์ด์
์ ๋ฆฌ๋๋ ์
์ฒด์ธ์ ์๋ ํ๋์ ๋ฆฌ๋๋ ์
์๋ต์
`Timing-Allow-Origin` ๊ฐ์ ๋ณด๊ดํ๋ค.
์์ฒญ์ URL ๋ชฉ๋ก, ํ์ฌ URL, ๋ฆฌ๋๋ ์ ํ์, ์๋ต ์ค์ผ, ์๋ฃ ํ๋๊ทธ, ํ์ด๋ฐ ํ์ฉ ์คํจ ํ๋๊ทธ, ๊ทธ๋ฆฌ๊ณ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ fetch ์๊ณ ๋ฆฌ์ฆ์์ ์ฅ๋ถ ๊ธฐ์ ์ธ๋ถ ์ ๋ณด๋ก ์ฌ์ฉ๋๋ค.
A ์์ฒญ์๋ ์ฐ๊ด๋ WebDriver id๊ฐ ์์ผ๋ฉฐ, ์ด๋ ๋ฌด์์ UUID๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก, ์์ฒญ์ด ์์ฑ๋ ๋ ์ค์ ๋๋ค. [WEBCRYPTO]
WebDriver id๋ WebDriver-BiDi์์ ์ฌ์ฉ๋๋ค. ์ด๋ ๋ฆฌ๋๋ ์ , ์ธ์ฆ ์๋, ๊ทธ๋ฆฌ๊ณ ์ต์ด ์์ฒญ์ CORS-preflight fetch ์ ๋ฐ์ ๊ฑธ์ณ ์ผ์ ํ๊ฒ ์ ์ง๋๋ค. ์์ฒญ์ด ๋ณต์ ๋ ๋, ์์ฑ๋ ์์ฒญ์ ๊ณ ์ ํ WebDriver id๋ฅผ ๊ฐ๋๋ค. [WEBDRIVER-BIDI]
A ํ์ ๋ฆฌ์์ค ์์ฒญ์
์์ฒญ์ผ๋ก,
๊ทธ ๋ชฉ์ ์ง๊ฐ "audio",
"audioworklet",
"font", "image", "json", "manifest",
"paintworklet", "script", "style", "text",
"track", "video", "xslt", ๋๋ ๋น ๋ฌธ์์ด์ธ ๊ฒ์ด๋ค.
A ๋น-ํ์ ๋ฆฌ์์ค
์์ฒญ์ ์์ฒญ์ผ๋ก,
๊ทธ ๋ชฉ์ ์ง๊ฐ "document",
"embed",
"frame", "iframe", "object", "report",
"serviceworker", "sharedworker", ๋๋ "worker"์ธ ๊ฒ์ด๋ค.
A ๋ด๋น๊ฒ์ด์
์์ฒญ์
์์ฒญ์ผ๋ก, ๊ทธ
๋ชฉ์ ์ง๊ฐ
"document", "embed", "frame", "iframe",
๋๋ "object"์ธ ๊ฒ์ด๋ค.
์ด ์ฉ์ด๋ค์ ์ฌ์ฉ์ ๋ํด์๋ handle fetch๋ฅผ ์ฐธ์กฐํ๋ผ. [SW]
์์ฒญ
request์
redirect-taint๋ฅผ ๊ณ์ฐํ๋ ค๋ฉด
๋ค์ ๋จ๊ณ๋ฅผ ์ํํ๋ค. ์ด ๋จ๊ณ๋ค์
"same-origin", "same-site", ๋๋ "cross-site"๋ฅผ ๋ฐํํ๋ค.
-
lastURL์ null๋ก ๋๋ค.
-
taint๋ฅผ "
same-origin"์ผ๋ก ๋๋ค. -
request์ URL ๋ชฉ๋ก์ ์๋ ๊ฐ url์ ๋ํด For each:
-
lastURL์ด null์ด๋ฉด, lastURL์ url๋ก ์ค์ ํ๊ณ continueํ๋ค.
-
url์ origin์ด lastURL์ origin๊ณผ same site๊ฐ ์๋๊ณ , request์ origin๋ lastURL์ origin๊ณผ same site๊ฐ ์๋๋ฉด, "
cross-site"๋ฅผ ๋ฐํํ๋ค. -
url์ origin์ด lastURL์ origin๊ณผ same origin์ด ์๋๊ณ , request์ origin๋ lastURL์ origin๊ณผ same origin์ด ์๋๋ฉด, taint๋ฅผ "
same-site"๋ก ์ค์ ํ๋ค. -
lastURL์ url๋ก ์ค์ ํ๋ค.
-
-
taint๋ฅผ ๋ฐํํ๋ค.
์์ฒญ request๊ฐ ์ฃผ์ด์ก์ ๋, ์์ฒญ ์ถ์ฒ ์ง๋ ฌํํ๊ธฐ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ ๊ฒ์ด๋ค:
-
request์ redirect-taint๊ฐ "
same-origin"์ด ์๋๋ฉด, "null"์ ๋ฐํํ๋ค.
์์ฒญ request๊ฐ ์ฃผ์ด์ก์ ๋, ์์ฒญ ์ถ์ฒ ๋ฐ์ดํธ ์ง๋ ฌํํ๊ธฐ๋ request๋ก ์์ฒญ ์ถ์ฒ ์ง๋ ฌํํ๊ธฐ๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ฅผ ๋ํ ์ธ์ฝ๋ฉํ ๊ฐ์ ๋ฐํํ๋ ๊ฒ์ด๋ค.
์์ฒญ request๋ฅผ ๋ณต์ ํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
newRequest๋ฅผ request์ ์ฌ๋ณธ์ผ๋ก ๋๋, ๊ทธ body ์ WebDriver id๋ ์ ์ธํ๋ค.
-
newRequest์ WebDriver id๋ฅผ ๋ฌด์์ UUID๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. [WEBCRYPTO]
-
request์ body๊ฐ null์ด ์๋๋ฉด, newRequest์ body ๋ฅผ request์ body๋ฅผ ๋ณต์ ํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
newRequest๋ฅผ ๋ฐํํ๋ค.
์์ฒญ request์ ์ ์ first์ ์ ํ์ ์ ์ last๋ฅผ ์ฌ์ฉํ์ฌ range header๋ฅผ ์ถ๊ฐํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
Assert: last๊ฐ ์ฃผ์ด์ง์ง ์์๊ฑฐ๋, first๊ฐ last๋ณด๋ค ์๊ฑฐ๋ ๊ฐ๋ค.
-
rangeValue๋ฅผ `
bytes=`๋ก ๋๋ค. -
first๋ฅผ ์ง๋ ฌํํ๊ณ ๋ํ ์ธ์ฝ๋ฉํ ๋ค, ๊ทธ ๊ฒฐ๊ณผ๋ฅผ rangeValue์ ๋ง๋ถ์ธ๋ค.
-
0x2D (-)๋ฅผ rangeValue์ ๋ง๋ถ์ธ๋ค.
-
last๊ฐ ์ฃผ์ด์ก๋ค๋ฉด, ์ด๋ฅผ ์ง๋ ฌํํ๊ณ ๋ํ ์ธ์ฝ๋ฉํ ๋ค, ๊ทธ ๊ฒฐ๊ณผ๋ฅผ rangeValue์ ๋ง๋ถ์ธ๋ค.
-
(`
Range`, rangeValue)๋ฅผ request์ ํค๋ ๋ชฉ๋ก์ ๋ง๋ถ์ธ๋ค.
range header๋ ํฌํจ์ ๋ฐ์ดํธ ๋ฒ์๋ฅผ ๋ํ๋ธ๋ค. ๋ฐ๋ผ์ first๊ฐ 0์ด๊ณ last๊ฐ 500์ธ range header๋ 501๋ฐ์ดํธ ๋ฒ์์ด๋ค.
์ฌ๋ฌ ์๋ต์ ํ๋์ ๋ ผ๋ฆฌ์ ๋ฆฌ์์ค๋ก ๊ฒฐํฉํ๋ ๊ธฐ๋ฅ์ ์ญ์ฌ์ ์ผ๋ก ๋ณด์ ๋ฒ๊ทธ์ ์์ธ์ด ๋์ด ์๋ค. ๋ถ๋ถ ์๋ต์ ๋ค๋ฃจ๋ ๊ธฐ๋ฅ์ ๋ํด์๋ ๋ณด์ ๊ฒํ ๋ฅผ ์์ฒญํ๋ผ.
์๋ต response๊ฐ ์ฃผ์ด์ก์ ๋, ๋ณด๊ณ ์ฉ ์๋ต URL ์ง๋ ฌํํ๊ธฐ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ ๊ฒ์ด๋ค:
-
Assert: response์ URL ๋ชฉ๋ก์ ๋น์ด ์์ง ์๋ค.
-
url์ response์ URL ๋ชฉ๋ก[0]์ ์ฌ๋ณธ์ผ๋ก ๋๋ค.
์ด๋ ๋ฆฌ๋๋ ์ ๋์์ ๊ดํ ์ ๋ณด ๋์ถ์ ํผํ๊ธฐ ์ํด response์ URL์ด ์๋๋ค(๋ค์์ CSP ๋ณด๊ณ ์ ๋ํ ์ ์ฌํ ๊ณ ๋ ค ์ฌํญ ๋ ์ฐธ์กฐ). [CSP]
-
์ฃผ์ด์ง url์ ๋ํด ์ฌ์ฉ์ ์ด๋ฆ์ ์ค์ ํ๋ ๋น ๋ฌธ์์ด๋ก ์ค์ ํ๋ค.
-
์ฃผ์ด์ง url์ ๋ํด ๋น๋ฐ๋ฒํธ๋ฅผ ์ค์ ํ๋ ๋น ๋ฌธ์์ด๋ก ์ค์ ํ๋ค.
-
fragment ์ ์ธ๋ฅผ true๋ก ์ค์ ํ์ฌ url์ ์ง๋ ฌํ๋ฅผ ๋ฐํํ๋ค.
์์ฒญ request๊ฐ ์ฃผ์ด์ก์ ๋, Cross-Origin-Embedder-Policy๊ฐ ์๊ฒฉ ์ฆ๋ช ์ ํ์ฉํ๋์ง ํ์ธํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
request์ mode๊ฐ "
no-cors"๊ฐ ์๋๋ฉด, true๋ฅผ ๋ฐํํ๋ค. -
request์ client๊ฐ null์ด๋ฉด, true๋ฅผ ๋ฐํํ๋ค.
-
request์ client์ policy container์ embedder policy์ value๊ฐ "
credentialless"๊ฐ ์๋๋ฉด, true๋ฅผ ๋ฐํํ๋ค. -
request์ ์ค๋ฆฌ์ง์ด ๋์ผ ์ค๋ฆฌ์ง์ผ๋ก request์ ํ์ฌ URL์ ์ค๋ฆฌ์ง๊ณผ ๊ฐ๊ณ request์ ๋ฆฌ๋๋ ์ ์ค์ผ์ด "
same-origin"์ด๋ฉด true๋ฅผ ๋ฐํํฉ๋๋ค. -
false๋ฅผ ๋ฐํํ๋ค.
2.2.6. ์๋ต
The result of fetch is a ์๋ต. ์๋ต์ ์๊ฐ์ด ์ง๋๋ฉด์ ๋ฐ์ ํ๋ค. ์ฆ, ๊ทธ ๋ชจ๋ ํ๋๊ฐ ์ฆ์ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ฒ์ ์๋๋ค.
์๋ต์๋
์ฐ๊ด๋
type์ด ์์ผ๋ฉฐ, ์ด๋
"basic",
"cors",
"default",
"error",
"opaque", ๋๋
"opaqueredirect"์ด๋ค.
๋ฌ๋ฆฌ ๋ช
์๋์ง ์๋ ํ, ์ด๋ "default"์ด๋ค.
์๋ต์ ์ฐ๊ด๋ aborted flag๋ฅผ ๊ฐ์ง ์ ์์ผ๋ฉฐ, ์ด๋ ์ฒ์์๋ ์ค์ ๋์ง ์๋๋ค.
์ด๋ ์์ฒญ์ด ๊ฐ๋ฐ์ ๋๋ ์ต์ข ์ฌ์ฉ์์ ์ํด ์๋์ ์ผ๋ก ์ค๋จ๋์์์ ๋ํ๋ธ๋ค.
์๋ต์๋ ์ฐ๊ด๋ URL์ด ์๋ค. ์ด๋ ์๋ต์ URL ๋ชฉ๋ก์ ์๋ ๋ง์ง๋ง URL์ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ์ด๋ฉฐ, ์๋ต์ URL ๋ชฉ๋ก์ด ๋น์ด ์์ผ๋ฉด null์ด๋ค.
์๋ต์๋ ์ฐ๊ด๋ URL ๋ชฉ๋ก(0๊ฐ ์ด์์ URL๋ก ์ด๋ฃจ์ด์ง ๋ชฉ๋ก)์ด ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ยซ ยป์ด๋ค.
์๋ ๊ฒฝ์ฐ ์ฒซ ๋ฒ์งธ์ ๋ง์ง๋ง URL์ ์ ์ธํ๋ฉด, ์๋ต์ URL ๋ชฉ๋ก์ ์คํฌ๋ฆฝํธ์ ์ง์ ๋ ธ์ถ๋์ง ์๋๋ค. ๊ทธ๋ ๊ฒ ํ๋ฉด ์์์ HTTP ๋ฆฌ๋๋ ์ ์ฒ๋ฆฌ๋ฅผ ์๋ฐํ๊ธฐ ๋๋ฌธ์ด๋ค.
์๋ต์๋ ์ฐ๊ด๋ status๊ฐ ์์ผ๋ฉฐ, ์ด๋ status์ด๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ ์ด๋ 200์ด๋ค.
์๋ต์๋ ์ฐ๊ด๋ status message๊ฐ ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ ์ด๋ ๋น ๋ฐ์ดํธ ์ํ์ค์ด๋ค.
HTTP/2 ์ฐ๊ฒฐ์ ํตํ ์๋ต์ HTTP/2๊ฐ ์ด๋ฅผ ์ง์ํ์ง ์์ผ๋ฏ๋ก ํญ์ ๋น ๋ฐ์ดํธ ์ํ์ค๋ฅผ status message๋ก ๊ฐ์ง๋ค.
์๋ต์๋ ์ฐ๊ด๋ ํค๋ ๋ชฉ๋ก( ํค๋ ๋ชฉ๋ก)์ด ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ ์ด๋ ยซ ยป์ด๋ค.
์๋ต์๋ ์ฐ๊ด๋ body(null ๋๋ body)๊ฐ ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ ์ด๋ null์ด๋ค.
๋คํธ์ํฌ์ ์๋ต์ body์ ๋ํ source ๋ฐ length ๊ฐ๋ ์ ํญ์ null์ด๋ค.
์๋ต์๋
์ฐ๊ด๋
cache state(๋น ๋ฌธ์์ด,
"local", ๋๋ "validated")๊ฐ ์๋ค. ๋ฌ๋ฆฌ ๋ช
์๋์ง ์๋ ํ, ์ด๋ ๋น
๋ฌธ์์ด์ด๋ค.
์ด๋ Service Workers ๋ฐ Resource Timing์์ ์ฌ์ฉํ๋๋ก ์๋๋ ๊ฒ์ด๋ค. [SW] [RESOURCE-TIMING]
์๋ต์๋ ์ฐ๊ด๋ CORS-exposed header-name ๋ชฉ๋ก (0๊ฐ ์ด์์ header name์ผ๋ก ์ด๋ฃจ์ด์ง ๋ชฉ๋ก)์ด ์๋ค. ์ด ๋ชฉ๋ก์ ๋ฌ๋ฆฌ ์ง์ ๋์ง ์๋ ํ ๋น์ด ์๋ค.
์๋ต์ ์ผ๋ฐ์ ์ผ๋ก
`Access-Control-Expose-Headers` ํค๋์์
ํค๋
๊ฐ์ ์ถ์ถํ์ฌ
๊ทธ CORS-exposed header-name ๋ชฉ๋ก์ ์ค์ ํ๋ค.
์ด ๋ชฉ๋ก์
CORS ํํฐ๋ง๋ ์๋ต์ด ์ด๋ค ํค๋๋ฅผ
๋
ธ์ถํ ์ง ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉ๋๋ค.
์๋ต์๋ ์ฐ๊ด๋ range-requested flag๊ฐ ์์ผ๋ฉฐ, ์ด๋ ์ฒ์์๋ ์ค์ ๋์ง ์๋๋ค.
์ด๋ ์ด์ ์ ๋ฒ์ ์์ฒญ์์ ์จ ๋ถ๋ถ ์๋ต์ด ๋ฒ์ ์์ฒญ์ ํ์ง ์์ API์ ์ ๊ณต๋๋ ๊ฒ์ ๋ฐฉ์งํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ค. ๊ณต๊ฒฉ์ ๋ํ ์์ธํ ์ค๋ช ์ ์ด ํ๋๊ทธ์ ์ฌ์ฉ์ฒ๋ฅผ ์ฐธ์กฐํ๋ผ.
์๋ต์๋ ์ฐ๊ด๋ request-includes-credentials (๋ถ๋ฆฌ์ธ)์ด ์์ผ๋ฉฐ, ์ด๋ ์ฒ์์๋ true์ด๋ค.
์๋ต์๋ ์ฐ๊ด๋ timing allow passed flag๊ฐ ์์ผ๋ฉฐ, ์ด๋ ์ฒ์์๋ ์ค์ ๋์ง ์๋๋ค.
์ด๋ fetch ํธ์ถ์๊ฐ ๋ฐํ๋ ์๋ต์ ํ๋๊ทธ๋ฅผ ํ์ธํ์ฌ ๊ฐ์ ธ์จ ๋ฆฌ์์ค์์ ๋ฏผ๊ฐํ ํ์ด๋ฐ ๋ฐ์ดํฐ๊ฐ ํ์ฉ๋๋์ง ๊ฒฐ์ ํ ์ ์๋๋ก ํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ค. ๋ฆฌ๋๋ ์ ์ ์๋ต์ ์๋ ํ๋๊ทธ๋ ๋ฆฌ๋๋ ์ ์ฒด์ธ์ ์ด์ ์๋ต๋ค์ ๋ํด ์ค์ ๋์๋ค๋ฉด ์ค์ ๋์ด์ผ ํ๋ฏ๋ก, ์ด๋ ์์ฒญ์ timing allow failed flag๋ฅผ ์ฌ์ฉํ์ฌ ๋ด๋ถ์ ์ผ๋ก๋ ์ถ์ ๋๋ค.
์๋ต์๋ ์ฐ๊ด๋ navigation timing allow values list(๋ชฉ๋ก์ ๋ชฉ๋ก์ผ๋ก, ๋ฌธ์์ด๋ก ์ด๋ฃจ์ด์ง)์ด ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ยซ ยป์ด๋ค.
์ด๋ ๋ด๋น๊ฒ์ด์
์ ๋ฆฌ๋๋ ์
์ฒด์ธ์ ์๋ ๊ฐ ๋ฆฌ๋๋ ์
์๋ต์
`Timing-Allow-Origin` ๊ฐ์ ๋ณด๊ดํ๋ค. ์ด๋ ๋ด๋น๊ฒ์ด์
์ ๋ชฉ์ ์ง origin์ ์๊ฒ ๋์์ ๋,
ํธ์ถ์๋ค์ด ํด๋น origin์ด ๋ฆฌ๋๋ ์
์ฒด์ธ์ ๋ชจ๋ ๋ฆฌ๋๋ ์
์์ ํ์ฉ๋๋์ง ํ๋จํ ์ ์๋๋ก ํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ค.
์๋ต์๋ ์ฐ๊ด๋ body info (response body info)๊ฐ ์๋ค. ๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ, ์ด๋ ์ response body info์ด๋ค.
์๋ต์๋ ์ฐ๊ด๋ service worker timing info(null ๋๋ service worker timing info)๊ฐ ์์ผ๋ฉฐ, ์ด๋ ์ฒ์์๋ null์ด๋ค.
์๋ต์๋
์ฐ๊ด๋ redirect taint
("same-origin", "same-site", ๋๋ "cross-site")๊ฐ ์์ผ๋ฉฐ, ์ด๋
์ฒ์์๋ "same-origin"์ด๋ค.
network error๋
์๋ต์ผ๋ก, ๊ทธ
type์
"error", status๋ 0,
status message๋ ๋น ๋ฐ์ดํธ ์ํ์ค,
ํค๋
๋ชฉ๋ก์ ยซ ยป, body๋ null, ๊ทธ๋ฆฌ๊ณ
body
info๋ ์ response
body info์ธ ๊ฒ์ด๋ค.
aborted network error๋ network error๋ก, ๊ทธ aborted flag๊ฐ ์ค์ ๋ ๊ฒ์ด๋ค.
fetch params fetchParams๊ฐ ์ฃผ์ด์ก์ ๋ appropriate network error๋ฅผ ๋ง๋ค๋ ค๋ฉด:
-
fetchParams๊ฐ ์ค๋จ๋์์ผ๋ฉด aborted network error๋ฅผ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด network error๋ฅผ ๋ฐํํ๋ค.
ํํฐ๋ง๋ ์๋ต์ ์ฐ๊ด๋ ์๋ต์ ๋ํด ์ ํ๋ ๋ทฐ๋ฅผ ์ ๊ณตํ๋ ์๋ต์ด๋ค. ์ด ์ฐ๊ด๋ ์๋ต์ ํํฐ๋ง๋ ์๋ต์ ๋ด๋ถ ์๋ต( ์๋ต์ผ๋ก, network error๋ ์๋๊ณ ํํฐ๋ง๋ ์๋ต๋ ์๋ ๊ฒ)์ ํตํด ์ ๊ทผํ ์ ์๋ค.
๋ฌ๋ฆฌ ๋ช ์๋์ง ์๋ ํ ํํฐ๋ง๋ ์๋ต์ ์ฐ๊ด๋ ๊ฐ๋ ๋ค(์: ๊ทธ body)์ ๊ทธ ๋ด๋ถ ์๋ต์ ์ฐ๊ด๋ ๊ฐ๋ ๋ค์ ์ฐธ์กฐํ๋ค. (์ด์ ๋ํ ์์ธ๋ ์๋์์ ํํฐ๋ง๋ ์๋ต์ ๊ตฌ์ฒด์ ์ธ ํ์ ์ ์ ์ํ๋ ๋ถ๋ถ์ ๋์ด๋์ด ์๋ค.)
fetch ์๊ณ ๋ฆฌ์ฆ์ processResponse์ ๋๋ฑํ ๋งค๊ฐ๋ณ์๋ฅผ ํตํด ํํฐ๋ง๋ ์๋ต์ ํธ์ถ์์๊ฒ ๋ ธ์ถํ์ฌ ์ ๋ณด๊ฐ ์ฐ๋ฐ์ ์ผ๋ก ๋์ถ๋์ง ์๋๋ก ๋ณด์ฅํ๋ค. ๋ ๊ฑฐ์ ์ด์ ๋ก ์ ๋ณด๊ฐ ๊ณต๊ฐ๋์ด์ผ ํ๋ ๊ฒฝ์ฐ, ์๋ฅผ ๋ค์ด ์ด๋ฏธ์ง ๋ฐ์ดํฐ๋ฅผ ๋์ฝ๋์ ๊ณต๊ธํด์ผ ํ๋ ๊ฒฝ์ฐ์๋, ์ฐ๊ด๋ ๋ด๋ถ ์๋ต์ ๋ช ์ธ ์๊ณ ๋ฆฌ์ฆ์์ ์ฌ์ฉํ ์ ์๋ค.
์ ๋ช ์ธ๋ opaque ํํฐ๋ง๋ ์๋ต์ด๋ opaque-redirect ํํฐ๋ง๋ ์๋ต์ ๋ ์ด์ ๊ธฐ๋ฐ์ผ๋ก ์ผ์์๋ ์ ๋๋ค. ์ด๋ค์ ๋ ๊ฑฐ์ ๊ตฌ์ฑ๋ฌผ์ด๋ฉฐ ํ๋ ์ปดํจํฐ ์ํคํ ์ฒ๋ฅผ ๊ณ ๋ คํ ๋ ํญ์ ์ถฉ๋ถํ ๋ณดํธ๋ ์ ์๋ ๊ฒ์ ์๋๋ค.
basic
ํํฐ๋ง๋ ์๋ต์
ํํฐ๋ง๋
์๋ต์ผ๋ก, ๊ทธ
type์ด
"basic"์ด๊ณ
ํค๋
๋ชฉ๋ก์ด
๋ด๋ถ
์๋ต์
ํค๋
๋ชฉ๋ก์ ์๋
ํค๋ ์ค์์
๊ทธ name์ด
forbidden response-header name์ธ ๊ฒ์ ์ ์ธํ ๊ฒ์ด๋ค.
CORS ํํฐ๋ง๋
์๋ต์
ํํฐ๋ง๋
์๋ต์ผ๋ก, ๊ทธ
type์ด
"cors"์ด๊ณ
ํค๋
๋ชฉ๋ก์ด
๋ด๋ถ
์๋ต์
ํค๋
๋ชฉ๋ก์ ์๋
ํค๋ ์ค์์
๊ทธ name์ด
์ฃผ์ด์ง ๋ด๋ถ
์๋ต์
CORS-exposed header-name ๋ชฉ๋ก์ ๋ํ
CORS-safelisted response-header name์ด
์๋ ๊ฒ์ ์ ์ธํ ๊ฒ์ด๋ค.
opaque
ํํฐ๋ง๋ ์๋ต์
ํํฐ๋ง๋
์๋ต์ผ๋ก, ๊ทธ
type์ด
"opaque",
URL
๋ชฉ๋ก์ ยซ ยป,
status๋
0,
status message๋ ๋น ๋ฐ์ดํธ ์ํ์ค,
ํค๋
๋ชฉ๋ก์ ยซ ยป,
body๋ null,
๊ทธ๋ฆฌ๊ณ
body
info๋ ์ response
body info์ธ ๊ฒ์ด๋ค.
opaque-redirect ํํฐ๋ง๋ ์๋ต์
ํํฐ๋ง๋
์๋ต์ผ๋ก, ๊ทธ
type์ด
"opaqueredirect",
status๋
0,
status message๋ ๋น ๋ฐ์ดํธ ์ํ์ค,
ํค๋
๋ชฉ๋ก์ ยซ ยป,
body๋ null,
๊ทธ๋ฆฌ๊ณ
body
info๋ ์ response
body info์ธ ๊ฒ์ด๋ค.
opaque-redirect ํํฐ๋ง๋ ์๋ต์ ๋ํด URL ๋ชฉ๋ก์ ๋ ธ์ถํ๋ ๊ฒ์ ๋ฆฌ๋๋ ์ ์ด ๋ฐ๋ผ๊ฐ์ง์ง ์์ผ๋ฏ๋ก ๋ฌดํดํ๋ค.
๋ค์ ๋งํด, opaque ํํฐ๋ง๋ ์๋ต๊ณผ opaque-redirect ํํฐ๋ง๋ ์๋ต์ network error์ ๊ฑฐ์ ๊ตฌ๋ณ๋์ง ์๋๋ค. ์ API๋ฅผ ๋์ ํ ๋๋ ์ ๋ณด๊ฐ ๋์ถ๋ ์ ์์ผ๋ฏ๋ก ๋ด๋ถ ๋ช ์ธ ์๊ณ ๋ฆฌ์ฆ์์ ๋ด๋ถ ์๋ต์ ์ฌ์ฉํ์ง ๋ง๋ผ.
์ด๋ ๋ํ
response.ok ๊ฐ์ JavaScript API๊ฐ
๊ทธ๋ค์ง ์ ์ฉํ์ง ์์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค๋ ๋ป์ด๊ธฐ๋ ํ๋ค.
์๋ต์
type์
type
getter๋ฅผ ํตํด ์คํฌ๋ฆฝํธ์ ๋
ธ์ถ๋๋ค:
console. log( new Response(). type); // "default"
console. log(( await fetch( "/" )). type); // "basic"
console. log(( await fetch( "https://api.example/status" )). type); // "cors"
console. log(( await fetch( "https://crossorigin.example/image" , { mode: "no-cors" })). type); // "opaque"
console. log(( await fetch( "/surprise-me" , { redirect: "manual" })). type); // "opaqueredirect"
(์ด๋ ๋ค์ํ ๋ฆฌ์์ค๊ฐ ์กด์ฌํ๊ณ , https://api.example/status๊ฐ ์ ์ ํ
CORS ํค๋๋ฅผ ๊ฐ์ง๋ฉฐ, /surprise-me๊ฐ redirect status๋ฅผ ์ฌ์ฉํ๋ค๊ณ ๊ฐ์ ํ๋ค.)
์๋ต response๋ฅผ ๋ณต์ ํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
response๊ฐ ํํฐ๋ง๋ ์๋ต์ด๋ฉด, ๊ทธ ๋ด๋ถ ์๋ต์ด response์ ๋ด๋ถ ์๋ต์ ๋ณต์ ํ ๊ฒ์ธ ์ ๋์ผํ ํํฐ๋ง๋ ์๋ต์ ๋ฐํํ๋ค.
-
newResponse๋ฅผ response์ ์ฌ๋ณธ์ผ๋ก ๋๋, ๊ทธ body๋ ์ ์ธํ๋ค.
-
response์ body๊ฐ null์ด ์๋๋ฉด, newResponse์ body๋ฅผ response์ body๋ฅผ ๋ณต์ ํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
newResponse๋ฅผ ๋ฐํํ๋ค.
fresh response๋ ๊ทธ current age๊ฐ ํด๋น freshness lifetime ์์ ์๋ ์๋ต์ด๋ค.
stale-while-revalidate response๋ fresh response๊ฐ ์๋๋ฉฐ, ๊ทธ current age๊ฐ stale-while-revalidate lifetime ์์ ์๋ ์๋ต์ด๋ค. [HTTP-CACHING] [STALE-WHILE-REVALIDATE]
stale response๋ fresh response๋ ์๋๊ณ stale-while-revalidate response๋ ์๋ ์๋ต์ด๋ค.
null ๋๋ ASCII ๋ฌธ์์ด requestFragment๊ฐ ์ฃผ์ด์ก์ ๋, ์๋ต response์ location URL์ ๋ค์ ๋จ๊ณ๋ค์ด ๋ฐํํ๋ ๊ฐ์ด๋ค. ์ด ๋จ๊ณ๋ค์ null, failure, ๋๋ URL์ ๋ฐํํ๋ค.
-
response์ status๊ฐ redirect status๊ฐ ์๋๋ฉด, null์ ๋ฐํํ๋ค.
-
location์ `
Location`๊ณผ response์ ํค๋ ๋ชฉ๋ก์ด ์ฃผ์ด์ก์ ๋ ํค๋ ๋ชฉ๋ก ๊ฐ์ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
location์ด header value์ด๋ฉด, location์ response์ URL์ ๊ธฐ์ค์ผ๋ก location์ ํ์ฑํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
response๊ฐ
Response์์ฑ์๋ฅผ ํตํด ๊ตฌ์ฑ๋ ๊ฒฝ์ฐ, response์ URL์ null์ผ ๊ฒ์ด๋ฉฐ, ์ด๋ location์ด absolute-URL-with-fragment string์ธ ๊ฒฝ์ฐ์๋ง ์ฑ๊ณต์ ์ผ๋ก ํ์ฑ๋๋ค๋ ๋ป์ด๋ค. -
location์ด URL์ด๊ณ ๊ทธ fragment๊ฐ null์ด๋ฉด, location์ fragment๋ฅผ requestFragment๋ก ์ค์ ํ๋ค.
์ด๋ ํฉ์ฑ ์๋ต(์ค์ ๋ก๋ ๋ชจ๋ ์๋ต)์ด HTTP์์ ์ ์ํ ๋ฆฌ๋๋ ์ ์ฒ๋ฆฌ ๋ชจ๋ธ์ ๋ฐ๋ฅด๋๋ก ๋ณด์ฅํ๋ค. [HTTP]
-
location์ ๋ฐํํ๋ค.
location URL ์๊ณ ๋ฆฌ์ฆ์ ์ด ํ์ค๊ณผ ๋ฆฌ๋๋ ์ ์ ์๋์ผ๋ก ์ฒ๋ฆฌํ๋ HTML์ navigate ์๊ณ ๋ฆฌ์ฆ์์ ๋ฆฌ๋๋ ์ ์ฒ๋ฆฌ์๋ง ๋ ์ ์ ์ผ๋ก ์ฌ์ฉ๋๋ค. [HTML]
2.2.7. ๊ธฐํ
์ ์ฌ์
destination(potential destination)์
"fetch"์ด๊ฑฐ๋ ๋น ๋ฌธ์์ด์ด ์๋ destination์ด๋ค.
๋ณํ(translate)์ ์ ์ฌ์ destination potentialDestination์ ๋ํด ์คํํ๋ ค๋ฉด ๋ค์์ ๋ฐ๋ฅธ๋ค:
-
potentialDestination์ด "
fetch"๋ผ๋ฉด ๋น ๋ฌธ์์ด์ ๋ฐํํ๋ค. -
Assert: potentialDestination์ด destination์์ ํ์ธํ๋ค.
-
potentialDestination์ ๋ฐํํ๋ค.
2.3. ์ธ์ฆ ์ํธ๋ฆฌ(Authentication entries)
์ธ์ฆ ์ํธ๋ฆฌ(authentication entry)์ ํ๋ก์ ์ธ์ฆ ์ํธ๋ฆฌ(proxy-authentication entry)๋ HTTP ์ธ์ฆ ๋ฐ HTTP ํ๋ก์ ์ธ์ฆ์ ์ฌ์ฉ๋๋ username, password, realm์ ํํ์ด๋ฉฐ, ํ๋ ์ด์์ ์์ฒญ(requests)๊ณผ ์ฐ๊ด๋๋ค.
์ฌ์ฉ์ ์์ด์ ํธ๋ ์ด ๋์ HTTP ์ฟ ํค ๋ฐ ์ ์ฌ ์ถ์ ๊ธฐ๋ฅ๊ณผ ํจ๊ป ๋ชจ๋ ์ญ์ ํ ์ ์๋๋ก ํด์ผ ํ๋ค.
์์ธํ ์ฌํญ์ HTTP์์ ์ ์ํ๋ค. [HTTP] [HTTP-CACHING]
2.4. Fetch ๊ทธ๋ฃน(Fetch groups)
๊ฐ environment settings object์๋ fetch group์ด ์ฐ๊ด๋์ด ์์ผ๋ฉฐ, ์ด๋ fetch group์ ๋ด๊ณ ์๋ค.
fetch group์ fetch ๊ด๋ จ ์ ๋ณด๋ฅผ ๋ณด๊ดํ๋ค.
fetch group์๋ ๋ค์์ด ์ฐ๊ด๋๋ค:
- fetch records
- ๋ชฉ๋ก์ผ๋ก, fetch records์ ๋ชฉ๋ก์ด๋ค.
- deferred fetch records
- ๋ชฉ๋ก์ผ๋ก, deferred fetch records์ ๋ชฉ๋ก์ด๋ค.
fetch record๋ ๋ค์ items๋ฅผ ๊ฐ์ง struct์ด๋ค:
- request
- ์์ฒญ์ด๋ค.
- controller
- fetch controller ๋๋ null์ด๋ค.
deferred fetch record๋ ๋์ค์ fetch๋ฅผ ํธ์ถํ๋ ๋ฐ ํ์ํ ์ํ๋ฅผ ์ ์งํ๋ ๋ฐ ์ฌ์ฉ๋๋ struct์ด๋ค. ์๋ฅผ ๋ค์ด ๋ฌธ์๊ฐ ์ธ๋ก๋๋๊ฑฐ๋ fully active๊ฐ ์๋๊ฒ ๋ ๋ ์ฌ์ฉ๋๋ค. ์ด๋ ๋ค์ items๋ฅผ ๊ฐ์ง๋ค:
- request
- ์์ฒญ์ด๋ค.
- notify invoked
- ์ธ์๋ฅผ ๋ฐ์ง ์๋ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.
- invoke state (๊ธฐ๋ณธ๊ฐ "
pending") - "
pending", "sent", ๋๋ "aborted"์ด๋ค.
fetch group fetchGroup์ด terminated๋๋ฉด:
-
๊ฐ fetch record record์ ๋ํด, fetchGroup์ fetch records ์ค record์ controller๊ฐ null์ด ์๋๊ณ , record์ request์ done flag์ด ์ค์ ๋์ด ์์ง ์๊ณ , keepalive๊ฐ false์ด๋ฉด, terminate record์ controller๋ฅผ ํธ์ถํ๋ค.
-
Process deferred fetches๋ฅผ fetchGroup์ ๋ํด ์คํํ๋ค.
2.5. ๋๋ฉ์ธ ํด์
origin ํด์(resolve an origin)์ ํ๋ ค๋ฉด,
๋คํธ์ํฌ ํํฐ์
ํค(network partition key) key์ origin origin์ด ์ฃผ์ด์ง๋ค:
-
origin์ host๊ฐ IP ์ฃผ์๋ผ๋ฉด, ยซ origin์ host ยป๋ฅผ ๋ฐํํ๋ค.
-
origin์ host์ public suffix๊ฐ "
localhost" ๋๋ "localhost."๋ผ๋ฉด, ยซ::1,127.0.0.1ยป๋ฅผ ๋ฐํํ๋ค. -
origin์ ํ๋ ์ด์์ IP ์ฃผ์์ ์งํฉ(set)์ผ๋ก ๋ณํํ๋ ๊ตฌํ ์ ์(implementation-defined) ์์ ์ ์ํํ๋ค.
๋ํ ๋จ์ํ IP ์ฃผ์๋ง ์ป๋ ๊ฒ ์ธ์, ๋ค๋ฅธ ์ฐ๊ฒฐ ์ ๋ณด๋ ์ป๋ ์์ ์ด ๊ตฌํ ์ ์๋ก ์ํ๋ ์ ์๋ค. ์๋ฅผ ๋ค์ด, origin์ scheme์ด HTTP(S) scheme๋ผ๋ฉด, ๊ตฌํ์ฒด๋ HTTPS RR์ ๋ํ DNS ์ง์๋ฅผ ํ ์๋ ์๋ค. [SVCB]
์ด ์์ ์ด ์ฑ๊ณตํ๋ฉด, IP ์ฃผ์์ ์งํฉ(set)๊ณผ ์ถ๊ฐ ๊ตฌํ ์ ์ ์ ๋ณด๋ฅผ ๋ฐํํ๋ค.
-
์คํจ(failure)๋ฅผ ๋ฐํํ๋ค.
origin ํด์ ๊ฒฐ๊ณผ๋ ์บ์๋ ์ ์๋ค. ์บ์ํ ๊ฒฝ์ฐ, key๋ฅผ ์บ์ ํค์ ์ผ๋ถ๋ก ์ฌ์ฉํด์ผ ํ๋ค.
์ด ์์ ์ ์ผ๋ฐ์ ์ผ๋ก DNS๋ฅผ ํฌํจํ๋ฏ๋ก, DNS ์๋ฒ์์ key๋ฅผ ๊ณ ๋ คํ์ง ์๊ณ ์บ์๊ฐ ๋ฐ์ํ ์ ์๋ค. ๊ตฌํ์ฒด์ ๋ฐ๋ผ ๋ก์ปฌ์์ key๋ฅผ ๊ณ ๋ คํ ์ ์๋ ๊ฒฝ์ฐ๋ ์๋ค. [RFC1035]
IP ์ฃผ์์ ๋ฐํ ์์๋ origin ํด์ ์๊ณ ๋ฆฌ์ฆ ํธ์ถ๋ง๋ค ๋ค๋ฅผ ์ ์๋ค.
(์บ์ ํค๋ฅผ ์ ์ธํ) ์ธ๋ถ ์ฌํญ์ ํํ ํ์ค์ด ์ ์ํ๋ ์์คํ ๊ณผ ์ง์ ์ ์ผ๋ก ๊ด๋ จ์ด ์์ผ๋ฏ๋ก ๊ตฌ์ฒด์ ์ผ๋ก ๋ช ์ํ์ง ์๋๋ค. ๋ค๋ฅธ ๋ฌธ์์์ ์ด ํ๋ฆฌ๋ฏธํฐ๋ธ์ ์์กดํ๊ณ ์ ํ๋ค๋ฉด, ๋ฐ๋์ ํํ ํ์ค ์ปค๋ฎค๋ํฐ์ ์ถฉ๋ถํ ๋ ผ์๊ฐ ์ ํ๋์ด์ผ ํ๋ค.
2.6. ์ฐ๊ฒฐ
์ฌ์ฉ์ ์์ด์ ํธ๋ ์ฐ๊ด๋ ์ฐ๊ฒฐ ํ ์ ๊ฐ์ง๋๋ค. ์ฐ๊ฒฐ ํ ์ 0๊ฐ ์ด์์ ์ฐ๊ฒฐ ๋ก ์ด๋ฃจ์ด์ง ์์ ์๋ ์งํฉ ์ ๋๋ค. ๊ฐ ์ฐ๊ฒฐ ์ ์ฐ๊ด๋ ํค ( ๋คํธ์ํฌ ํํฐ์ ํค ), origin ( origin ), credentials (๋ถ๋ฆฌ์ธ)๋ก ์๋ณ๋ฉ๋๋ค.
๊ฐ connection์ ์ฐ๊ด๋ timing info (connection timing info)๋ฅผ ๊ฐ์ง๋ค.
connection timing info๋ ์ฐ๊ฒฐ ํ๋ ๊ณผ์ ์ ํ์ด๋ฐ ์ ๋ณด๋ฅผ ๋ณด๊ดํ๋ struct์ด๋ค. ๋ค์ ํญ๋ชฉ(items)์ ๊ฐ์ง๋ค:
- ๋๋ฉ์ธ ์กฐํ ์์ ์๊ฐ(domain lookup start time)
(๊ธฐ๋ณธ๊ฐ 0)
- ๋๋ฉ์ธ ์กฐํ ์ข ๋ฃ ์๊ฐ(domain lookup end time) (๊ธฐ๋ณธ๊ฐ 0)
- ์ฐ๊ฒฐ ์์ ์๊ฐ(connection start time) (๊ธฐ๋ณธ๊ฐ 0)
- ์ฐ๊ฒฐ ์ข ๋ฃ ์๊ฐ(connection end time) (๊ธฐ๋ณธ๊ฐ 0)
- ๋ณด์ ์ฐ๊ฒฐ ์์ ์๊ฐ(secure connection start time) (๊ธฐ๋ณธ๊ฐ 0)
- ๋๋ฉ์ธ ์กฐํ ์ข ๋ฃ ์๊ฐ(domain lookup end time) (๊ธฐ๋ณธ๊ฐ 0)
DOMHighResTimeStamp.- ALPN ํ์ ํ๋กํ ์ฝ(ALPN negotiated protocol) (๊ธฐ๋ณธ๊ฐ: ๋น ๋ฐ์ดํธ ์ํ์ค)
- ๋ฐ์ดํธ ์ํ์ค.
connection timing info clamp/coarsen ์๊ณ ๋ฆฌ์ฆ์
connection
timing info timingInfo,
DOMHighResTimeStamp
defaultStartTime, ๋ถ๋ฆฌ์ธ crossOriginIsolatedCapability๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์์ ์คํํ๋ค:
-
timingInfo ์ ์ฐ๊ฒฐ ์์ ์๊ฐ ์ด defaultStartTime ๋ณด๋ค ์์ผ๋ฉด, ๋๋ฉ์ธ ์กฐํ ์์ ์๊ฐ ์ defaultStartTime ์ผ๋ก ์ค์ ํ๊ณ , ๋๋ฉ์ธ ์กฐํ ์ข ๋ฃ ์๊ฐ ์ defaultStartTime ์ผ๋ก ์ค์ ํ๊ณ , ์ฐ๊ฒฐ ์์ ์๊ฐ ์ defaultStartTime ์ผ๋ก ์ค์ ํ๊ณ , ์ฐ๊ฒฐ ์ข ๋ฃ ์๊ฐ ์ defaultStartTime ์ผ๋ก ์ค์ ํ๊ณ , ๋ณด์ ์ฐ๊ฒฐ ์์ ์๊ฐ ์ defaultStartTime ์ผ๋ก ์ค์ ํ๊ณ ALPN ํ์ ํ๋กํ ์ฝ ์ timingInfo ์ ALPN ํ์ ํ๋กํ ์ฝ ๋ก ์ค์ ํ ์๋ก์ด ์ฐ๊ฒฐ ํ์ด๋ฐ ์ ๋ณด ๋ฅผ ๋ฐํํฉ๋๋ค.
-
์๋ก์ด ์ฐ๊ฒฐ ํ์ด๋ฐ ์ ๋ณด ๋ฅผ ๋ฐํํฉ๋๋ค. ์ด ์ ๋ณด์์ ๋๋ฉ์ธ ์กฐํ ์์ ์๊ฐ ์ timingInfo ์ ๋๋ฉ์ธ ์กฐํ ์์ ์๊ฐ ๊ณผ crossOriginIsolatedCapability ๊ฐ ์ฃผ์ด์ก์ ๋ ์๊ฐ ์ ๋ฐ๋๋ฅผ ๋ฎ์ถ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋๋ฉ์ธ ์กฐํ ์ข ๋ฃ ์๊ฐ ์ timingInfo ์ ๋๋ฉ์ธ ์กฐํ ์ข ๋ฃ ์๊ฐ ๊ณผ crossOriginIsolatedCapability ๊ฐ ์ฃผ์ด์ก์ ๋ ์๊ฐ ์ ๋ฐ๋๋ฅผ ๋ฎ์ถ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ์ฐ๊ฒฐ ์์ ์๊ฐ ์ timingInfo ์ ์ฐ๊ฒฐ ์์ ์๊ฐ ๊ณผ crossOriginIsolatedCapability ๊ฐ ์ฃผ์ด์ก์ ๋ ์๊ฐ ์ ๋ฐ๋๋ฅผ ๋ฎ์ถ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ์ฐ๊ฒฐ ์ข ๋ฃ ์๊ฐ ์ timingInfo ์ ์ฐ๊ฒฐ ์ข ๋ฃ ์๊ฐ ๊ณผ crossOriginIsolatedCapability ๊ฐ ์ฃผ์ด์ก์ ๋ ์๊ฐ ์ ๋ฐ๋๋ฅผ ๋ฎ์ถ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณด์ ์ฐ๊ฒฐ ์์ ์๊ฐ ์ timingInfo ์ ์ฐ๊ฒฐ ์ข ๋ฃ ์๊ฐ ๊ณผ crossOriginIsolatedCapability ๊ฐ ์ฃผ์ด์ก์ ๋ ์๊ฐ ์ ๋ฐ๋๋ฅผ ๋ฎ์ถ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ALPN ํ์ ํ๋กํ ์ฝ ์ timingInfo ์ ALPN ํ์ ํ๋กํ ์ฝ ๋ก ์ค์ ํฉ๋๋ค.
์ ์ฐ๊ฒฐ ์ค์ (new connection
setting)์ "no", "yes", "yes-and-dedicated" ์ค ํ๋์ด๋ค.
์ฐ๊ฒฐ์ ํ๋(obtain a
connection)ํ๋ ค๋ฉด,
๋คํธ์ํฌ ํํฐ์
ํค(network partition key) key,
URL url,
๋ถ๋ฆฌ์ธ credentials, ์ ํ์ ์ ์ฐ๊ฒฐ ์ค์ (new connection setting) new(๊ธฐ๋ณธ๊ฐ
"no"),
์ ํ์ ๋ถ๋ฆฌ์ธ requireUnreliable(๊ธฐ๋ณธ๊ฐ false), ๊ทธ๋ฆฌ๊ณ
์ ํ์ WebTransport-hash ๋ชฉ๋ก
webTransportHashes(๊ธฐ๋ณธ๊ฐ ยซ ยป)๋ฅผ ์
๋ ฅ๋ฐ์ ๋ค์์
๋ฐ๋ฅธ๋ค:
-
new๊ฐ "
no"๋ผ๋ฉด:-
๋จ์ธ(assert): webTransportHashes ๊ฐ ๋น์ด ์์.
-
connections๋ฅผ ์ฌ์ฉ์ ์์ด์ ํธ์ ์ฐ๊ฒฐ ์งํฉ์ผ๋ก ๋๋ฉฐ, ์ด๋ ์ฌ์ฉ์ ์์ด์ ํธ์ ์ฐ๊ฒฐ ํ์ ์ํ๊ณ ๊ทธ ํค๊ฐ key์ ๊ฐ์ ๊ฒ์ด๋ฉฐ, ์ถ์ฒ๊ฐ url์ ๋์ผ ์ถ์ฒ์ธ ์ถ์ฒ์ ๊ฐ๊ณ , ๋ํ ์๊ฒฉ ์ฆ๋ช ์ด credentials์ ๋๋ค.
-
connections๊ฐ ๋น์ด ์์ง ์๊ณ requireUnreliable์ด false๋ผ๋ฉด, connections ์ค ํ๋๋ฅผ ๋ฐํํ๋ค.
-
connections ์์ ์๋ฅผ ๋ค์ด HTTP/3 ๋ฑ ์ ๋ขฐํ ์ ์๋(unreliable) ์ ์ก์ ์ง์ํ ์ ์๋ ์ฐ๊ฒฐ์ด ์๋ค๋ฉด, ํด๋น ์ฐ๊ฒฐ์ ๋ฐํํ๋ค.
-
-
proxies๋ฅผ url์ ๋ํด ๊ตฌํ์ ์ ์ ๋ฐฉ์(implementation-defined manner)์ผ๋ก ํ๋ก์๋ฅผ ์ฐพ์ ๊ฒฐ๊ณผ๋ก ๋๋ค. ํ๋ก์๊ฐ ์์ผ๋ฉด proxies๋ ยซ "
DIRECT" ยป๋ก ๋๋ค.์ฌ๊ธฐ๊ฐ WPAD๋ PAC ๋ฑ์ ๋นํ์ค ๊ธฐ์ ์ด ๋์ํ๋ ๋ถ๋ถ์ด๋ค. "
DIRECT" ๊ฐ์ ์ด url์ ํ๋ก์๋ฅผ ์ฌ์ฉํ์ง ์์์ ์๋ฏธํ๋ค. -
timingInfo๋ฅผ ์๋ก์ด connection timing info๋ก ๋๋ค.
-
๊ฐ proxies์ proxy์ ๋ํด:
-
timingInfo์ domain lookup start time์ unsafe shared current time์ผ๋ก ์ค์ ํ๋ค.
-
proxy๊ฐ "
DIRECT"์ด๋ฉด, hosts๋ฅผ key์ url์ origin์ ์ฌ์ฉํ์ฌ origin ํด์(resolve an origin) ์ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. -
hosts๊ฐ ์คํจ(failure)๋ฉด continue.
-
timingInfo์ domain lookup end time์ unsafe shared current time์ผ๋ก ๋๋ค.
-
connection์ ๋ค์ ๋จ๊ณ์ ๊ฒฐ๊ณผ๋ก ๋๋ค: ์ฐ๊ฒฐ ์์ฑ(create a connection)์ key, url์ origin, credentials, proxy, hosts์์ ๊ตฌํ์ ์ ์ ๋ฐฉ์์ผ๋ก ํ๋์ host, timingInfo, requireUnreliable, webTransportHashes๋ก ํธ์ถํ๋ค. ์ด๋ฅผ ๊ตฌํ์ ์ ์ ํ์๋งํผ ์๋ก ๋ณ๋ ฌ(parallel)๋ก ์๋ํ๊ณ , ์ต์ ํ๋ ์ด์ ๊ฐ์ด ๋ฐํ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆฐ๋ค. ๊ตฌํ์ ์ ์ ๋ฐฉ์์ผ๋ก ๋ฐํ๊ฐ ์ค ํ๋๋ฅผ ์ ํํด ๋ฐํํ๋ค. ๋ฐํ๊ฐ ์ค ์ฐ๊ฒฐ(connection)์ธ ๋ค๋ฅธ ๊ฐ๋ค์ ๋ซํ ์ ์๋ค.
์ค์ง์ ์ผ๋ก ์ด๊ฒ์ ๊ตฌํ์ฒด๊ฐ origin ํด์(resolve an origin)์ ๊ฒฐ๊ณผ(ํ๋ก์๊ฐ "
DIRECT"์ผ ๋)๋ก ์ฌ๋ฌ IP ์ฃผ์๋ฅผ ๋ฐ์ ๋ณ๋ ฌ๋ก ์ฐ๊ฒฐ์ ์๋ํ๊ฑฐ๋, IPv6 ์ฃผ์๋ฅผ ์ฐ์ ํ๊ฑฐ๋, ์๊ฐ ์ด๊ณผ ์ ์ฌ์๋ํ๋ ๋ฑ์ ์ ์ฑ ์ ๊ตฌํํ ์ ์์์ ์๋ฏธํ๋ค. -
connection์ด ์คํจ(failure)์ด๋ฉด continue.
-
new๊ฐ "
yes-and-dedicated"๊ฐ ์๋๋ผ๋ฉด append connection์ ์ฌ์ฉ์ ์์ด์ ํธ์ connection pool์ ์ถ๊ฐํ๋ค. -
connection์ ๋ฐํํ๋ค.
-
-
์คํจ(failure)๋ฅผ ๋ฐํํ๋ค.
์ฐ๊ฒฐ ๊ด๋ฆฌ์๋ ๊ตฌํ์์ ์ฌ๋์ ๋งก๊ธฐ๋ ๊ฒ์ด ์ข์ ์ฌ๋ฌ ์ธ๋ถ์ฌํญ์ด ์์ผ๋ฏ๋ก ์๋์ ์ผ๋ก ๋ค์ ํฌ๊ด์ ์ผ๋ก ์์ ๋์ด ์์ต๋๋ค. ์ด ์ค๋ช ์ <link rel=preconnect> ๊ธฐ๋ฅ์ ์ค๋ช ํ๊ณ ์ฐ๊ฒฐ ์ด credentials ๋ฅผ ํค๋ก ๊ตฌ๋ถ๋จ์ ๋ช ํํ๊ฒ ๊ท์ ํฉ๋๋ค. ์์ปจ๋ TLS ์ธ์ ์๋ณ์๋ credentials ๊ฐ false์ธ ์ฐ๊ฒฐ ๊ณผ credentials ๊ฐ true์ธ ์ฐ๊ฒฐ ์ฌ์ด์์ ์ฌ์ฌ์ฉ๋์ง ์์ต๋๋ค.
์ฐ๊ฒฐ ์์ฑ์ ์ํด, ๋คํธ์ํฌ ํํฐ์ ํค key, origin origin, ๋ถ๋ฆฌ์ธ credentials, ๋ฌธ์์ด proxy, host host, ์ฐ๊ฒฐ ํ์ด๋ฐ ์ ๋ณด timingInfo, ๋ถ๋ฆฌ์ธ requireUnreliable, ๊ทธ๋ฆฌ๊ณ WebTransport-hash ๋ชฉ๋ก webTransportHashes๊ฐ ์ฃผ์ด์ง๋ค:
-
timingInfo์ connection start time์ unsafe shared current time์ผ๋ก ์ค์ ํ๋ค.
-
connection์ ์ ์ฐ๊ฒฐ(connection)๋ก ๋๋, key๋ key, origin์ origin, credentials๋ credentials, timing info๋ timingInfo๋ก ํ๋ค. connection timing info ๊ธฐ๋ก(record connection timing info)์ connection์ ๋ํด ์ํํ๊ณ , proxy์ origin์ ๊ณ ๋ คํ์ฌ host๋ก HTTP ์ฐ๊ฒฐ์ ์ค์ ํ๋ค. ์๋ ์ฃผ์์ฌํญ ์ฐธ๊ณ . [HTTP] [HTTP1] [TLS]
-
requireUnreliable๊ฐ true๋ผ๋ฉด, HTTP/3 ๋ฑ ์ ๋ขฐํ ์ ์๋ ์ ์ก์ ์ง์ํ๋ ์ฐ๊ฒฐ์ ์ค์ ํ๋ค. [HTTP3]
-
์ ๋ขฐํ ์ ์๋ ์ ์ก์ ์ง์ํ๋ ์ฐ๊ฒฐ์ ์ค์ ํ ๋๋ WebTransport์ ํ์ํ ์ต์ ์ ํ์ฑํํด์ผ ํ๋ค. HTTP/3์ ๊ฒฝ์ฐ, ์ด๊ธฐ
SETTINGSํ๋ ์์SETTINGS_ENABLE_WEBTRANSPORT์H3_DATAGRAM๊ฐ์ 1๋ก ํฌํจํ๋ค. [WEBTRANSPORT-HTTP3] [HTTP3-DATAGRAM] -
credentials๊ฐ false๋ฉด, TLS ํด๋ผ์ด์ธํธ ์ธ์ฆ์๋ฅผ ๋ณด๋ด์ง ์๋๋ค.
-
webTransportHashes๊ฐ ๋น์ด ์์ง ์์ผ๋ฉด, ๊ธฐ๋ณธ ์ธ์ฆ์ ๊ฒ์ฆ ์๊ณ ๋ฆฌ์ฆ ๋์ , ์๋ฒ ์ธ์ฆ์๊ฐ ์ฌ์ฉ์ ์ ์ ์ธ์ฆ์ ์๊ฑด์ ๋ง์กฑํ๊ณ , ์ธ์ฆ์ ํด์ ๊ฒ์ฆ์ด webTransportHashes์ ๋ํด true๋ฅผ ๋ฐํํ๋ฉด ์๋ฒ ์ธ์ฆ์๊ฐ ์ ํจํ ๊ฒ์ผ๋ก ๊ฐ์ฃผํ๋ค. ์กฐ๊ฑด์ด ์ถฉ์กฑ๋์ง ์์ผ๋ฉด ์คํจ๋ฅผ ๋ฐํํ๋ค.
-
์ฐ๊ฒฐ ์ค์ ์ ์คํจํ๋ฉด(์: UDP, TCP, TLS ์ค๋ฅ ๋ฑ) ์คํจ๋ฅผ ๋ฐํํ๋ค.
-
-
timingInfo์ ALPN ํ์ ํ๋กํ ์ฝ(ALPN negotiated protocol)์ connection์ ALPN Protocol ID๋ก ์ค์ ํ๋, ๋ค์ ์์ธ๋ฅผ ์ ์ฉํ๋ค. [RFC7301]
-
ํ๋ก์๊ฐ ์ค์ ๋ ๊ฒฝ์ฐ, ํฐ๋ ์ฐ๊ฒฐ์ด ์๋ฆฝ๋๋ค๋ฉด ๊ทธ ํฐ๋๋ง๋ ํ๋กํ ์ฝ์ ALPN Protocol ID์ฌ์ผ ํ๋ฉฐ, ์๋ ๊ฒฝ์ฐ ํ๋ก์์ ์ฒซ ํ(hop)์ ๋ํ ๊ฐ์ด์ด์ผ ํ๋ค.
-
์คํ์ ์ด๊ฑฐ๋ ๋ฑ๋ก๋์ง ์์ ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ, ์ฌ์ฉ๋ ALPN Protocol ID(์๋ค๋ฉด)๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค. ํ๋กํ ์ฝ ํ์์ ALPN์ด ์ฌ์ฉ๋์ง ์์๋ค๋ฉด, ์ค๋ช ์ ์ธ ๋ค๋ฅธ ๋ฌธ์์ด์ ์จ๋ ๋๋ค.
timingInfo์ ALPN ํ์ ํ๋กํ ์ฝ์ ์ค์ ํ์ ๋ฐฉ์์ ๊ด๊ณ์์ด ์ฌ์ฉ ๋คํธ์ํฌ ํ๋กํ ์ฝ์ ์๋ณํ๊ธฐ ์ํ ๊ฒ์ด๋ค. ์ฆ ALPN์ด ์ค์ ๋ก ์ฐ์ด์ง ์๋๋ผ๋ ์ฌ์ฉ๋ ํ๋กํ ์ฝ์ ์ง์ํ๋ ALPN Protocol ID๋ค.
IANA๋ ALPN Protocol ID ๋ชฉ๋ก์ ๊ด๋ฆฌํ๋ค.
-
-
connection์ ๋ฐํํ๋ค.
connection timing info ๊ธฐ๋ก(record connection timing info) ์๊ณ ๋ฆฌ์ฆ์ connection connection์ ๋ํด timingInfo๋ฅผ connection์ timing info๋ก ๋๊ณ , ๋ค์ ์ฌํญ์ ๊ด์ฐฐํ๋ค:
-
timingInfo์ connection end time์ ์๋ฒ๋ ํ๋ก์ ์ฐ๊ฒฐ ์งํ unsafe shared current time์ด์ด์ผ ํ๋ค. ๋จ, ์๋์ ์ธ๋ถ์ฌํญ ์ค์:
-
๋ฐํ ์๊ฐ์๋ ํธ๋์คํฌํธ ์ฐ๊ฒฐ ์๊ฐ๋ฟ ์๋๋ผ, SOCKS ์ธ์ฆ ๋ฑ ๊ธฐํ ์๊ฐ๋ ํฌํจํด์ผ ํ๋ค. ์์ ์์ฒญ์ ์ํ TLS handshake ์ต์ ์๋ฃ๊น์ง์ ์๊ฐ๋ ํฌํจํด์ผ ํ๋ค.
-
์ด ์ฐ๊ฒฐ์ TLS False Start๋ฅผ ์ผ๋ค๋ฉด, ์๋ฒ Finished ๋ฉ์์ง ์์ ๊น์ง์ ์๊ฐ์ ํฌํจํ์ง ์๋๋ค. [RFC7918]
-
์ ์ฒด handshake ์๋ฃ๋ฅผ ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ early data๋ก ์์ฒญ์ ๋ณด๋ธ๋ค๋ฉด, ์๋ฒ ServerHello ์์ ๊น์ง์ ์๊ฐ์ ํฌํจํ์ง ์๋๋ค. [RFC8470]
-
์ ์ฒด handshake ์๋ฃ๋ฅผ ๊ธฐ๋ค๋ ค ์์ฒญ์ ๋ณด๋ธ ๊ฒฝ์ฐ, ์ด ์๊ฐ์๋ ์ ์ฒด TLS handshake๊ฐ ํฌํจ๋๋ค(์ค๋ น ๋ค๋ฅธ ์์ฒญ์ด early data๋ก ์ด๋ฏธ ์ ์ก๋๋๋ผ๋).
์์: ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ TLS 1.3 ๊ธฐ๋ฐ HTTP/2 ์ฐ๊ฒฐ์ ๋งบ๊ณ
GET๊ณผPOST์์ฒญ์ ๋ณด๋ธ๋ค. t1์ ClientHello ๋ฐGET์ early data๋ก ๋ณด๋ธ ๋ค,POST๋ ์์ ํ์ง ์์ผ๋ฏ๋ก([HTTP] 9.2.1์ ), handshake๊ฐ ์๋ฃ๋ t2๊น์ง ๊ธฐ๋ค๋ ธ๋ค๊ฐ ๋ณด๋ธ๋ค. ๋ ์์ฒญ ๋ชจ๋ ๊ฐ์ ์ฐ๊ฒฐ์ ์ฌ์ฉํ์ง๋งGET์ connection end time์ t1,POST๋ t2๋ก ๊ธฐ๋ก๋๋ค. -
-
๋ณด์ ํธ๋์คํฌํธ๋ฅผ ์ด ๊ฒฝ์ฐ, timingInfo์ secure connection start time์ handshake ์์ ์ง์ unsafe shared current time์ด์ด์ผ ํ๋ค. [TLS]
-
connection์ด HTTP/3๋ผ๋ฉด, timingInfo์ connection start time๊ณผ secure connection start time์ด ๋์ผํด์ผ ํ๋ค(HTTP/3์์๋ ๋ณด์ handshake๊ฐ ์ฐ๊ฒฐ ์ด๊ธฐํ์ ๋์์ ์ด๋ฃจ์ด์ง๊ธฐ ๋๋ฌธ). [HTTP3]
connection timing info clamp/coarsen ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฌ์ฉ๋ ์ฐ๊ฒฐ์ ์์ธ ์ ๋ณด ๋ ธ์ถ ๋ฐฉ์ง ๋ฐ ์๊ฐ๊ฐ coarsen์ ๋ณด์ฅํ๋ค.
2.7. ๋คํธ์ํฌ ํํฐ์ ํค(Network partition keys)
๋คํธ์ํฌ ํํฐ์ ํค(network partition key)๋ site์ null ๋๋ ๊ตฌํ ์ ์ ๊ฐ์ ์์๋ก ํ๋ ํํ์ด๋ค.
๋คํธ์ํฌ ํํฐ์ ํค ๊ฒฐ์ (determine the network partition key) ์๊ณ ๋ฆฌ์ฆ์ environment environment๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์์ ๋ฐ๋ฅธ๋ค:
-
topLevelOrigin์ environment์ top-level origin์ผ๋ก ๋๋ค.
-
topLevelOrigin์ด null์ด๋ฉด, topLevelOrigin์ environment์ top-level creation URL์ origin์ผ๋ก ๋๋ค.
-
topLevelSite๋ฅผ obtain a site ์๊ณ ๋ฆฌ์ฆ์ topLevelOrigin์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
secondKey๋ฅผ null ๋๋ ๊ตฌํ ์ ์ ๊ฐ ์ค ํ๋๋ก ๋๋ค.
secondKey๋ ์๋์ ์ผ๋ก ๋ค์ ๋ชจํธํ๊ฒ ์ ์๋์ด ์๋ค. ์ธ๋ถ ๋ด์ฉ์ ์์ง ๋ฐ์ ์ค์. issue #1035 ์ฐธ๊ณ .
-
(topLevelSite, secondKey)๋ฅผ ๋ฐํํ๋ค.
๋คํธ์ํฌ ํํฐ์ ํค ๊ฒฐ์ (determine the network partition key)์ ํ๋ ค๋ฉด, request request์ ๋ํด ๋ค์์ ์ํํ๋ค:
-
request์ reserved client๊ฐ null์ด ์๋๋ฉด, request์ reserved client๋ฅผ ์ฌ์ฉํ์ฌ ๋คํธ์ํฌ ํํฐ์ ํค ๊ฒฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
request์ client๊ฐ null์ด ์๋๋ฉด, request์ client๋ฅผ ์ฌ์ฉํ์ฌ ๋คํธ์ํฌ ํํฐ์ ํค ๊ฒฐ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
null์ ๋ฐํํ๋ค.
2.8. HTTP ์บ์ ํํฐ์ (HTTP cache partitions)
HTTP ์บ์ ํํฐ์ ๊ฒฐ์ (determine the HTTP cache partition)์ ํ๋ ค๋ฉด, request request์ ๋ํด ๋ค์์ ์ํํ๋ค:
-
key๋ฅผ request๋ก ๋คํธ์ํฌ ํํฐ์ ํค ๊ฒฐ์ (determine the network partition key)์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
key๊ฐ null์ด๋ฉด, null์ ๋ฐํํ๋ค.
-
key์ ์ฐ๊ด๋ ๊ณ ์ HTTP ์บ์๋ฅผ ๋ฐํํ๋ค. [HTTP-CACHING]
2.9. ํฌํธ ์ฐจ๋จ(Port blocking)
์๋ก์ด ํ๋กํ ์ฝ์ TLS์ ALPN์ ์ฌ์ฉํ์ฌ ํ๋กํ ์ฝ ํ์์ ํตํด ํฌํธ ์ฐจ๋จ์ ํ์์ฑ์ ํผํ ์ ์์ต๋๋ค. ์ด๋๋ HTTP ์์ฒญ์ผ๋ก ํ๋กํ ์ฝ์ ์์กฐํ ์ ์์ต๋๋ค. [RFC7301]
request request๋ฅผ ๊ฐ์ ธ์ค๋ ๊ฒ์ด ๋์ ํฌํธ(bad port)๋ก ์ธํด ์ฐจ๋จ๋์ด์ผ ํ๋์ง ๊ฒฐ์ ํ๋ ค๋ฉด:
-
url์ request์ ํ์ฌ URL๋ก ํ๋ค.
-
url์ ์คํด(scheme)์ด HTTP(S) ์คํด์ด๊ณ , url์ ํฌํธ(port)๊ฐ ๋์ ํฌํธ(bad port)๋ผ๋ฉด, blocked๋ฅผ ๋ฐํํ๋ค.
-
allowed๋ฅผ ๋ฐํํ๋ค.
ํฌํธ(port)๊ฐ ๋์ ํฌํธ(bad port)์ด๋ฉด ์๋ ํ์ ์ฒซ ๋ฒ์งธ ์ด์ ๋์ด๋ ๊ฐ ์ค ํ๋์ด๋ค.
| ํฌํธ | ์ผ๋ฐ ์๋น์ค |
|---|---|
| 0 | โโ |
| 1 | tcpmux |
| 7 | echo |
| 9 | discard |
| 11 | systat |
| 13 | daytime |
| 15 | netstat |
| 17 | qotd |
| 19 | chargen |
| 20 | ftp-data |
| 21 | ftp |
| 22 | ssh |
| 23 | telnet |
| 25 | smtp |
| 37 | time |
| 42 | name |
| 43 | nicname |
| 53 | domain |
| 69 | tftp |
| 77 | โโ |
| 79 | finger |
| 87 | โโ |
| 95 | supdup |
| 101 | hostname |
| 102 | iso-tsap |
| 103 | gppitnp |
| 104 | acr-nema |
| 109 | pop2 |
| 110 | pop3 |
| 111 | sunrpc |
| 113 | auth |
| 115 | sftp |
| 117 | uucp-path |
| 119 | nntp |
| 123 | ntp |
| 135 | epmap |
| 137 | netbios-ns |
| 139 | netbios-ssn |
| 143 | imap |
| 161 | snmp |
| 179 | bgp |
| 389 | ldap |
| 427 | svrloc |
| 465 | submissions |
| 512 | exec |
| 513 | login |
| 514 | shell |
| 515 | printer |
| 526 | tempo |
| 530 | courier |
| 531 | chat |
| 532 | netnews |
| 540 | uucp |
| 548 | afp |
| 554 | rtsp |
| 556 | remotefs |
| 563 | nntps |
| 587 | submission |
| 601 | syslog-conn |
| 636 | ldaps |
| 989 | ftps-data |
| 990 | ftps |
| 993 | imaps |
| 995 | pop3s |
| 1719 | h323gatestat |
| 1720 | h323hostcall |
| 1723 | pptp |
| 2049 | nfs |
| 3659 | apple-sasl |
| 4045 | npp |
| 4190 | sieve |
| 5060 | sip |
| 5061 | sips |
| 6000 | x11 |
| 6566 | sane-port |
| 6665 | ircu |
| 6666 | ircu |
| 6667 | ircu |
| 6668 | ircu |
| 6669 | ircu |
| 6679 | osaut |
| 6697 | ircs-u |
| 10080 | amanda |
2.10. response๋ฅผ request์ ๋ํด MIME ํ์ ์ผ๋ก ์ฐจ๋จํด์ผ ํ๋๊ฐ?
๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
mimeType์ response์ header list์์ MIME ํ์ ์ถ์ถ์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
mimeType์ด failure๋ผ๋ฉด allowed๋ฅผ ๋ฐํํ๋ค.
-
destination์ request์ destination์ผ๋ก ๋๋ค.
-
destination์ด script-like์ด๊ณ , ์๋ ์ค ํ๋๋ผ๋ ํด๋น๋๋ฉด blocked๋ฅผ ๋ฐํํ๋ค:
-
allowed๋ฅผ ๋ฐํํ๋ค.
3. HTTP ํ์ฅ
3.1. ์ฟ ํค(Cookies)
`Cookie` ์์ฒญ ํค๋์ `Set-Cookie` ์๋ต ํค๋๋ ๋๋ถ๋ถ ์์ฒด ๋ช
์ธ์์ ์ ์๋๋ค. ์ฌ๊ธฐ์๋ ์ด๋ฅผ ํธ๋ฆฌํ๊ฒ ์ฌ์ฉํ๊ธฐ ์ํ ์ถ๊ฐ ์ธํ๋ผ๋ฅผ
์ ์ํ๋ค. [COOKIES].
3.1.1. `Cookie` ํค๋
์์ฒญ์
`Cookie` ํค๋๋ฅผ ์ถ๊ฐ(append a request `Cookie` header)ํ๋ ค๋ฉด, request
request์ ๋ํด ๋ค์์ ์ํํ๋ค:
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ request์ ๋ํด ์ฟ ํค๋ฅผ ์ฌ์ฉํ์ง ์๋๋ก ์ค์ ๋์ด ์๋ค๋ฉด, ๋ฐํํ๋ค.
-
sameSite๋ฅผ request์ ๋ํด same-site ๋ชจ๋ ๊ฒฐ์ (determine the same-site mode)์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
isSecure๋ฅผ request์ ํ์ฌ URL์ ์คํด(scheme)์ด "
https"๋ผ๋ฉด true, ์๋๋ฉด false๋ก ๋๋ค. -
httpOnlyAllowed๋ฅผ true๋ก ๋๋ค.
fetch ์์ ํธ์ถ๋๋ ๊ฒฝ์ฐ์ด๋ฏ๋ก
document.cookiegetter์ ๋ฌ๋ฆฌ true๊ฐ ๋๋ค. -
cookies๋ฅผ ์ฟ ํค ๊ฒ์(retrieve cookies)์ isSecure, request์ ํ์ฌ URL์ host, request์ ํ์ฌ URL์ path, httpOnlyAllowed, sameSite๋ฅผ ๋๊ฒจ ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
์ฟ ํค ์ ์ฅ์๋ ์ ๋ ฌ๋ ์ฟ ํค ๋ชฉ๋ก์ ๋ฐํํ๋ค.
-
cookies๊ฐ ๋น์ด ์๋ค๋ฉด ๋ฐํํ๋ค.
-
value๋ฅผ ์ฟ ํค ์ง๋ ฌํ(serialize cookies)๋ฅผ cookies์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
์ถ๊ฐ(Append) (`
Cookie`, value)๋ฅผ request์ ํค๋ ๋ชฉ๋ก(header list)์ ์ถ๊ฐํ๋ค.
3.1.2. `Set-Cookie` ํค๋
์๋ต์ `Set-Cookie` ํค๋ ํ์ฑ ๋ฐ ์ ์ฅ์
ํ๋ ค๋ฉด,
request
request์ response response๋ฅผ ์
๋ ฅ์ผ๋ก ๋ค์์ ์ํํ๋ค:
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ request์ ๋ํด ์ฟ ํค ์ฌ์ฉ์ ๋นํ์ฑํํ ๊ฒฝ์ฐ, ๋ฐํํ๋ค.
-
allowNonHostOnlyCookieForPublicSuffix๋ฅผ false๋ก ๋๋ค.
-
isSecure๋ฅผ request์ ํ์ฌ URL์ ์คํด(scheme)์ด "
https"์ด๋ฉด true, ์๋๋ฉด false๋ก ๋๋ค. -
httpOnlyAllowed๋ฅผ true๋ก ๋๋ค.
fetch์์ ํธ์ถ๋์์ผ๋ฏ๋ก(์:
document.cookiegetter๊ฐ ์๋) true๊ฐ ๋๋ค. -
sameSiteStrictOrLaxAllowed๋ฅผ ๋์ผ ์ฌ์ดํธ ๋ชจ๋ ๊ฒฐ์ (determine the same-site mode) ์ ๊ฒฐ๊ณผ๊ฐ "
strict-or-less"๋ฉด true, ์๋๋ฉด false๋ก ๋๋ค. -
๊ฐ response์ ํค๋ ๋ชฉ๋ก(header list)์ header์ ๋ํ์ฌ:
-
header์ ์ด๋ฆ(name)์ด `
Set-Cookie`์ ๋ฐ์ดํธ ๋์๋ฌธ์ ๋ฌด์(byte-case-insensitive)๋ก ์ผ์นํ์ง ์์ผ๋ฉด continue ํ๋ค. -
์ฟ ํค ํ์ฑ ๋ฐ ์ ์ฅ(Parse and store a cookie)๋ฅผ header์ ๊ฐ(value), isSecure, request์ ํ์ฌ URL์ host, request์ ํ์ฌ URL์ path, httpOnlyAllowed, allowNonHostOnlyCookieForPublicSuffix, sameSiteStrictOrLaxAllowed๋ก ์คํํ๋ค.
-
์ฟ ํค ์ ๋ฆฌ(Garbage collect cookies)๋ฅผ request์ ํ์ฌ URL์ host๋ฅผ ๋๊ฒจ ์คํํ๋ค.
๋ค๋ฅธ ๊ณณ์์๋ ์ธ๊ธ๋ ๊ฒ์ฒ๋ผ `
Set-Cookie` ํค๋๋ ๋ณํฉ๋ ์ ์์ด ๊ฐ ์ธ์คํด์ค๋ณ๋ก ๋ ๋ฆฝ์ ์ผ๋ก ์ฒ๋ฆฌ๋์ด์ผ ํ๋ค. ์ด๋ ๋ค๋ฅธ ์ด๋ค ํค๋์๋ ํ์ฉ๋์ง ์๋๋ค. -
3.1.3. ์ฟ ํค ์ธํ๋ผ(Cookie infrastructure)
์ฃผ์ด์ง request request์ ๋ํด same-site ๋ชจ๋ ๊ฒฐ์ ์ ํ๋ ค๋ฉด:
-
๋จ์ธ(assert): request์ method๊ฐ "
GET" ๋๋ "POST"์์ ๋จ์ธํ๋ค. -
request์ ์ต์์ ๋ค๋น๊ฒ์ด์ ๋ฐ์ ์ ์ถ์ฒ(top-level navigation initiator origin)๊ฐ null์ด ์๋๊ณ request์ URL์ origin๊ณผ same site๊ฐ ์๋๋ฉด "
unset-or-less"๋ฅผ ๋ฐํํ๋ค. -
request์ method๊ฐ "
GET"์ด๊ณ , request์ destination์ด "document"์ด๋ฉด "lax-or-less"๋ฅผ ๋ฐํํ๋ค. -
request์ client์ ๊ต์ฐจ ์ฌ์ดํธ ์์(cross-site ancestor)๊ฐ ์์ผ๋ฉด "
unset-or-less"๋ฅผ ๋ฐํํ๋ค. -
request์ redirect-taint๊ฐ "
cross-site"์ด๋ฉด, "unset-or-less"๋ฅผ ๋ฐํํ๋ค. -
"
strict-or-less"๋ฅผ ๋ฐํํ๋ค.
URL url์ ๋ํด ์ง๋ ฌํ๋ ์ฟ ํค ๊ธฐ๋ณธ ๊ฒฝ๋ก(serialized cookie default path)๋ฅผ ์ป์ผ๋ ค๋ฉด:
-
cloneURL์ url์ ๋ณต์ ๋ณธ์ผ๋ก ๋๋ค.
-
cloneURL์ ๊ฒฝ๋ก(path)๋ฅผ ์ฟ ํค ๊ธฐ๋ณธ ๊ฒฝ๋ก(cookie default path)๋ก ์ค์ ํ๋ค. (๋์์ cloneURL์ ๊ฒฝ๋ก(path)์)
-
cloneURL์ URL ๊ฒฝ๋ก ์ง๋ ฌํ(URL path serialization)๋ฅผ ๋ฐํํ๋ค.
3.2. `Origin` ํค๋
`Origin`
์์ฒญ header๋
fetch๊ฐ
์ด๋์ ์์๋์๋์ง๋ฅผ ๋ํ๋
๋๋ค.
`Origin` ํค๋๋ ๊ฒฝ๋ก๋ฅผ ๋๋ฌ๋ด์ง ์๋
`Referer` [sic] ํค๋์ ํ ๋ฒ์ ์ด๋ค. ์ด๋
HTTP fetch ์ค์์
์์ฒญ์
์๋ต ์ค์ผ์ด "cors"์ธ ๋ชจ๋ ๊ฒฝ์ฐ์,
์์ฒญ์ ๋ฉ์๋๊ฐ
`GET`๋
`HEAD`๋ ์๋ ๊ฒฝ์ฐ์ ์ฌ์ฉ๋๋ค. ํธํ์ฑ ์ ์ฝ์ผ๋ก ์ธํด ๋ชจ๋
fetch์ ํฌํจ๋์ง๋ ์๋๋ค.
๊ทธ ๊ฐ๋ฅํ ๊ฐ์ ์์ฒญ์ด ์ฃผ์ด์ก์ ๋ ์์ฒญ ์ถ์ฒ๋ฅผ ๋ฐ์ดํธ ์ง๋ ฌํํ๊ธฐ์ ๋ชจ๋ ๋ฐํ ๊ฐ์ด๋ค. ์ด๋ค์ ๋ค์ ABNF๋ก ํํ๋๋ค:
serialized-ipv4 = dec-octet "." dec-octet "." dec-octet "." dec-octet
dec-octet = DIGIT ; 0-9
/ %x31-39 DIGIT ; 10-99
/ "1" 2 DIGIT ; 100-199
/ "2" %x30-34 DIGIT ; 200-249
/ "25" %x30-35 ; 250-255
serialized-ipv6 = 7 ( h16 ":" ) h16
/ "::" 5 ( h16 ":" ) h16
/ [ h16 ] "::" 4 ( h16 ":" ) h16
/ [ *1 ( h16 ":" ) h16 ] "::" 3 ( h16 ":" ) h16
/ [ *2 ( h16 ":" ) h16 ] "::" 2 ( h16 ":" ) h16
/ [ *3 ( h16 ":" ) h16 ] "::" h16 ":" h16
/ [ *4 ( h16 ":" ) h16 ] "::" h16
/ [ *5 ( h16 ":" ) h16 ] "::"
h16 = "0" / ( non-zero-hex 0*3 hex )
non-zero-hex = %x31-39 / %x61-66 ; '1'-'9' or lowercase 'a'-'f'
hex = %x30-39 / %x61-66 ; '0'-'9' or lowercase 'a'-'f
lower-alpha = %x61-7A
lower-alphanum = lower-alpha / DIGIT
domain-label = lower-alphanum / ( lower-alphanum * ( lower-alphanum / "-" ) lower-alphanum )
serialized-domain = * ( domain-label "." ) domain-label
serialized-scheme = lower-alpha * ( lower-alphanum / "+" / "-" / "." )
serialized-host = serialized-ipv4 / "[" serialized-ipv6 "]" / serialized-domain
serialized-port = 1*5 DIGIT
serialized-origin = serialized-scheme "://" serialized-host [ ":" serialized-port ]
origin-or-null = serialized-origin / %s"null" ; case-sensitive
Origin = origin-or-null
์ด๋ The Web Origin Concept์ ์ ์๋ฅผ ๋์ฒดํ๋ค. [ORIGIN]
์ฌ๊ธฐ์์ ์ ์ํ ์ถ์ฒ ์ง๋ ฌํ๋ [RFC3986]์ ๋ฌธ๋ฒ๋ณด๋ค ๋ ๊ฐ์ง ์ค์ํ ๋ฐฉ์์์ ๋ ์ ํ์ ์ด๋ค. ์ฒซ์งธ, ์คํด ๋ฐ ๋๋ฉ์ธ ์ง๋ ฌํ๋ ๋ชจ๋ ์๋ฌธ์ ASCII์ด๋ฉฐ, ํผ์ผํธ ์ธ์ฝ๋ฉ์ ์ฌ์ฉํ์ง ์๋๋ค. ๋์งธ, URL ยง 3.6 Host serializing ๋ฐ [RFC5952]์ ๊ถ๊ณ ์ ๋ฐ๋ผ, IPv6 ์ฃผ์๋ ๋ค์๊ณผ ๊ฐ์ด ์ ํ๋๋ค:
- ์ตํ์ ์๋ฆฟ์๋ IPv4 ์ฃผ์๋ก ํํํ ์ ์๋ค.
- ์ ํ 0์ ๊ธ์ง๋๋ค.
- ๋ชจ๋ 16์ง์ ๋ฌธ์๋ ์๋ฌธ์์ด๋ค.
- "::"๋ ๋จ์ผ "0" ๋ธ๋ก๋ง์ ์๋ตํ ์ ์์ผ๋ฏ๋ก, "::"๊ฐ ์๋ ๊ฒฝ์ฐ ์ต๋ 6๊ฐ ๋ธ๋ก๋ง ํ์ฉํ๋ค.
์์ฒญ
`Origin` ํค๋ ์ถ๊ฐ๋ฅผ ํ๋ ค๋ฉด,
request
request์ ๋ํด ์๋ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
serializedOrigin์ byte-serializing a request origin (request ์ฌ์ฉ) ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๋ง์ฝ request์ response tainting์ด "
cors"์ด๊ฑฐ๋, request์ mode๊ฐ "websocket" ๋๋ "webtransport"๋ผ๋ฉด, append (`Origin`, serializedOrigin)์ request์ header list์ ์ถ๊ฐํฉ๋๋ค. -
๊ทธ ์ธ์, request์ method๊ฐ `
GET`์ด๋ `HEAD`๊ฐ ์๋๋ผ๋ฉด:-
request์ mode๊ฐ "
cors"๊ฐ ์๋๋ผ๋ฉด, request์ referrer policy์ ๋ฐ๋ผ ์๋๋ฅผ ์ํํฉ๋๋ค:- "
no-referrer" -
serializedOrigin์ `
null`๋ก ์ค์ ํฉ๋๋ค. - "
no-referrer-when-downgrade"- "
strict-origin"- "
strict-origin-when-cross-origin" - "
-
๋ง์ฝ request์ origin์ด tuple origin์ด๊ณ , ๊ทธ scheme์ด "
https"์ด๋ฉฐ, request์ current URL์ scheme์ด "https"๊ฐ ์๋๋ผ๋ฉด, serializedOrigin์ `null`๋ก ์ค์ ํฉ๋๋ค. - "
same-origin" -
request์ ์ถ์ฒ๊ฐ ๋์ผ ์ถ์ฒ๊ฐ ์๋๋ฉฐ request์ ํ์ฌ URL์ ์ถ์ฒ์ ๊ฐ์ง ์์ผ๋ฉด, serializedOrigin์ `
null`๋ก ์ค์ ํฉ๋๋ค. - ๊ทธ ์ธ
- ์๋ฌด ๋์๋ ํ์ง ์์.
- "
-
Append (`
Origin`, serializedOrigin)์ request์ header list์ ์ถ๊ฐํฉ๋๋ค.
-
์์ฒญ์ ๋ฆฌํผ๋ฌ ์ ์ฑ ์ fetcher๊ฐ ์๋ฒ์ ์์ ์ origin์ ๊ณต์ ํ๊ฒ ๋ค๊ณ ๋ช ์์ ์ผ๋ก ์ ํํ์ง ์์ ๋ชจ๋ fetch์์ ๊ณ ๋ ค๋๋ค. ์๋ฅผ ๋ค์ด CORS ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
3.3. CORS ํ๋กํ ์ฝ
์๋ต์ ๊ต์ฐจ ์ถ์ฒ(cross-origin)๋ก ๊ณต์ ํ ์ ์๊ฒ ํ๊ณ HTML์
form
์์๋ก๋ ๋ถ๊ฐ๋ฅํ ๋ ๋ค์ํ fetch๋ฅผ ์ํด,
CORS ํ๋กํ ์ฝ์ด ์กด์ฌํ๋ค.
CORS๋ HTTP ์์ ๊ณ์ธตํ๋์ด ์์ผ๋ฉฐ, ์๋ต์ด ๋ค๋ฅธ
์ถ์ฒ(origin)์ ๊ณต์ ๋ ์ ์์์ ์ ์ธํ๋๋ก ํ๋ค.
์ด ๋ฉ์ปค๋์ฆ์ ๋ฐฉํ๋ฒฝ(์ธํธ๋ผ๋ท) ๋ค์ ์๋ต ๋ฐ์ดํฐ๊ฐ ์ ์ถ๋๋ ๊ฒ์ ๋ง๊ธฐ ์ํด opt-in์ด์ด์ผ ํ๋ค. ๋ํ ์์ฒญ(request)์ด ์ธ์ฆ์ ๋ณด(credentials)๋ฅผ ํฌํจํ ๋, ๋ฏผ๊ฐํ ์ ์๋ ๋ฐ์ดํฐ๊ฐ ์ ์ถ๋์ง ์๋๋ก opt-in์ด์ด์ผ ํ๋ค.
์ด ์ ์์๋ ์๋ฒ ๊ฐ๋ฐ์๋ฅผ ์ํ CORS ํ๋กํ ์ฝ์ ๋ด์ฉ์ ์ค๋ช ํ๋ค. ์ฌ์ฉ์ ์์ด์ ํธ์ ๋ํ ์๊ตฌ์ฌํญ์ fetch ์๊ณ ๋ฆฌ์ฆ์ ์ผ๋ถ์ด๋ฉฐ, ์๋ก์ด HTTP ํค๋ ๋ฌธ๋ฒ์ ์์ธ๋ค.
3.3.1. ์ผ๋ฐ
CORS ํ๋กํ ์ฝ์ ์๋ต์ด ๊ต์ฐจ ์ถ์ฒ๋ก ๊ณต์ ๋ ์ ์๋์ง๋ฅผ ๋ํ๋ด๋ ์ผ๋ จ์ ํค๋๋ก ๊ตฌ์ฑ๋์ด ์๋ค.
HTML์
form
์์๋ก ๊ฐ๋ฅํ ๊ฒ๋ณด๋ค ๋ ๋ณต์กํ ์์ฒญ์
๋ํด์๋,
CORS-preflight
request๊ฐ ์ํ๋์ด, ์์ฒญ์
ํ์ฌ
URL์ด CORS ํ๋กํ ์ฝ์ ์ง์ํ๋์ง
๋ณด์ฅํ๋ค.
3.3.2. HTTP ์์ฒญ
CORS ์์ฒญ์ด๋
`Origin`
ํค๋๋ฅผ ํฌํจํ๋ HTTP ์์ฒญ์ ๋งํ๋ค.
์ด ํค๋๋ CORS ํ๋กํ ์ฝ์ ์ฐธ์ฌํ๋์ง ์ ๋ขฐ์ฑ ์๊ฒ
ํ๋ณํ ์ ์๋ ๊ธฐ์ค์ด ๋์ง ์๋๋ค. ์๋ํ๋ฉด
`Origin`
ํค๋๋ request์ method๊ฐ
`GET` ๋๋
`HEAD`๊ฐ ์๋ ๋ชจ๋ ๊ฒฝ์ฐ์๋ ํฌํจ๋๊ธฐ ๋๋ฌธ์ด๋ค.
CORS-์ฌ์
์์ฒญ(CORS-preflight request)์ด๋ CORS ์์ฒญ์ผ๋ก,
CORS ํ๋กํ ์ฝ์ด ์ ์ฉ ๊ฐ๋ฅํ์ง ํ์ธํ๋ ์ญํ ์
ํ๋ค.
์ด ๋ method๋
`OPTIONS`์ด๊ณ ๋ค์ ํค๋๊ฐ ํฌํจ๋๋ค:
- `
Access-Control-Request-Method` -
์ดํ์ ๋์ผ ๋ฆฌ์์ค์ ๋ํด ํ CORS ์์ฒญ์ด ์ด๋ค method๋ฅผ ์ฌ์ฉํ ์ ์๋์ง ๋ํ๋ธ๋ค.
CORS-์ฌ์ ์์ฒญ์๋ ๋ค์ ํค๋๋ ํฌํจ๋ ์ ์๋ค:
- `
Access-Control-Request-Headers` -
์ดํ์ ๋์ผ ๋ฆฌ์์ค์ ๋ํด ํ CORS ์์ฒญ์ด ์ด๋ค ํค๋๋ฅผ ์ฌ์ฉํ ์ ์๋์ง ๋ํ๋ธ๋ค.
3.3.3. HTTP ์๋ต
CORS ์์ฒญ์ ๋ํ HTTP ์๋ต์๋ ๋ค์ ํค๋๋ฅผ ํฌํจํ ์ ์๋ค:
- `
Access-Control-Allow-Origin` -
์๋ต์์ `
Origin` ์์ฒญ ํค๋์ ๋ฆฌํฐ๋ด ๊ฐ (์ด๋ `null`์ผ ์ ์์) ๋๋ `*`๋ฅผ ๋ฐํํจ์ผ๋ก์จ, ์๋ต์ ๊ณต์ ํ ์ ์๋์ง๋ฅผ ๋ํ๋ธ๋ค. - `
Access-Control-Allow-Credentials` -
์์ฒญ์ ์๊ฒฉ ์ฆ๋ช ๋ชจ๋๊ฐ "
include"์ผ ๋ ์๋ต์ ๊ณต์ ํ ์ ์๋์ง๋ฅผ ๋ํ๋ธ๋ค.CORS-preflight request์ ๊ฒฝ์ฐ, ์์ฒญ์ ์๊ฒฉ ์ฆ๋ช ๋ชจ๋๋ ํญ์ "
same-origin"์ด๋ค. ์ฆ, ์๊ฒฉ ์ฆ๋ช ์ ์ ์ธํ์ง๋ง, ์ดํ์ ์ด๋ค CORS ์์ฒญ์์๋ ๊ทธ๋ ์ง ์์ ์๋ ์๋ค. ๋ฐ๋ผ์ ์ง์ ์ฌ๋ถ๋ CORS-preflight request์ ๋ํ HTTP ์๋ต์ ์ผ๋ถ๋ก๋ ํ์๋์ด์ผ ํ๋ค.
CORS-preflight request์ ๋ํ HTTP ์๋ต์ ๋ค์ ํค๋๋ค์ ํฌํจํ ์ ์๋ค:
- `
Access-Control-Allow-Methods` -
CORS ํ๋กํ ์ฝ์ ๋ชฉ์ ์, ์๋ต์ URL์ด ์ด๋ค ๋ฉ์๋๋ฅผ ์ง์ํ๋์ง๋ฅผ ๋ํ๋ธ๋ค.
`
Allow` ํค๋๋ CORS ํ๋กํ ์ฝ์ ๋ชฉ์ ์ ๊ด๋ จ์ด ์๋ค. - `
Access-Control-Allow-Headers` -
CORS ํ๋กํ ์ฝ์ ๋ชฉ์ ์, ์๋ต์ URL์ด ์ด๋ค ํค๋๋ฅผ ์ง์ํ๋์ง๋ฅผ ๋ํ๋ธ๋ค.
- `
Access-Control-Max-Age` -
`
Access-Control-Allow-Methods` ๋ฐ `Access-Control-Allow-Headers` ํค๋๋ค์ด ์ ๊ณตํ ์ ๋ณด๋ฅผ ์บ์ํ ์ ์๋ ์ด ์(๊ธฐ๋ณธ๊ฐ์ 5)๋ฅผ ๋ํ๋ธ๋ค.
CORS ์์ฒญ์ด๋ฉด์ CORS-์ฌ์ ์์ฒญ์ด ์๋ ๊ฒฝ์ฐ, ๋ค์ ํค๋๋ ํฌํจํ ์ ์๋ค:
- `
Access-Control-Expose-Headers` -
์๋ต์ ์ผ๋ถ๋ก ๋ ธ์ถ๋ ์ ์๋ ํค๋๋ฅผ ๊ทธ ์ด๋ฆ๋ค์ ๋์ดํ์ฌ ํ์ํ๋ค.
์๋ฒ ๊ฐ๋ฐ์๊ฐ ๊ณต์ ์๋๊ฐ ์๋ CORS ์์ฒญ์ ๋ํ ์ฑ๊ณต์ ์ธ HTTP ์๋ต์, ์์ ๋ช ์๋ ํค๋๋ฅผ ์์ฒญ์ ๋ง๋ ๊ฐ์ผ๋ก ํฌํจํ๊ธฐ๋ง ํ๋ฉด ์ด๋ค status๋ ์ฌ์ฉํ ์ ์๋ค.
CORS-์ฌ์ ์์ฒญ์ ๋ํ ์ฑ๊ณต์ ์ธ HTTP ์๋ต๋ ์ ์ฌํ๋, ok status (์: 200 ๋๋ 204)๋ก ์ ํ๋๋ค.
๊ทธ ์ธ์ HTTP ์๋ต์ ์ฑ๊ณต์ ์ด์ง ์์ผ๋ฉฐ, ๊ณต์ ๊ฐ ๋ถ๊ฐ๋ฅํ๊ฑฐ๋ CORS-์ฌ์ ์์ฒญ์ ์คํจํ๋ค. ์๋ฒ์์ ์ํํ ์์ ์ด ํ์ด๋ฐ ๋ฑ ๋ถ์ฑ๋๋ก ๋์ถ๋ ์ ์์์ ์ ์ํด์ผ ํ๋ค. ์๋ฒ ๊ฐ๋ฐ์๊ฐ ์ด๋ฅผ ๋ช ์์ ์ผ๋ก ๋ํ๋ด๊ณ ์ถ๋ค๋ฉด, 403 status์ ๊ด๋ จ ํค๋์ ์๋ต์ ํจ๊ป ์ฌ์ฉํ ์ ์๋ค.
์ํ๋ค๋ฉด "์คํจ"๋ ๊ณต์ ํ ์ ์์ง๋ง, ๊ทธ๋ฌ๋ฉด ์ฑ๊ณต์ ์ธ HTTP ์๋ต์ด ๋ฉ๋๋ค. ๊ทธ๋ ๊ธฐ ๋๋ฌธ์ CORS ์์ฒญ์ ๋ํ ์ฑ๊ณต์ ์ธ HTTP ์๋ต์ด CORS ์ฌ์ ์์ฒญ์ด ์๋ ๊ฒฝ์ฐ, ์ํ๋ 403์ ํฌํจํ์ฌ ์ด๋ค ๊ฐ์ด๋ ๋ ์ ์์ต๋๋ค.
๊ฒฐ๊ตญ ์๋ฒ ๊ฐ๋ฐ์๋ HTTP ์๋ต ์ฒ๋ฆฌ ๋ฐฉ์์์ ๋ง์ ์์ ๋ฅผ ๊ฐ์ง๋ฉฐ, ์ด๋ฌํ ์ ๋ต์ CORS-์ฌ์ ์์ฒญ๊ณผ ๊ทธ ์ดํ CORS ์์ฒญ์ ์๋ต ์ฒ๋ฆฌ ๋ฐฉ์์ด ๋ค๋ฅผ ์ ์๋ค:
-
์ ์ ์๋ต์ ์ ๊ณตํ ์ ์๋ค. ์ด๋ ์บ์ ์ค๊ฐ์์ ํจ๊ป ์์ ํ ๋ ์ ์ฉํ๋ค. ์ ์ ์๋ต์ CORS ์์ฒญ์ ๋ฐ๋ผ ์ฑ๊ณต์ด๊ฑฐ๋ ์๋ ์ ์๋ค. ์ด๋ ํ์ฉ๋๋ค.
-
CORS ์์ฒญ์ ๋ง๊ฒ ์กฐ์ ํ ๋์ ์๋ต์ ์ ๊ณตํ ์ ์๋ค. ์ด๋ ์๋ต ๋ณธ๋ฌธ์ ํน์ origin์ ๋ง๊ฒ ์กฐ์ ํ๊ฑฐ๋ credentials๊ฐ ํ์ํ๊ณ ์ฌ๋ฌ origin์ ๋ํด ์ฑ๊ณต์ ์ด์ด์ผ ํ ๋ ์ ์ฉํ๋ค.
3.3.4. HTTP new-header ๋ฌธ๋ฒ
ABNF: CORS ํ๋กํ ์ฝ์์ ์ฌ์ฉํ๋ ํค๋์ ๊ฐ์ ๋ํ ๊ฒ:
Access-Control-Request-Method = method
Access-Control-Request-Headers = 1 #field-name
wildcard = "*"
Access-Control-Allow-Origin = origin-or-null / wildcard
Access-Control-Allow-Credentials = %s"true" ; case-sensitive
Access-Control-Expose-Headers = #field-name
Access-Control-Max-Age = delta-seconds
Access-Control-Allow-Methods = #method
Access-Control-Allow-Headers = #field-name
`Access-Control-Expose-Headers`,
`Access-Control-Allow-Methods`, ๊ทธ๋ฆฌ๊ณ `Access-Control-Allow-Headers`
์๋ต ํค๋์ ๊ฒฝ์ฐ, ๊ฐ
`*`๋ ์๊ฒฉ ์ฆ๋ช
์ด ์๋
์์ฒญ์ ๋ํด
์์ผ๋์นด๋๋ก ๊ฐ์ฃผ๋๋ค. ๊ทธ๋ฌํ ์์ฒญ์์๋
`*`์ธ ํค๋ ์ด๋ฆ
๋๋ ๋ฉ์๋๋ง์
์ผ์น์ํฌ ๋ฐฉ๋ฒ์ด ์๋ค.
3.3.5. CORS ํ๋กํ ์ฝ๊ณผ credentials
์์ฒญ์
์๊ฒฉ ์ฆ๋ช
๋ชจ๋๊ฐ "include"์ผ ๋, ์ด๋
fetch์
์๊ฒฉ ์ฆ๋ช
์ ํฌํจํ๋ ๊ฒ ์ธ์๋
CORS ํ๋กํ ์ฝ์ ์๋์ ์ํฅ์ ์ค๋ค.
์์ ์๋ XMLHttpRequest๋ฅผ
์ฌ์ฉํ์ฌ ์์ฒญ์
์๊ฒฉ ์ฆ๋ช
๋ชจ๋๋ฅผ "include"๋ก ์ค์ ํ ์ ์์๋ค:
var client = new XMLHttpRequest()
client. open( "GET" , "./" )
client. withCredentials = true
/* โฆ */
์ค๋๋ ์๋ fetch("./", { credentials:"include" }).then(/* โฆ */)์ด๋ฉด
์ถฉ๋ถํ๋ค.
์์ฒญ์ ์๊ฒฉ ์ฆ๋ช ๋ชจ๋๊ฐ ๋ฐ๋์ ์๋ฒ์์ ๊ด์ฐฐ ๊ฐ๋ฅํ ๊ฒ์ ์๋๋ค. ์์ฒญ์ ๋ํด ์๊ฒฉ ์ฆ๋ช ์ด ์กด์ฌํ ๋์๋ง, ๊ทธ ์๊ฒฉ ์ฆ๋ช ์ด ํฌํจ๋จ์ผ๋ก์จ ๊ด์ฐฐ๋ ์ ์๋ค. ๊ทธ๋ผ์๋ CORS-preflight request์๋ ์๊ฒฉ ์ฆ๋ช ์ด ์ ๋ ํฌํจ๋์ง ์๋๋ค๋ ์ ์ ์ ์ํ๋ผ.
๋ฐ๋ผ์ ์๋ฒ ๊ฐ๋ฐ์๋ ์๊ฒฉ ์ฆ๋ช ์ผ๋ก "์ค์ผ๋" ์๋ต์ ๊ณต์ ํ ์ ์๋์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํด์ผ ํ๋ค. ๋ํ CORS-preflight request๋ฅผ ํ์๋ก ํ๋ ์์ฒญ์ด ์๊ฒฉ ์ฆ๋ช ์ ํฌํจํ ์ ์๋์ง๋ ๊ฒฐ์ ํด์ผ ํ๋ค. ์ผ๋ฐ์ ์ผ๋ก ๋งํด, ์๋ต์ ๊ณต์ ํ๋ ๊ฒ๊ณผ ์๊ฒฉ ์ฆ๋ช ์ด ์๋ ์์ฒญ์ ํ์ฉํ๋ ๊ฒ์ ๋ชจ๋ ์๋นํ ์์ ํ์ง ์์ผ๋ฉฐ, ํผ๋๋ ๋๋ฆฌ์ ๋ฌธ์ ๋ฅผ ํผํ๋ ค๋ฉด ๊ทน๋์ ์ฃผ์๊ฐ ํ์ํ๋ค.
์๊ฒฉ ์ฆ๋ช
์ด ์๋ ์๋ต์ ๊ณต์ ํ๋ ค๋ฉด,
`Access-Control-Allow-Origin` ๋ฐ
`Access-Control-Allow-Credentials` ํค๋๊ฐ
์ค์ํ๋ค. ๋ค์ ํ๋ https://rabbit.invalid/์ ๋ํ ์์ฒญ์์ ๋ค์ํ ํฉ๋ฒ ๋ฐ ๋ถ๋ฒ ์กฐํฉ์
์ค๋ช
ํ๊ธฐ ์ํ ๊ฒ์ด๋ค:
| ์์ฒญ์ ์๊ฒฉ ์ฆ๋ช ๋ชจ๋ | `Access-Control-Allow-Origin`
| `Access-Control-Allow-Credentials`
| ๊ณต์ ๋จ? | ๋น๊ณ |
|---|---|---|---|---|
"omit"
| `*`
| ์๋ต๋จ | โ | โโ |
"omit"
| `*`
| `true`
| โ | ์๊ฒฉ ์ฆ๋ช
๋ชจ๋๊ฐ "include"๊ฐ ์๋๋ฉด,
`Access-Control-Allow-Credentials`๋
๋ฌด์๋๋ค.
|
"omit"
| `https://rabbit.invalid/`
| ์๋ต๋จ | โ | ์ง๋ ฌํ๋ origin์๋ ๋ค๋ฐ๋ฅด๋ ์ฌ๋์๊ฐ ์๋ค. |
"omit"
| `https://rabbit.invalid`
| ์๋ต๋จ | โ | โโ |
"include"
| `*`
| `true`
| โ | ์๊ฒฉ ์ฆ๋ช
๋ชจ๋๊ฐ "include"์ด๋ฉด,
`Access-Control-Allow-Origin`์
`*`์ผ ์ ์๋ค.
|
"include"
| `https://rabbit.invalid`
| `true`
| โ | โโ |
"include"
| `https://rabbit.invalid`
| `True`
| โ | `true`๋ (๋ฐ์ดํธ ๊ธฐ์ค) ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๋ค.
|
๋ง์ฐฌ๊ฐ์ง๋ก, `Access-Control-Expose-Headers`,
`Access-Control-Allow-Methods`, ๊ทธ๋ฆฌ๊ณ
`Access-Control-Allow-Headers` ์๋ต
ํค๋๋ ์์ฒญ์ ์๊ฒฉ ์ฆ๋ช
๋ชจ๋๊ฐ
"include"๊ฐ ์๋ ๋์๋ง
`*`๋ฅผ ๊ฐ์ผ๋ก ์ฌ์ฉํ ์ ์๋ค.
3.3.6. ์์
https://foo.invalid/์ ์๋ ์คํฌ๋ฆฝํธ๊ฐ https://bar.invalid/์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ถ์ด ํ๋ค. (credentials๋ ์๋ต ํค๋ ์ ๊ทผ์ ์ค์ํ์ง
์๋ค.)
var url = "https://bar.invalid/api?key=730d67a37d7f3d802e96396d00280768773813fbe726d116944d814422fc1a45&data=about:unicorn" ;
fetch( url). then( success, failure)
์ด ๊ฒฝ์ฐ CORS ํ๋กํ ์ฝ์ด ์ฌ์ฉ๋์ง๋ง,
foo.invalid์ ๊ฐ๋ฐ์์๊ฒ๋ ์์ ํ ํฌ๋ช
ํ๋ค. CORS ํ๋กํ ์ฝ์ ์ผ๋ถ๋ก, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์์ฒญ์ `Origin` ํค๋๋ฅผ ํฌํจํ๋ค:
Origin: https://foo.invalid
bar.invalid๋ก๋ถํฐ ์๋ต์ ๋ฐ์ ํ, ์ฌ์ฉ์ ์์ด์ ํธ๋ `Access-Control-Allow-Origin` ์๋ต ํค๋๋ฅผ
ํ์ธํ๋ค. ๊ฐ์ด `https://foo.invalid` ๋๋ `*`๋ผ๋ฉด success ์ฝ๋ฐฑ์ ํธ์ถํ๋ค. ๊ทธ ์ธ์ด๊ฑฐ๋
ํด๋น ํค๋๊ฐ ์์ผ๋ฉด failure ์ฝ๋ฐฑ์ ํธ์ถํ๋ค.
foo.invalid์ ๊ฐ๋ฐ์๊ฐ ๋ค์ ๋ํ๋, ์ด๋ฒ์ bar.invalid์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ฉด์ ์๋ต ํค๋์ ์ ๊ทผํ๊ณ ์ ํ๋ค.
fetch( url). then( response => {
var hsts = response. headers. get( "strict-transport-security" ),
csp = response. headers. get( "content-security-policy" )
log( hsts, csp)
})
bar.invalid์ ์์ ์์์์์ ๊ฐ์ด ์ฌ๋ฐ๋ฅธ `Access-Control-Allow-Origin` ์๋ต ํค๋๋ฅผ
์ ๊ณตํ๋ค. hsts์ csp ๊ฐ์ `Access-Control-Expose-Headers` ์๋ต
ํค๋์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋ค. ์๋ฅผ ๋ค์ด, ์๋ต์ ๋ค์๊ณผ ๊ฐ์ ํค๋๊ฐ ์๋ค๋ฉด
Content-Security-Policy: default-src 'self'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Access-Control-Expose-Headers: Content-Security-Policy
์ด ๊ฒฝ์ฐ hsts๋ null, csp๋ "default-src 'self'"๊ฐ ๋๋ค. ๋ ํค๋ ๋ชจ๋ ์๋ต์ ํฌํจ๋์ด
์์ง๋ง, bar.invalid๊ฐ `Access-Control-Expose-Headers` ์๋ต
ํค๋์ ์ด๋ฆ์ ๋ช
์์ ์ผ๋ก ๋์ดํด ๊ณต์ ํด์ผ ํ๊ธฐ ๋๋ฌธ์ด๋ค.
๋ฐ๋๋ก, bar.invalid์ด credentials๋ฅผ ํฌํจํ์ง ์๋ ์์ฒญ์ ๋ํด ์๋ต ํค๋ ์ ์ฒด๋ฅผ ๊ณต์ ํ๊ณ ์ถ๋ค๋ฉด, `Access-Control-Expose-Headers` ์๋ต
ํค๋ ๊ฐ์ผ๋ก `*`๋ฅผ ์ฌ์ฉํ ์ ์๋ค. credentials๊ฐ ํฌํจ๋ ์์ฒญ์ ๊ฒฝ์ฐ์๋ ํค๋ ์ด๋ฆ์ ๋ช
์์ ์ผ๋ก ๋์ดํด์ผ ํ๋ฉฐ `*`๋ ์ฌ์ฉํ
์ ์๋ค.
foo.invalid์ ๊ฐ๋ฐ์๊ฐ ๋ค์ ๋์์, ์ด๋ฒ์๋ credentials๋ฅผ ํฌํจํด bar.invalid์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์จ๋ค. ์ด ๊ฒฝ์ฐ CORS ํ๋กํ ์ฝ์ด ๊ฐ๋ฐ์์๊ฒ ํฌ๋ช
ํ์ง
์๋ค. credentials๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ช
์์ ์ผ๋ก
opt-in์ด ํ์ํ๊ธฐ ๋๋ฌธ์ด๋ค:
fetch( url, { credentials: "include" }). then( success, failure)
์ด ๊ฒฝ์ฐ bar.invalid์ `Set-Cookie` ์๋ต ํค๋๋ ์์ ํ ๋์ํ๋ค(๊ทธ๋ ์ง ์์ผ๋ฉด ๋ฌด์๋จ).
์ฌ์ฉ์ ์์ด์ ํธ๋ ์์ฒญ์ ํ์ํ credentials๋
๋ชจ๋ ํฌํจ์ํจ๋ค.
๋ํ ์๋ต์๋ ๋ ์๊ฒฉํ ์๊ตฌ์ฌํญ์ด ์ ์ฉ๋๋ค. bar.invalid๋ ๋ฐ๋์ `https://foo.invalid` ๊ฐ์ ๊ฐ์ง `Access-Control-Allow-Origin` ํค๋์,
`Access-Control-Allow-Credentials`
ํค๋๋ ํฌํจํด์ผ ํ๋ค(`*`๋ credentials๊ฐ ์์ ๋ ํ์ฉ๋์ง ์์):
Access-Control-Allow-Origin: https://foo.invalid
Access-Control-Allow-Credentials: true
์๋ต์ ์ด ๋ ํค๋๊ฐ ํด๋น ๊ฐ์ผ๋ก ํฌํจ๋์ด ์์ง ์์ผ๋ฉด failure ์ฝ๋ฐฑ์ด ํธ์ถ๋๋ค. ๋จ, `Set-Cookie` ์๋ต ํค๋๋ ํญ์
์ ์ฉ๋๋ค.
3.3.7. CORS ํ๋กํ ์ฝ ์์ธ
๋ช
์ธ์ ๋ฐ๋ผ CORS safelist์ ํฌํจ๋์ง ์์ `Content-Type` ํค๋ ๊ฐ์ ๋ํด ์ ํ์ ์ธ ์์ธ๊ฐ ํ์ฉ๋์ด ์๋ค. ์ด๋ฌํ ์์ธ๋ ์น ์ฝํ
์ธ ๊ฐ ํธ๋ฆฌ๊ฑฐํ ์
์์ง๋ง, ์น ์ฝํ
์ธ ๊ฐ ํค๋์ ๋ณธ๋ฌธ์ ์ต์ํ์ผ๋ก๋ง ์ ์ดํ ์ ์๋ ์์ฒญ์ ํํด์ ๋ง๋ค์ด์ง ๊ฒ์ด๋ค. ๋ฐ๋ผ์ ์๋ฒ๋ ๊ต์ฐจ ์ถ์ฒ ์น ์ฝํ
์ธ ๊ฐ ๋ค์๊ณผ ๊ฐ์ safelist์ ์๋
`Content-Type` ํค๋ ๊ฐ์ผ๋ก ์ฌ์ ์์ฒญ(preflight) ์์ด ์์ฒญ์ ํธ๋ฆฌ๊ฑฐํ ์ ์์์ ์์ํด์ผ ํ๋ค:
- `
application/csp-report` [CSP] - `
application/expect-ct-report+json` [RFC9163] - `
application/xss-auditor-report` - `
application/ocsp-request` [RFC6960]
๋ช ์ธ์์๋ ์ ์์ธ ๋์ ์ ํผํด์ผ ํ๋ฉฐ, ๋ฐ๋์ ์ ์คํ ๋ณด์ ์ํฅ์ ๊ณ ๋ คํ์ฌ์ผ ํ๋ค. ์๋ก์ด ์์ธ๋ ์ด์ ๋ฑ๋ก์ ํตํด ์ ์ํ ์ ์๋ค.
3.4. `Content-Length` ํค๋
`Content-Length` ํค๋๋ ์ฃผ๋ก HTTP์์ ์ ์๋์ด ์๋ค. HTTP์์ ์ ์๋ ์ฒ๋ฆฌ ๋ชจ๋ธ์ด ์น ์ฝํ
์ธ ์ ํธํ๋์ง ์์ผ๋ฏ๋ก ์ฌ๊ธฐ์ ์ฒ๋ฆฌ ๋ชจ๋ธ์ ์ ์ํ๋ค. [HTTP]
๊ธธ์ด ์ถ์ถ(extract a length) ์๊ณ ๋ฆฌ์ฆ์ header list headers์์ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
values๋ฅผ getting, decoding, and splitting `
Content-Length` from headers์ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
values๊ฐ null์ด๋ฉด null์ ๋ฐํํ๋ค.
-
candidateValue๋ฅผ null๋ก ๋๋ค.
-
๊ฐ values์ value์ ๋ํด:
-
candidateValue๊ฐ null์ด๋ฉด candidateValue์ value๋ฅผ ํ ๋นํ๋ค.
-
์๋๋ผ๋ฉด value๊ฐ candidateValue์ ๋ค๋ฅด๋ฉด failure๋ฅผ ๋ฐํํ๋ค.
-
-
candidateValue๊ฐ ๋น ๋ฌธ์์ด์ด๊ฑฐ๋, code point ์ค ASCII digit์ด ์๋ ๊ฒ์ด ์์ผ๋ฉด null์ ๋ฐํํ๋ค.
-
candidateValue๋ฅผ 10์ง์ ์ซ์๋ก ํด์ํ์ฌ ๋ฐํํ๋ค.
3.5. `Content-Type` ํค๋
`Content-Type` ํค๋๋ ์ฃผ๋ก HTTP์์ ์ ์๋์ด ์๋ค. HTTP์์ ์ ์๋ ์ฒ๋ฆฌ ๋ชจ๋ธ์ด ์น ์ฝํ
์ธ ์ ํธํ๋์ง ์์ผ๋ฏ๋ก ์ฌ๊ธฐ์ ์ฒ๋ฆฌ ๋ชจ๋ธ์ ์ ์ํ๋ค. [HTTP]
MIME ํ์ ์ถ์ถ(extract a MIME type) ์๊ณ ๋ฆฌ์ฆ์ header list headers์์ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค. ๋ฐํ ๊ฐ์ failure ๋๋ MIME ํ์ ์ด๋ค.
-
charset์ null๋ก ๋๋ค.
-
essence๋ฅผ null๋ก ๋๋ค.
-
mimeType์ null๋ก ๋๋ค.
-
values๋ฅผ getting, decoding, and splitting `
Content-Type` from headers์ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
values๊ฐ null์ด๋ฉด failure๋ฅผ ๋ฐํํ๋ค.
-
๊ฐ values์ value์ ๋ํด:
-
temporaryMimeType์ MIME ํ์ ํ์ฑ(parsing) value ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
temporaryMimeType์ด failure์ด๊ฑฐ๋, ๊ทธ essence๊ฐ "
*/*"๋ฉด continueํ๋ค. -
mimeType์ temporaryMimeType์ผ๋ก ๋๋ค.
-
mimeType์ essence๊ฐ essence์ ๋ค๋ฅด๋ฉด:
-
charset์ null๋ก ๋๋ค.
-
mimeType์ parameters["
charset"]๊ฐ ์กด์ฌํ๋ฉด charset์ mimeType์ parameters["charset"] ๊ฐ์ผ๋ก ๋๋ค. -
essence๋ฅผ mimeType์ essence๋ก ๋๋ค.
-
-
์๋๋ผ๋ฉด, mimeType์ parameters["
charset"]๊ฐ ์กด์ฌํ์ง ์๊ณ , charset์ด null์ด ์๋๋ฉด mimeType์ parameters["charset"]๋ฅผ charset์ผ๋ก ๋๋ค.
-
-
mimeType์ด null์ด๋ฉด failure๋ฅผ ๋ฐํํ๋ค.
-
mimeType์ ๋ฐํํ๋ค.
MIME ํ์ ์ถ์ถ์ด failure๋ฅผ ๋ฐํํ๊ฑฐ๋, MIME ํ์ ์ essence๊ฐ ํด๋น ํฌ๋งท์ ๋ํด ๋ถ์ ์ ํ ๊ฒฝ์ฐ, ์ด๋ ์น๋ช ์ ์ค๋ฅ๋ก ๊ฐ์ฃผํ๋ค. ๊ธฐ์กด ์น ํ๋ซํผ ๊ธฐ๋ฅ๋ค์ ํญ์ ์ด ํจํด์ ๋ฐ๋ฅด์ง ์์ ๋ค์์ ๋ณด์ ์ทจ์ฝ์ ์์ธ์ด ๋์ด ์๋ค. ์ด์ ๋ฐํด MIME ํ์ ์ parameters๋ ์ผ๋ฐ์ ์ผ๋ก ๋ฌด์ํด๋ ์์ ํ๋ค.
MIME ํ์ ์ถ์ถ ์๊ณ ๋ฆฌ์ฆ์ ์ค์ ๋์ ์์:
| ํค๋(๋คํธ์ํฌ ์) | ์ถ๋ ฅ(์ง๋ ฌํ(serialized)) |
|---|---|
| text/html
|
| text/html;x=y;charset=gbk
|
| |
| text/html;x=y
|
| text/html
|
| |
|
๋ ๊ฑฐ์ ์ธ์ฝ๋ฉ ์ถ์ถ(legacy extract an encoding) ์๊ณ ๋ฆฌ์ฆ์ failure ๋๋ MIME ํ์ mimeType๊ณผ encoding fallbackEncoding์ด ์ฃผ์ด์ก์ ๋ ๋ค์์ ๋ฐ๋ฅธ๋ค:
-
mimeType์ด failure๋ฉด fallbackEncoding์ ๋ฐํํ๋ค.
-
mimeType["
charset"]์ด ์กด์ฌํ์ง ์์ผ๋ฉด fallbackEncoding์ ๋ฐํํ๋ค. -
tentativeEncoding์ get an encoding ์๊ณ ๋ฆฌ์ฆ์ mimeType["
charset"]์ ๋๊ฒจ ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
tentativeEncoding์ด failure๋ฉด fallbackEncoding์ ๋ฐํํ๋ค.
-
tentativeEncoding์ ๋ฐํํ๋ค.
์ด ์๊ณ ๋ฆฌ์ฆ์ mimeType์ด failure์ผ ์๋ ์๊ฒ ํ์ฌ, MIME ํ์ ์ถ์ถ๊ณผ ์ฝ๊ฒ ๊ฒฐํฉํ ์ ์๋๋ก ํ๋ค.
๋ ๊ฑฐ์๋ก ๋ช ์๋ ์ด์ ๋ ํ๋ ํฌ๋งท์ ๋ฐ๋์ UTF-8๋ง ์จ์ผ ํ๊ธฐ ๋๋ฌธ์ด๋ค.
3.6.
`X-Content-Type-Options` ํค๋
`X-Content-Type-Options`
์๋ต ํค๋๋
์์ฒญ์
๋ชฉ์ ์ง์ ๋ํด
์๋ต์
`Content-Type` ํค๋ ๊ฒ์ฌ๋ฅผ ์๊ตฌํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ค.
ํค๋ ๋ชฉ๋ก(header list) list์ ๋ํด nosniff ํ์ (determine nosniff)์ ํ๋ ค๋ฉด ๋ค์์ ์คํํ๋ค:
-
values๋ฅผ get, decode, split์ list์์ `
X-Content-Type-Options` ์ ๋ํด ์ํํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
values๊ฐ null์ด๋ฉด false๋ฅผ ๋ฐํํ๋ค.
-
values[0]์ด "
nosniff"์ ASCII ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด(ASCII case-insensitive) ์ผ์นํ๋ฉด true๋ฅผ ๋ฐํํ๋ค. -
false๋ฅผ ๋ฐํํ๋ค.
์น ๊ฐ๋ฐ์์ ์ ํฉ์ฑ ๊ฒ์ฌ๊ธฐ๋ `X-Content-Type-Options`์ ๋ํด
์๋์ ๊ฐ
ABNF๋ฅผ ๋ฐ๋์ ์ฌ์ฉํด์ผ ํ๋ค:
X-Content-Type-Options = "nosniff" ; case-insensitive
3.6.1. nosniff๋ก ์ธํด response๊ฐ request์ ๋ํด ์ฐจ๋จ๋์ด์ผ ํ๋๊ฐ?
๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
nosniff ํ์ (determine nosniff)์ response์ ํค๋ ๋ชฉ๋ก์ ๋ํด ํธ์ถํ์ ๋ false๋ผ๋ฉด allowed๋ฅผ ๋ฐํํ๋ค.
-
mimeType์ ํค๋์์ MIME ํ์ ์ถ์ถ(extract MIME type)์ response์ ํค๋ ๋ชฉ๋ก์ ๋ํด ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
destination์ request์ destination์ผ๋ก ๋๋ค.
-
destination์ด script-like์ด๊ณ mimeType์ด ์คํจ(failure)๊ฑฐ๋ ์๋ฐ์คํฌ๋ฆฝํธ MIME ํ์ (JavaScript MIME type)์ด ์๋๋ฉด blocked๋ฅผ ๋ฐํํ๋ค.
-
destination์ด "
style"์ด๊ณ , mimeType์ด ์คํจ(failure)๊ฑฐ๋ ๊ทธ essence๊ฐ "text/css"๊ฐ ์๋๋ฉด blocked๋ฅผ ๋ฐํํ๋ค. -
allowed๋ฅผ ๋ฐํํ๋ค.
request์
destination ์ค
script-like์ด๋
"style"๋ง์ด ๊ณ ๋ ค๋๋ค. ์ด๋ ์
์ฉ ์ฌ๋ก๊ฐ ์ด ๋์ ํด๋นํ๊ธฐ ๋๋ฌธ์ด๋ค.
๋ํ "image"์ ๋ํด์ ๋ฐฐํฌ๋ ์ปจํ
ํธ์ ํธํ๋์ง ์์ ์ ์ธ๋์๋ค.
3.7.
`Cross-Origin-Resource-Policy` ํค๋
The
`Cross-Origin-Resource-Policy`
์๋ต ํค๋๋
์์ฒญ์
ํ์ฌ
URL์ origin์
์์ฒญ์
origin๊ณผ
๋น๊ตํ์ฌ ๊ฒ์ฌํ๋๋ก ์๊ตฌํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ค. ์ด๋
์์ฒญ์ mode๊ฐ
"no-cors"์ผ ๋ ์ ์ฉ๋๋ค.
Cross-Origin-Resource-Policy = %s"same-origin" / %s"same-site" / %s"cross-origin" ; case-sensitive
origin origin, ํ๊ฒฝ ์ค์ ๊ฐ์ฒด settingsObject, ๋ฌธ์์ด destination, ์๋ต response, ๊ทธ๋ฆฌ๊ณ ์ ํ์ ๋ถ๋ฆฌ์ธ forNavigation์ด ์ฃผ์ด์ก์ ๋, ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค ์ ์ฑ ๊ฒ์ฌ๋ฅผ ์ํํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
forNavigation์ด ์ฃผ์ด์ง์ง ์์๋ค๋ฉด false๋ก ์ค์ ํ๋ค.
-
embedderPolicy๋ฅผ settingsObject์ policy container์ embedder policy๋ก ๋๋ค.
-
origin, "
unsafe-none", response, ๊ทธ๋ฆฌ๊ณ forNavigation์ ์ฌ์ฉํ ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค ์ ์ฑ ๋ด๋ถ ๊ฒ์ฌ๊ฐ blocked๋ฅผ ๋ฐํํ๋ฉด, blocked๋ฅผ ๋ฐํํ๋ค.์ด ๋จ๊ณ๋ ์๋์ Cross-Origin Embedder Policy์ ๊ด๋ จ ์๋ ์๋ฐ์ ๋ณด๊ณ ํ๊ณ ์ถ์ง ์๊ธฐ ๋๋ฌธ์ ํ์ํ๋ค.
-
origin, embedderPolicy์ report-only value, response, ๊ทธ๋ฆฌ๊ณ forNavigation์ ์ฌ์ฉํ ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค ์ ์ฑ ๋ด๋ถ ๊ฒ์ฌ๊ฐ blocked๋ฅผ ๋ฐํํ๋ฉด, response, settingsObject, destination, ๊ทธ๋ฆฌ๊ณ true๋ก ๊ต์ฐจ ์ถ์ฒ embedder policy CORP ์๋ฐ ๋ณด๊ณ ์๋ฅผ ํ์ ๋ฃ๋๋ค.
-
origin, embedderPolicy์ value, response, ๊ทธ๋ฆฌ๊ณ forNavigation์ ์ฌ์ฉํ ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค ์ ์ฑ ๋ด๋ถ ๊ฒ์ฌ๊ฐ allowed๋ฅผ ๋ฐํํ๋ฉด, allowed๋ฅผ ๋ฐํํ๋ค.
-
response, settingsObject, destination, ๊ทธ๋ฆฌ๊ณ false๋ก ๊ต์ฐจ ์ถ์ฒ embedder policy CORP ์๋ฐ ๋ณด๊ณ ์๋ฅผ ํ์ ๋ฃ๋๋ค.
-
blocked๋ฅผ ๋ฐํํ๋ค.
HTML์ navigate ์๊ณ ๋ฆฌ์ฆ๋ง forNavigation์ด true๋ก ์ค์ ๋ ์ํ์์ ์ด ๊ฒ์ฌ๋ฅผ ์ฌ์ฉํ๋ฉฐ, ์ด๋ ํญ์ ์ค์ฒฉ ๋ด๋น๊ฒ์ด์ ์ ์ํ ๊ฒ์ด๋ค. ๊ทธ ์ธ์ ๊ฒฝ์ฐ, response๋ opaque ํํฐ๋ง๋ ์๋ต์ ๋ด๋ถ ์๋ต์ด๊ฑฐ๋, opaque ํํฐ๋ง๋ ์๋ต์ ๋ด๋ถ ์๋ต์ด ๋ ์๋ต์ด๋ค. [HTML]
origin origin, embedder policy value embedderPolicyValue, ์๋ต response, ๊ทธ๋ฆฌ๊ณ ๋ถ๋ฆฌ์ธ forNavigation์ด ์ฃผ์ด์ก์ ๋, ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค ์ ์ฑ ๋ด๋ถ ๊ฒ์ฌ๋ฅผ ์ํํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
forNavigation์ด true์ด๊ณ embedderPolicyValue๊ฐ "
unsafe-none"์ด๋ฉด, allowed๋ฅผ ๋ฐํํ๋ค. -
policy๋ฅผ response์ ํค๋ ๋ชฉ๋ก์์ `
Cross-Origin-Resource-Policy`๋ฅผ ๊ฐ์ ธ์จ ๊ฒฐ๊ณผ๋ก ๋๋ค.์ด๋ `
Cross-Origin-Resource-Policy: same-site, same-origin`์ด ์๋์์ ๊ฒฐ๊ตญ allowed๊ฐ ๋๋ค๋ ๋ป์ด๋ค. ์ด๋ embedderPolicyValue๊ฐ "unsafe-none"์ธ ํ, ์ด๋ค ๊ฒ๊ณผ๋ ์ผ์นํ์ง ์๊ธฐ ๋๋ฌธ์ด๋ค. ๋ ๊ฐ ์ด์์ `Cross-Origin-Resource-Policy` ํค๋๋ ๊ฐ์ ํจ๊ณผ๋ฅผ ๊ฐ์ง๋ค. -
policy๊ฐ `
same-origin`, `same-site`, `cross-origin` ์ค ์ด๋ ๊ฒ๋ ์๋๋ฉด, policy๋ฅผ null๋ก ์ค์ ํ๋ค. -
policy๊ฐ null์ด๋ฉด, embedderPolicyValue์ ๋ํด switchํ๋ค:
- "
unsafe-none" -
์๋ฌด๊ฒ๋ ํ์ง ์๋๋ค.
- "
credentialless" -
๋ค์ ์ค ํ๋๊ฐ ์ฐธ์ด๋ฉด policy๋ฅผ `
same-origin`์ผ๋ก ์ค์ ํ๋ค:- response์ request-includes-credentials ๊ฐ true์ด๊ฑฐ๋,
- forNavigation์ด true์ด๋ค.
- "
require-corp" -
policy๋ฅผ `
same-origin`์ผ๋ก ์ค์ ํ๋ค.
- "
-
policy์ ๋ํด switchํ๋ค:
- null
- `
cross-origin` - `
-
allowed๋ฅผ ๋ฐํํ๋ค.
- `
same-origin` -
origin์ด response์ URL์ origin๊ณผ same origin์ด๋ฉด, allowed๋ฅผ ๋ฐํํ๋ค.
๊ทธ๋ ์ง ์์ผ๋ฉด, blocked๋ฅผ ๋ฐํํ๋ค.
- `
same-site` -
๋ค์์ด ๋ชจ๋ ์ฐธ์ด๋ฉด
-
origin์ด response์ URL์ origin๊ณผ schemelessly same site์ด๋ค
-
origin์ scheme์ด "
https"์ด๊ฑฐ๋ response์ URL์ scheme์ด "https"๊ฐ ์๋๋ค
๊ทธ๋ฌ๋ฉด allowed๋ฅผ ๋ฐํํ๋ค.
๊ทธ๋ ์ง ์์ผ๋ฉด, blocked๋ฅผ ๋ฐํํ๋ค.
`
Cross-Origin-Resource-Policy: same-site`๋ ๋ณด์ ์ ์ก์ ํตํด ์ ๋ฌ๋ ์๋ต์ด ๋น๋ณด์ ์์ฒญ origin๊ณผ ์ผ์นํ๋ค๊ณ ๋ณด์ง ์๋๋ค. ๊ทธ ํธ์คํธ๋ค์ด ๋ค๋ฅธ ๋ฉด์์๋ same site๋ผ ํ๋๋ผ๋ ๊ทธ๋ ๋ค. ๋ณด์ ์ ์ก๋ ์๋ต์ ๋ณด์ ์ ์ก๋ initiator์๋ง ์ผ์นํ๋ค. -
- null
์๋ต response, ํ๊ฒฝ ์ค์ ๊ฐ์ฒด settingsObject, ๋ฌธ์์ด destination, ๊ทธ๋ฆฌ๊ณ ๋ถ๋ฆฌ์ธ reportOnly๊ฐ ์ฃผ์ด์ก์ ๋, ๊ต์ฐจ ์ถ์ฒ embedder policy CORP ์๋ฐ ๋ณด๊ณ ์๋ฅผ ํ์ ๋ฃ๊ธฐ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ ๊ฒ์ด๋ค:
-
endpoint๋ฅผ reportOnly๊ฐ true์ด๋ฉด settingsObject์ policy container์ embedder policy์ report-only reporting endpoint๋ก ๋๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด settingsObject์ policy container์ embedder policy์ reporting endpoint๋ก ๋๋ค.
-
serializedURL์ response๋ก ๋ณด๊ณ ์ฉ ์๋ต URL ์ง๋ ฌํํ๊ธฐ๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
disposition์ reportOnly๊ฐ true์ด๋ฉด "
reporting"์ผ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด "enforce"๋ก ๋๋ค. -
body๋ฅผ ๋ค์ ์์ฑ์ ํฌํจํ๋ ์ ๊ฐ์ฒด๋ก ๋๋ค:
ํค ๊ฐ " type"" corp"" blockedURL"serializedURL " destination"destination " disposition"disposition -
settingsObject์ ์ ์ญ ๊ฐ์ฒด์ ๋ํด "
coep" report type, endpoint, ๊ทธ๋ฆฌ๊ณ body๊ฐ ์ฃผ์ด์ก์ ๋ ๋ณด๊ณ ์๋ฅผ ์์ฑํ๊ณ ํ์ ๋ฃ๋๋ค. [REPORTING]
3.8. `Sec-Purpose` ํค๋
`Sec-Purpose` HTTP ์์ฒญ
ํค๋๋ ์์ฒญ์ด ์ฌ์ฉ์๊ฐ ์ฆ์ ์ฌ์ฉํ ๋ฆฌ์์ค๋ฅผ ์์ฒญํ๋ ๊ฒ ์ธ์ ํ๋ ์ด์์ ๋ชฉ์ ์ ๊ฐ์ง์ ๋ช
์ํ๋ค.
`Sec-Purpose` ํค๋ ํ๋๋ ๊ตฌ์กฐํ ํค๋์ด๋ฉฐ,
๊ทธ ๊ฐ์ ํ ํฐ(token)์ด์ด์ผ ํ๋ค.
์ ์๋ ์ ์ผํ ํ ํฐ(token)์ prefetch์ด๋ค.
์ด๋ ์์ฒญ์ ๋ชฉ์ ์ด ๊ณง ํ์ํ ๊ฒ์ผ๋ก ์์๋๋ ๋ฆฌ์์ค๋ฅผ ๋ฏธ๋ฆฌ ๊ฐ์ ธ์ค๊ธฐ ์ํจ์์ ๋ํ๋ธ๋ค.
์๋ฒ๋ ์ด๋ฅผ ์ด์ฉํด prefetch์ ๋ํ ์บ์ฑ ๋ง๋ฃ๋ฅผ ์กฐ์ ํ๊ฑฐ๋, prefetch๋ฅผ ๊ฑฐ๋ถํ๊ฑฐ๋, ํ์ด์ง ๋ฐฉ๋ฌธ ์ ์ง๊ณ ์ ๋ค๋ฅด๊ฒ ์ฒ๋ฆฌํ ์ ์๋ค.
4. ๊ฐ์ ธ์ค๊ธฐ
์๋ ์๊ณ ๋ฆฌ์ฆ์ fetching์ ์ ์ํ๋ค. ๋๋ต์ ์ผ๋ก ๋งํ๋ฉด, ์ด๋ ์์ฒญ ํ๋์ ์์ ์ค ์ฌ๋ฌ ์ง์ ์์ ์คํํ ํ๋ ์ด์์ ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋๋ค. ์๋์ ๋์ด๋ ๋ง์ง๋ง ๋ ์๊ณ ๋ฆฌ์ฆ์๋ ์๋ต์ด ์ ๋ฌ๋๋ค. ์ฒ์ ๋ ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ก๋๋ฅผ ํฌ์ฐฉํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ค.
์์ฒญ request, ์ ํ์ ์๊ณ ๋ฆฌ์ฆ processRequestBodyChunkLength, ์ ํ์ ์๊ณ ๋ฆฌ์ฆ processRequestEndOfBody, ์ ํ์ ์๊ณ ๋ฆฌ์ฆ processEarlyHintsResponse, ์ ํ์ ์๊ณ ๋ฆฌ์ฆ processResponse, ์ ํ์ ์๊ณ ๋ฆฌ์ฆ processResponseEndOfBody, ์ ํ์ ์๊ณ ๋ฆฌ์ฆ processResponseConsumeBody, ๊ทธ๋ฆฌ๊ณ ์ ํ์ ๋ถ๋ฆฌ์ธ useParallelQueue (๊ธฐ๋ณธ๊ฐ false)๊ฐ ์ฃผ์ด์ก์ ๋ fetchํ๋ ค๋ฉด, ์๋ ๋จ๊ณ๋ฅผ ์คํํ๋ค. ์ฃผ์ด์ง ๊ฒฝ์ฐ, processRequestBodyChunkLength๋ ์ ์ก๋ ๋ฐ์ดํธ ์๋ฅผ ๋ํ๋ด๋ ์ ์๋ฅผ ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ค. ์ฃผ์ด์ง ๊ฒฝ์ฐ, processRequestEndOfBody๋ ์ธ์๋ฅผ ๋ฐ์ง ์๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ค. ์ฃผ์ด์ง ๊ฒฝ์ฐ, processEarlyHintsResponse๋ ์๋ต์ ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ค. ์ฃผ์ด์ง ๊ฒฝ์ฐ, processResponse๋ ์๋ต์ ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ค. ์ฃผ์ด์ง ๊ฒฝ์ฐ, processResponseEndOfBody๋ ์๋ต์ ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ค. ์ฃผ์ด์ง ๊ฒฝ์ฐ, processResponseConsumeBody๋ ์๋ต ๋ฐ null, failure, ๋๋ ๋ฐ์ดํธ ์ํ์ค๋ฅผ ๋ฐ๋ ์๊ณ ๋ฆฌ์ฆ์ด์ด์ผ ํ๋ค.
์ฌ์ฉ์ ์์ด์ ํธ๋ ์งํ ์ค์ธ fetch๋ฅผ ์ผ์ ์ค๋จํ๋๋ก ์์ฒญ๋ฐ์ ์ ์๋ค. ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ด ์ผ์ ์ค๋จ ์์ฒญ์ ์๋ฝํ๊ฑฐ๋ ๋ฌด์ํ ์ ์๋ค. ์ผ์ ์ค๋จ๋ fetch๋ ์ฌ๊ฐ๋ ์ ์๋ค. ์งํ ์ค์ธ fetch๊ฐ ํด๋น ์์ฒญ์ ๋ํ HTTP ์บ์์ ์๋ต์ ๊ฐฑ์ ํ๊ณ ์๋ ๊ฒฝ์ฐ, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ผ์ ์ค๋จ ์์ฒญ์ ๋ฌด์ํด์ผ ํ๋ค.
์์ฒญ์ cache mode๊ฐ "no-store"์ด๊ฑฐ๋ ์๋ต์
`Cache-Control: no-store` ํค๋๊ฐ ๋ํ๋๋ ๊ฒฝ์ฐ, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์์ฒญ์ ๋ํ
HTTP ์บ์์ ํญ๋ชฉ์ ๊ฐฑ์ ํ์ง ์๋๋ค. [HTTP-CACHING]
-
Assert: request์ mode๋ "
navigate"์ด๊ฑฐ๋ processEarlyHintsResponse๊ฐ null์ด๋ค.early hints(์๋ต ์ค status๊ฐ 103์ธ ๊ฒ)์ ์ฒ๋ฆฌ๋ ๋ด๋น๊ฒ์ด์ ์ ๋ํด์๋ง ๊ฒํ ๋์๋ค.
-
taskDestination์ null๋ก ๋๋ค.
-
crossOriginIsolatedCapability๋ฅผ false๋ก ๋๋ค.
-
request๊ฐ ์ฃผ์ด์ก์ ๋ ํด๋ผ์ด์ธํธ์์ ์์ฒญ์ ์ฑ์ด๋ค.
-
request์ client๊ฐ null์ด ์๋๋ฉด:
-
taskDestination์ request์ client์ ์ ์ญ ๊ฐ์ฒด๋ก ์ค์ ํ๋ค.
-
crossOriginIsolatedCapability๋ฅผ request์ client์ cross-origin isolated capability๋ก ์ค์ ํ๋ค.
-
-
useParallelQueue๊ฐ true์ด๋ฉด, taskDestination์ ์ ๋ณ๋ ฌ ํ๋ฅผ ์์ํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
timingInfo๋ฅผ ์ fetch timing info๋ก ๋๋ฉฐ, ๊ทธ start time ๋ฐ post-redirect start time์ crossOriginIsolatedCapability๊ฐ ์ฃผ์ด์ก์ ๋์ coarsened shared current time์ด๊ณ , render-blocking์ request์ render-blocking์ผ๋ก ์ค์ ๋๋ค.
-
fetchParams๋ฅผ ์ fetch params๋ก ๋๋ฉฐ, ๊ทธ request๋ request, timing info๋ timingInfo, process request body chunk length๋ processRequestBodyChunkLength, process request end-of-body๋ processRequestEndOfBody, process early hints response๋ processEarlyHintsResponse, process response๋ processResponse, process response consume body๋ processResponseConsumeBody, process response end-of-body๋ processResponseEndOfBody, task destination์ taskDestination, ๊ทธ๋ฆฌ๊ณ cross-origin isolated capability์ crossOriginIsolatedCapability์ด๋ค.
-
request์ body๊ฐ ๋ฐ์ดํธ ์ํ์ค์ด๋ฉด, request์ body๋ฅผ request์ body๋ฅผ body๋ก ์ทจ๊ธํ ๊ฒ์ผ๋ก ์ค์ ํ๋ค.
-
request๋ก WebDriver BiDi clone network request body ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
๋ค์ ์กฐ๊ฑด์ด ๋ชจ๋ true์ด๋ฉด:
-
request์ URL์ scheme์ด HTTP(S) scheme์ด๋ค
-
request์ mode๊ฐ "
same-origin", "cors", ๋๋ "no-cors"์ด๋ค -
request์ client๊ฐ null์ด ์๋๊ณ , request์ client์ ์ ์ญ ๊ฐ์ฒด๊ฐ
Window๊ฐ์ฒด์ด๋ค -
request์ method๊ฐ `
GET`์ด๋ค -
request์ unsafe-request flag๊ฐ ์ค์ ๋์ด ์์ง ์๊ฑฐ๋ request์ header list๊ฐ ๋น์ด ์๋ค
๊ทธ๋ฌ๋ฉด:
-
Assert: request์ origin์ request์ client์ origin๊ณผ same origin์ด๋ค.
-
onPreloadedResponseAvailable์, ์๋ต response๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ๋๋ค: fetchParams์ preloaded response candidate๋ฅผ response๋ก ์ค์ ํ๋ค.
-
foundPreloadedResource๋ฅผ, request์ client์ ๋ํด, request์ URL, request์ destination, request์ mode, request์ credentials mode, request์ integrity metadata, ๊ทธ๋ฆฌ๊ณ onPreloadedResponseAvailable๊ฐ ์ฃผ์ด์ก์ ๋ preloaded resource๋ฅผ ์๋นํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
foundPreloadedResource๊ฐ true์ด๊ณ fetchParams์ preloaded response candidate๊ฐ null์ด๋ฉด, fetchParams์ preloaded response candidate๋ฅผ "
pending"์ผ๋ก ์ค์ ํ๋ค.
-
-
request์ header list๊ฐ `
Accept`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด:-
value๋ฅผ `
*/*`๋ก ๋๋ค. -
request์ initiator๊ฐ "
prefetch"์ด๋ฉด, value๋ฅผ document `Accept` header value๋ก ์ค์ ํ๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, ์ฌ์ฉ์ ์์ด์ ํธ๋ request์ destination์ ๋ํด switchํ์ฌ, ์ผ์นํ๋ ์ฒซ ๋ฌธ์ฅ์ด ์๋ค๋ฉด value๋ฅผ ๊ทธ ๊ฐ์ผ๋ก ์ค์ ํด์ผ ํ๋ค:
- "
document"- "
frame"- "
iframe" - "
- document `
Accept` header value - "
image" - `
image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5` - "
json" - `
application/json,*/*;q=0.5` - "
style" - `
text/css,*/*;q=0.1` - "
text" - `
text/plain,*/*;q=0.5`
- "
-
(`
Accept`, value)๋ฅผ request์ header list์ ๋ง๋ถ์ธ๋ค.
-
-
request์ header list๊ฐ `
Accept-Language`๋ฅผ ํฌํจํ์ง ์๊ณ request์ client๊ฐ null์ด ์๋๋ฉด:-
emulatedLanguage๋ฅผ request์ client์ ๋ํ WebDriver BiDi emulated language๋ก ๋๋ค.
-
emulatedLanguage๊ฐ null์ด ์๋๋ฉด:
-
encodedEmulatedLanguage๋ฅผ emulatedLanguage๋ฅผ ๋ํ ์ธ์ฝ๋ฉํ ๊ฒ์ผ๋ก ๋๋ค.
-
(`
Accept-Language`, encodedEmulatedLanguage)๋ฅผ request์ header list์ ๋ง๋ถ์ธ๋ค.
-
-
-
request์ header list๊ฐ `
Accept-Language`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, ์ฌ์ฉ์ ์์ด์ ํธ๋ (`Accept-Language`, ์ ์ ํ header value)๋ฅผ request์ header list์ ๋ง๋ถ์ฌ์ผ ํ๋ค. -
request์ internal priority๊ฐ null์ด๋ฉด, request์ priority, initiator, destination, ๊ทธ๋ฆฌ๊ณ render-blocking์ implementation-defined ๋ฐฉ์์ผ๋ก ์ฌ์ฉํ์ฌ request์ internal priority๋ฅผ implementation-defined ๊ฐ์ฒด๋ก ์ค์ ํ๋ค.
implementation-defined ๊ฐ์ฒด๋ HTTP/2์ ์คํธ๋ฆผ ๊ฐ์ค์น ๋ฐ ์ข ์์ฑ, ์ ์ฉ๋๋ ์ ์ก(HTTP/3 ํฌํจ)์์ Extensible Prioritization Scheme for HTTP์ ์ฌ์ฉ๋๋ ์ฐ์ ์์, ๊ทธ๋ฆฌ๊ณ HTTP/1 fetch์ ์ ๋ฌ ๋ฐ ์ฒ๋ฆฌ๋ฅผ ์ฐ์ ์์ํํ๋ ๋ฐ ์ฌ์ฉ๋๋ ๋๋ฑํ ์ ๋ณด๋ฅผ ํฌํจํ ์ ์๋ค. [RFC9218]
-
request๊ฐ ํ์ ๋ฆฌ์์ค ์์ฒญ์ด๋ฉด:
-
record๋ฅผ ์ fetch record๋ก ๋๋ฉฐ, ๊ทธ request๋ request์ด๊ณ controller๋ fetchParams์ controller์ด๋ค.
-
record๋ฅผ request์ client์ fetch group์ fetch records์ ๋ง๋ถ์ธ๋ค.
-
-
fetchParams๊ฐ ์ฃผ์ด์ก์ ๋ main fetch๋ฅผ ์คํํ๋ค.
-
fetchParams์ controller๋ฅผ ๋ฐํํ๋ค.
์์ฒญ request๊ฐ ์ฃผ์ด์ก์ ๋ ํด๋ผ์ด์ธํธ์์ ์์ฒญ์ ์ฑ์ฐ๊ธฐ๋:
-
request์ traversable for user prompts๊ฐ "
client"์ด๋ฉด:-
request์ traversable for user prompts๋ฅผ "
no-traversable"๋ก ์ค์ ํ๋ค. -
request์ client๊ฐ null์ด ์๋๋ฉด:
-
global์ request์ client์ ์ ์ญ ๊ฐ์ฒด๋ก ๋๋ค.
-
global์ด
Window๊ฐ์ฒด์ด๊ณ global์ navigable์ด null์ด ์๋๋ฉด, request์ traversable for user prompts๋ฅผ global์ navigable์ traversable navigable๋ก ์ค์ ํ๋ค.
-
-
-
request์ origin์ด "
client"์ด๋ฉด: -
request์ policy container๊ฐ "
client"์ด๋ฉด:-
request์ client๊ฐ null์ด ์๋๋ฉด, request์ policy container๋ฅผ request์ client์ policy container์ clone์ผ๋ก ์ค์ ํ๋ค. [HTML]
-
๊ทธ๋ ์ง ์์ผ๋ฉด, request์ policy container๋ฅผ ์ policy container๋ก ์ค์ ํ๋ค.
-
4.1. ๋ฉ์ธ fetch
main fetch๋ฅผ ์คํํ๋ ค๋ฉด, fetch params fetchParams์ ์ ํ์ ๋ถ๋ฆฌ์ธ recursive (๊ธฐ๋ณธ๊ฐ false)๋ฅผ ๋ฐ์ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
request๋ฅผ fetchParams์ request๋ก ๋๋ค.
-
response๋ฅผ null๋ก ๋๋ค.
-
request์ local-URLs-only flag๊ฐ ์ค์ ๋์ด ์๊ณ , request์ current URL์ด local์ด ์๋๋ฉด, response๋ฅผ ๋คํธ์ํฌ ์๋ฌ๋ก ์ค์ ํ๋ค.
-
Content Security Policy ์๋ฐ ์ฌํญ์ request์ ๋ํด ๋ณด๊ณ ํ๋ค.
-
request๋ฅผ ํ์ํ๋ค๋ฉด ์ ์ฌ์ ์ผ๋ก ์ ๋ขฐํ ์ ์๋ URL๋ก ์ ๊ทธ๋ ์ด๋ํ๋ค.
-
request๊ฐ ์๋ชป๋ ํฌํธ๋ก ์ธํด ์ฐจ๋จ๋์ด์ผ ํ๋์ง, request fetch๊ฐ ํผํฉ ์ฝํ ์ธ ๋ก ์ธํด ์ฐจ๋จ๋์ด์ผ ํ๋์ง, Content Security Policy์ ์ํด request๊ฐ ์ฐจ๋จ๋์ด์ผ ํ๋์ง, ๋ฌด๊ฒฐ์ฑ ์ ์ฑ ์ ์ํด request๊ฐ ์ฐจ๋จ๋์ด์ผ ํ๋์ง ์ค ํ๋๋ผ๋ blocked๋ฅผ ๋ฐํํ๋ฉด, response๋ฅผ ๋คํธ์ํฌ ์๋ฌ๋ก ์ค์ ํ๋ค.
-
request์ referrer policy๊ฐ ๋น ๋ฌธ์์ด์ด๋ฉด, request์ referrer policy๋ฅผ request์ policy container์ referrer policy๋ก ์ค์ ํ๋ค.
-
request์ referrer๊ฐ "
no-referrer"๊ฐ ์๋๋ฉด, request์ referrer๋ฅผ request์ referrer ๊ฒฐ์ ์ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. [REFERRER]Referrer Policy์์ ๋ช ์ํ ๋๋ก, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ต์ข ์ฌ์ฉ์์๊ฒ request์ referrer๋ฅผ "
no-referrer"๋ก ์ค๋ฒ๋ผ์ด๋ํ๊ฑฐ๋ ๋ ๋ฏผ๊ฐํ ์ ๋ณด๋ง ๋ ธ์ถํ๋๋ก ์ ํ๊ถ์ ์ ๊ณตํ ์ ์์ต๋๋ค. -
request์ current URL์ scheme์ ์๋ ์กฐ๊ฑด์ด ๋ชจ๋ true์ด๋ฉด "
https"๋ก ์ค์ ํ๋ค:- request์ current URL์ scheme์ด
"
http"์ - request์ current URL์ host๊ฐ ๋๋ฉ์ธ์
- request์ current URL์ host์
public suffix๊ฐ "
localhost" ๋๋ "localhost."๊ฐ ์๋ - request์ current URL์ host๋ฅผ
Known HSTS Host Domain
Name Matching์ผ๋ก ๋งค์นญํ ๊ฒฐ๊ณผ,
includeSubDomains์ง์๊ฐ ์๋ ์ํผ๋๋ฉ์ธ ๋งค์นญ ๋๋ congruent ๋งค์นญ(์ง์ ์ ๋ฌด ์๊ด์์ด)์ [HSTS] ๋๋ ์์ฒญ์ DNS ์กฐํ๋ก section 9.5์์ ๋ช ์ํ HTTPS RR์ด ๋งค์นญ๋จ [HSTS] [SVCB]
๋ชจ๋ DNS ๋์์ ์ผ๋ฐ์ ์ผ๋ก ๊ตฌํ ์ ์์ด๋ฏ๋ก, DNS ์กฐํ์ HTTPS RR์ด ํฌํจ๋์ด ์๋์ง ํ๋จํ๋ ๋ฐฉ๋ฒ ์ญ์ ๊ตฌํ ์ ์์ ๋๋ค. DNS ๋์์ ์ ํต์ ์ผ๋ก ์ฐ๊ฒฐ ์ป๊ธฐ ์์ ๊น์ง ์ํ๋์ง ์์ผ๋ฏ๋ก, ์ฌ์ฉ์ ์์ด์ ํธ๋ ๋ ์ผ์ฐ DNS ๋์์ ์ํํ๊ฑฐ๋, ๋ก์ปฌ DNS ์บ์๋ฅผ ์ฐธ์กฐํ๊ฑฐ๋, fetch ์๊ณ ๋ฆฌ์ฆ ๋ด์์ ๋ ๋ฆ๊ฒ๊น์ง ๊ธฐ๋ค๋ ธ๋ค๊ฐ request์ ํ์ฌ URL ์scheme ๋ณ๊ฒฝ์ด ํ์ํจ์ ๋ฐ๊ฒฌํด์ ๋ก์ง์ ๋๋๋ฆด ์๋ ์์ต๋๋ค.
- request์ current URL์ scheme์ด
"
-
recursive๊ฐ false์ด๋ฉด, ๋จ์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค.
-
response๊ฐ null์ด๋ฉด, ๋ค์์์ ์ฒ์์ผ๋ก ์ผ์นํ๋ ๊ตฌ๋ฌธ์ ํด๋นํ๋ ๋จ๊ณ๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ response๋ก ์ค์ ํ๋ค:
- fetchParams์ preloaded response candidate๊ฐ null์ด ์๋
-
-
fetchParams์ preloaded response candidate๊ฐ "
pending"์ด ์๋ ๋๊น์ง ๋๊ธฐํ๋ค. -
Assert: fetchParams์ preloaded response candidate๊ฐ response์
-
fetchParams์ preloaded response candidate๋ฅผ ๋ฐํํ๋ค.
-
- request์ current URL์ origin์ด request์ origin๊ณผ same origin์ด๊ณ , request์
response tainting์ด
"
basic"์- request์ current URL์ scheme์ด "
data"์- request์ mode๊ฐ "
navigate", "websocket", ๋๋ "webtransport"์ธ ๊ฒฝ์ฐ - request์ current URL์ scheme์ด "
-
-
request์ response tainting์ "
basic"์ผ๋ก ์ค์ ํ๋ค. -
"
scheme-fetch"์ fetchParams๊ฐ ์ฃผ์ด์ก์ ๋ override fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
HTML์ URL์ ์คํด์ด "
data"์ธ ๊ฒฝ์ฐ, ํด๋น ๋ฌธ์์ ์์ปค์ ๊ณ ์ ํ ๋ถํฌ๋ช ์ถ์ฒ(opaque origin)๋ฅผ ํ ๋นํฉ๋๋ค. ์๋น์ค ์์ปค๋ URL์ ์คํด์ด HTTP(S) ์คํด์ธ ๊ฒฝ์ฐ์๋ง ์์ฑ๋ ์ ์์ต๋๋ค. [HTML] [SW] -
- request์ mode๊ฐ "
same-origin"์ -
๋คํธ์ํฌ ์๋ฌ๋ฅผ ๋ฐํํ๋ค.
- request์ mode๊ฐ "
no-cors"์ -
-
request์ redirect mode๊ฐ "
follow"๊ฐ ์๋๋ฉด, ๋คํธ์ํฌ ์๋ฌ๋ฅผ ๋ฐํํ๋ค. -
request์ response tainting์ "
opaque"๋ก ์ค์ ํ๋ค. -
"
scheme-fetch"์ fetchParams๊ฐ ์ฃผ์ด์ก์ ๋ override fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
- request์ current URL์ scheme์ด HTTP(S) scheme์ด ์๋๋ฉด
-
๋คํธ์ํฌ ์๋ฌ๋ฅผ ๋ฐํํ๋ค.
- request์ use-CORS-preflight flag๊ฐ ์ค์ ๋จ
- request์ unsafe-request flag๊ฐ ์ค์ ๋์ด ์๊ณ , request์ method๊ฐ CORS-safelisted method๊ฐ ์๋๊ฑฐ๋, CORS-unsafe request-header names๊ฐ request์ header list์ ๋น์ด์์ง ์์
-
-
request์ response tainting์ "
cors"๋ก ์ค์ ํ๋ค. -
corsWithPreflightResponse๋ฅผ "
http-fetch", fetchParams, ๊ทธ๋ฆฌ๊ณ true๋ฅผ ์ฃผ์ด override fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. -
corsWithPreflightResponse๊ฐ ๋คํธ์ํฌ ์๋ฌ๋ฉด, ์บ์ ์ํธ๋ฆฌ ์ญ์ ๋ฅผ request๋ก ์คํํ๋ค.
-
corsWithPreflightResponse๋ฅผ ๋ฐํํ๋ค.
-
- ๊ทธ ์ธ์ ๊ฒฝ์ฐ
-
-
request์ response tainting์ "
cors"๋ก ์ค์ ํ๋ค. -
"
http-fetch"์ fetchParams๊ฐ ์ฃผ์ด์ก์ ๋ override fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
-
recursive๊ฐ true๋ฉด response๋ฅผ ๋ฐํํ๋ค.
-
response๊ฐ ๋คํธ์ํฌ ์๋ฌ๊ฐ ์๋๊ณ response๊ฐ filtered response๊ฐ ์๋๋ฉด:
-
request์ response tainting์ด "
cors"์ด๋ฉด:-
headerNames๋ฅผ extracting header list values๋ฅผ `
Access-Control-Expose-Headers`์ response์ header list๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
request์ credentials mode๊ฐ "
include"๊ฐ ์๋๊ณ , headerNames๊ฐ `*`๋ฅผ ํฌํจํ๋ฉด, response์ CORS-exposed header-name list๋ฅผ response์ header list ๋ด์ ๋ชจ๋ ๊ณ ์ header name๋ก ์ค์ ํ๋ค. -
๊ทธ ์ธ์ headerNames๊ฐ null ๋๋ ์คํจ๊ฐ ์๋๋ฉด, response์ CORS-exposed header-name list๋ฅผ headerNames๋ก ์ค์ ํ๋ค.
headerNames ์ค ํ๋๊ฐ ์ฌ์ ํ `
*`์ผ ์ ์์ง๋ง, ์ด๋ header์ name์ด `*`์ธ ๊ฒฝ์ฐ์๋ง ์ผ์นํ๋ค.
-
-
response๋ฅผ filtered response๋ก ์ค์ ํ๋ค. response๋ฅผ ๋ด๋ถ ์๋ต์ผ๋ก ๋๊ณ , request์ response tainting์ ๋ฐ๋ผ ์๋์ ๊ฐ์ด ํ๋ค:
- "
basic" - basic filtered response
- "
cors" - CORS filtered response
- "
opaque" - opaque filtered response
- "
-
-
internalResponse๋ฅผ response๊ฐ ๋คํธ์ํฌ ์๋ฌ์ผ ๊ฒฝ์ฐ response๋ก, ์๋๋ฉด response์ internal response๋ก ๋๋ค.
-
internalResponse์ URL ๋ชฉ๋ก์ด ๋น์ด ์์ผ๋ฉด, ์ด๋ฅผ request์ URL ๋ชฉ๋ก์ clone์ผ๋ก ์ค์ ํ๋ค.
์๋ต์ URL ๋ชฉ๋ก์ ๋น์ด ์์ ์ ์๋ค. ์๋ฅผ ๋ค์ด
about:URL์ fetchํ ๋ ๊ทธ๋ ๋ค. -
internalResponse์ redirect taint๋ฅผ request์ redirect-taint๋ก ์ค์ ํ๋ค.
-
request๊ฐ ๋ด๋น๊ฒ์ด์ ์์ฒญ์ด๋ฉด, internalResponse์ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ request์ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ clone์ผ๋ก ์ค์ ํ๋ค.
-
request์ timing allow failed flag๊ฐ ์ค์ ๋์ด ์์ง ์์ผ๋ฉด, internalResponse์ timing allow passed flag๋ฅผ ์ค์ ํ๋ค.
-
response๊ฐ network error๊ฐ ์๋๊ณ ๋ค์ ์ค ์ด๋ ํ๋๊ฐ blocked๋ฅผ ๋ฐํํ๋ฉด
-
request์ ๋ํ internalResponse๊ฐ ํผํฉ ์ฝํ ์ธ ๋ก ์ธํด ์ฐจ๋จ๋์ด์ผ ํ๋์ง
-
request์ ๋ํ internalResponse๊ฐ Content Security Policy์ ์ํด ์ฐจ๋จ๋์ด์ผ ํ๋์ง
-
request์ ๋ํ internalResponse๊ฐ ๊ทธ MIME type ๋๋ฌธ์ ์ฐจ๋จ๋์ด์ผ ํ๋์ง
-
request์ ๋ํ internalResponse๊ฐ nosniff ๋๋ฌธ์ ์ฐจ๋จ๋์ด์ผ ํ๋์ง
๊ทธ๋ฌ๋ฉด response์ internalResponse๋ฅผ network error๋ก ์ค์ ํ๋ค.
-
-
response์ type์ด "
opaque"์ด๊ณ , internalResponse์ status๊ฐ range status์ด๋ฉฐ, internalResponse์ range-requested flag๊ฐ ์ค์ ๋์ด ์๊ณ , request์ header list๊ฐ `Range`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, response์ internalResponse๋ฅผ network error๋ก ์ค์ ํ๋ค.์ ํต์ ์ผ๋ก API๋ ๋ฒ์๊ฐ ์์ฒญ๋์ง ์์๋๋ผ๋ ranged response๋ฅผ ํ์ฉํ๋ค. ์ด๋ ์ด์ ranged request์์ ์จ partial response ๋๋ range not satisfiable response๊ฐ range request๋ฅผ ํ์ง ์์ API์ ์ ๊ณต๋๋ ๊ฒ์ ๋ฐฉ์งํ๋ค.
์ถ๊ฐ ์ธ๋ถ ์ ๋ณด
์ ๋จ๊ณ๋ ๋ค์ ๊ณต๊ฒฉ์ ๋ฐฉ์งํ๋ค:
media ์์๊ฐ ๊ต์ฐจ ์ถ์ฒ HTML ๋ฆฌ์์ค์ ๋ฒ์๋ฅผ ์์ฒญํ๋ ๋ฐ ์ฌ์ฉ๋๋ค. ์ด๋ ์ ํจํ์ง ์์ media์ด์ง๋ง, ์๋ต์ clone์ ๋ํ ์ฐธ์กฐ๊ฐ service worker์ ๋ณด๊ด๋ ์ ์๋ค. ์ด๋ ๋์ค์ script ์์์ fetch์ ๋ํ ์๋ต์ผ๋ก ์ฌ์ฉ๋ ์ ์๋ค. partial response๊ฐ ์ ์ฒด ๋ฆฌ์์ค๋ ์๋๋๋ผ๋ ์ ํจํ JavaScript๋ผ๋ฉด, ์ด๋ฅผ ์คํํ๋ฉด ๋น๊ณต๊ฐ ๋ฐ์ดํฐ๊ฐ ๋์ถ๋ ์ ์๋ค.
-
response๊ฐ network error๊ฐ ์๋๊ณ request์ method๊ฐ `
HEAD` ๋๋ `CONNECT`์ด๊ฑฐ๋, internalResponse์ status๊ฐ null body status์ด๋ฉด, internalResponse์ body๋ฅผ null๋ก ์ค์ ํ๊ณ , ์ด๋ฅผ ํฅํ ๋ชจ๋ enqueue ์์ (์๋ ๊ฒฝ์ฐ)์ ๋ฌด์ํ๋ค.์ด๋ HTTP๋ฅผ ์๋ฐํ๋ ์๋ฒ์ ๋ํ ์ค๋ฅ ์ฒ๋ฆฌ๋ฅผ ํ์คํํ๋ค.
-
request์ integrity metadata๊ฐ ๋น ๋ฌธ์์ด์ด ์๋๋ฉด:
-
processBodyError๋ฅผ ๋ค์ ๋จ๊ณ๋ก ๋๋ค: fetchParams์ network error๊ฐ ์ฃผ์ด์ก์ ๋ fetch response handover๋ฅผ ์คํํ๋ค.
-
response์ body๊ฐ null์ด๋ฉด, processBodyError๋ฅผ ์คํํ๊ณ ์ด ๋จ๊ณ๋ฅผ ์ค๋จํ๋ค.
-
bytes๊ฐ ์ฃผ์ด์ก์ ๋ processBody๋ฅผ ๋ค์ ๋จ๊ณ๋ค๋ก ๋๋ค:
-
bytes๊ฐ request์ integrity metadata์ ์ผ์นํ์ง ์์ผ๋ฉด, processBodyError๋ฅผ ์คํํ๊ณ ์ด ๋จ๊ณ๋ฅผ ์ค๋จํ๋ค. [SRI]
-
response์ body๋ฅผ bytes๋ฅผ body๋ก ์ทจ๊ธํ ๊ฒ์ผ๋ก ์ค์ ํ๋ค.
-
fetchParams์ response๊ฐ ์ฃผ์ด์ก์ ๋ fetch response handover๋ฅผ ์คํํ๋ค.
-
-
processBody์ processBodyError๊ฐ ์ฃผ์ด์ก์ ๋ response์ body๋ฅผ ์์ ํ ์ฝ๋๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด, fetchParams ๋ฐ response๊ฐ ์ฃผ์ด์ก์ ๋ fetch ์๋ต ์ธ๊ณ๋ฅผ ์คํํฉ๋๋ค.
fetch response handover๋ fetch params fetchParams์ response response๋ฅผ ๋ฐ์ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
timingInfo๋ฅผ fetchParams์ timing info๋ก ๋๋ค.
-
response๊ฐ ๋คํธ์ํฌ ์๋ฌ๊ฐ ์๋๊ณ , fetchParams์ request์ client๊ฐ secure context์ด๋ฉด, timingInfo์ server-timing headers๋ฅผ response์ internal response์ header list์์ `
Server-Timing`์ get/decode/splitํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.internal response๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ `
Server-Timing` ํค๋ ๋ฐ์ดํฐ ๋ ธ์ถ์ด `Timing-Allow-Origin` ํค๋๋ก ๋ณดํธ๋๊ธฐ ๋๋ฌธ์ ์์ ํ๋ค.์ฌ์ฉ์ ์์ด์ ํธ๋ `
Server-Timing` ํค๋๋ฅผ non-secure context ์์ฒญ์๋ ๋ ธ์ถํ ์ ์๋ค. -
๋ง์ฝ fetchParams์ request์ destination์ด "
document"๋ผ๋ฉด, fetchParams์ controller์ full timing info๋ฅผ fetchParams์ timing info๋ก ์ค์ ํ๋ค. -
processResponseEndOfBody๋ฅผ ๋ค์ ๋จ๊ณ๋ก ๋๋ค:
-
unsafeEndTime์ unsafe shared current time์ผ๋ก ๋๋ค.
-
fetchParams์ controller์ report timing steps๋ฅผ global object global์ ๋ฐ์ ๋ค์ ๋จ๊ณ๋ก ๋๋ค:
-
fetchParams์ request์ URL์ scheme์ด HTTP(S) scheme์ด ์๋๋ฉด return.
-
timingInfo์ end time์ relative high resolution time์ผ๋ก, unsafeEndTime๊ณผ global์ ์ธ์๋ก ์ค์ ํ๋ค.
-
cacheState๋ฅผ response์ cache state๋ก ๋๋ค.
-
bodyInfo๋ฅผ response์ body info๋ก ๋๋ค.
-
response์ timing allow passed flag๊ฐ ์ค์ ๋์ด ์์ง ์์ผ๋ฉด, timingInfo๋ฅผ opaque timing info ์์ฑ์ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๊ณ , cacheState๋ฅผ ๋น ๋ฌธ์์ด๋ก ์ค์ ํ๋ค.
response๊ฐ ๋คํธ์ํฌ ์๋ฌ์ธ ๊ฒฝ์ฐ๋ ํฌํจํ๋ค.
-
responseStatus๋ฅผ 0์ผ๋ก ๋๋ค.
-
fetchParams์ request์ mode๊ฐ "
navigate"๊ฐ ์๋๊ฑฐ๋ response์ redirect taint๊ฐ "same-origin"์ด๋ฉด:-
responseStatus๋ฅผ response์ status๋ก ์ค์ ํ๋ค.
-
mimeType์ response์ header list์์ extracting a MIME type์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
mimeType์ด ์คํจ๊ฐ ์๋๋ฉด, bodyInfo์ content type์ minimizing a supported MIME type์ ๊ฒฐ๊ณผ๋ก mimeType์ ๋๊ฒจ ์ค์ ํ๋ค.
-
-
fetchParams์ request์ initiator type์ด null์ด ์๋๋ฉด, mark resource timing์ timingInfo, fetchParams์ request์ URL, fetchParams์ request์ initiator type, global, cacheState, bodyInfo, responseStatus๋ก ์คํํ๋ค.
-
-
processResponseEndOfBodyTask๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํ๋ค:
-
fetchParams์ process response end-of-body๊ฐ null์ด ์๋๋ฉด, fetchParams์ process response end-of-body๋ฅผ response๋ก ์คํํ๋ค.
-
fetchParams์ request์ initiator type์ด null์ด ์๋๊ณ , fetchParams์ request์ client์ global object๊ฐ fetchParams์ task destination์ด๋ฉด, fetchParams์ controller์ report timing steps๋ฅผ fetchParams์ request์ client์ global object๋ก ์คํํ๋ค.
-
fetch task ํ์ ๋ฃ๊ธฐ๋ฅผ ์คํํ์ฌ processResponseEndOfBodyTask๋ฅผ fetchParams์ task destination๊ณผ ํจ๊ป ์คํํ๋ค.
-
-
fetchParams์ process response๊ฐ null์ด ์๋๋ฉด, fetch task ํ์ ๋ฃ๊ธฐ๋ฅผ ์คํํ์ฌ fetchParams์ process response๋ฅผ response๋ก, fetchParams์ task destination๊ณผ ํจ๊ป ์คํํ๋ค.
-
internalResponse๋ฅผ response๊ฐ ๋คํธ์ํฌ ์๋ฌ์ผ ๊ฒฝ์ฐ response๋ก, ์๋๋ฉด response์ internal response๋ก ๋๋ค.
-
response๊ฐ network error๋ผ๋ฉด, request๋ฅผ ๊ฐ์ง๊ณ WebDriver BiDi fetch error ๋จ๊ณ๋ฅผ ์คํํ๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด request์ response๋ฅผ ๊ฐ์ง๊ณ WebDriver BiDi response completed ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
internalResponse์ body๊ฐ null์ด๋ฉด, processResponseEndOfBody๋ฅผ ์คํํ๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
transformStream์ ์๋ก์ด
TransformStream์ผ๋ก ๋๋ค. -
identityTransformAlgorithm์ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ๋๊ณ , chunk๋ฅผ ๋ฐ์ transformStream์ enqueueํ๋ค.
-
transformStream ์ค์ ์ ์คํํ์ฌ, transformAlgorithm์ identityTransformAlgorithm์ผ๋ก, flushAlgorithm์ processResponseEndOfBody๋ก ์ค์ ํ๋ค.
-
internalResponse์ body์ stream์ internalResponse์ body์ stream์ transformStream์ ํ์ดํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
์ด
TransformStream์ ์คํธ๋ฆผ์ด ๋์ ๋๋ฌํ ๋ ์๋ฆผ์ ๋ฐ๊ธฐ ์ํด ํ์ํ๋ฉฐ, ๊ทธ ์ธ์๋ identity transform stream์ด๋ค. -
-
fetchParams์ process response consume body๊ฐ null์ด ์๋๋ฉด:
-
processBody๋ฅผ nullOrBytes๋ฅผ ์ธ์๋ก ๋ฐ์, fetchParams์ process response consume body๋ฅผ response์ nullOrBytes๋ก ์คํํ๋ ๋จ๊ณ๋ก ์ค์ ํ๋ค.
-
processBodyError๋ฅผ fetchParams์ process response consume body๋ฅผ response์ failure๋ก ์คํํ๋ ๋จ๊ณ๋ก ์ค์ ํ๋ค.
-
internalResponse์ body๊ฐ null์ด๋ฉด, fetch task ํ์ ๋ฃ๊ธฐ๋ฅผ ์คํํ์ฌ processBody๋ฅผ null๋ก ์คํํ๊ณ , fetchParams์ task destination๊ณผ ํจ๊ป ์คํํ๋ค.
-
๊ทธ ์ธ์๋, body ์์ ์ฝ๊ธฐ๋ฅผ internalResponse์ body, processBody, processBodyError, fetchParams์ task destination๋ก ์คํํ๋ค.
-
4.2. ์ค๋ฒ๋ผ์ด๋ fetch
override
fetch๋ "scheme-fetch" ๋๋
"http-fetch" type, fetch params fetchParams, ๊ทธ๋ฆฌ๊ณ ์ ํ์ boolean
makeCORSPreflight (๊ธฐ๋ณธ๊ฐ false)๋ฅผ ์
๋ ฅ์ผ๋ก ๋ฐ๋๋ค:
-
request๋ฅผ fetchParams์ request๋ก ์ค์ ํ๋ค.
-
response๋ฅผ request์ ๋ํด potentially override response for a request๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
response๊ฐ null์ด ์๋๋ฉด response๋ฅผ ๋ฐํํ๋ค.
-
type์ ๋ฐ๋ผ ๋ค์ ๋จ๊ณ ์ค ํ๋๋ฅผ ์คํํ๋ค:
- "
scheme fetch" -
response๋ฅผ fetchParams๋ฅผ ์ ๋ ฅ์ผ๋ก scheme fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
- "
HTTP fetch" -
response๋ฅผ fetchParams์ makeCORSPreflight๋ฅผ ์ ๋ ฅ์ผ๋ก HTTP fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
- "
-
response๋ฅผ ๋ฐํํ๋ค.
์์ฒญ์ ๋ํ ์๋ต์ ์ ์ฌ์ ์ผ๋ก ์ฌ์ ์ํ๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ ์์ฒญ request๋ฅผ ๋ฐ์, ์๋ต ๋๋ null์ ๋ฐํํ๋ค. ๊ทธ ๋์์ implementation-defined์ด๋ฉฐ, ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์๋ต์ ์ง์ ๋ฐํํ์ฌ ์์ฒญ์ ๊ฐ์ ํ๊ฑฐ๋, null์ ๋ฐํํ์ฌ ์์ฒญ์ด ์งํ๋๋๋ก ํ์ฉํ ์ ์๊ฒ ํ๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก, ์ด ์๊ณ ๋ฆฌ์ฆ์ ๋ค์๊ณผ ๊ฐ์ ์ฌ์ํ ๊ตฌํ์ ๊ฐ์ง๋ค:
-
null์ ๋ฐํํ๋ค.
์ฌ์ฉ์ ์์ด์ ํธ๋ ์ผ๋ฐ์ ์ผ๋ก ์ด ๊ธฐ๋ณธ ๊ตฌํ์ ๋ค์ ๋ ๋ณต์กํ ๋์ ์งํฉ์ผ๋ก ์ฌ์ ์ํ ๊ฒ์ด๋ค. ์๋ฅผ ๋ค์ด, ์ฌ์ฉ์ ์์ด์ ํธ๋ `https://unsafe.example/`์ ๋ํ ์์ฒญ์ ์ผ๋ฐ์ ์ผ๋ก ์ฐจ๋จํ๋ ๊ฒ์ด ์ฌ์ฉ์์ ์์ ์ ๊ฐ์ฅ ์ ๋ณด์กดํ๋ค๊ณ ํ๋จํ๋ฉด์, ๋๋ฆฌ ์ฌ์ฉ๋๋ ๋ฆฌ์์ค `https://unsafe.example/widget.js`์ ๋ํด์๋ ํ์์ ํผํ๊ธฐ ์ํด shim์ ํฉ์ฑํ ์ ์๋ค. ๊ทธ ๊ตฌํ์ ๋ค์๊ณผ ๊ฐ์ ์ ์๋ค:
-
request์ current url์ host์ registrable domain์ด "
unsafe.example"์ด๋ฉด:-
request์ current url์ path๊ฐ ยซ "
widget.js" ยป์ด๋ฉด:-
body๋ฅผ [shim ์ฒ๋ฆฌ๋ ์ฝํ ์ธ ๋ฅผ ๋ํ๋ด๋ ๋ฐ์ดํธ ์ํ์ค๋ฅผ ์ฌ๊ธฐ์ ์ฝ์ ]์ผ๋ก ๋๋ค.
-
๋ค์ ์์ฑ์ ๊ฐ์ง ์ ์๋ต์ ๋ฐํํ๋ค:
- type
- "
cors" - status
- 200
- ...
- ...
- body
- body๋ฅผ body๋ก ์ทจ๊ธํ ๊ฒ์ ์ป์ ๊ฒฐ๊ณผ.
-
-
network error๋ฅผ ๋ฐํํ๋ค.
-
-
null์ ๋ฐํํ๋ค.
4.3. ์คํด fetch
์คํด fetch๋ fetch params fetchParams๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ๋๋ค:
-
fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด, fetchParams์ ๋ํด ์ ์ ํ ๋คํธ์ํฌ ์ค๋ฅ๋ฅผ ๋ฐํํ๋ค.
-
request๋ฅผ fetchParams์ request๋ก ์ค์ ํ๋ค.
-
request์ current URL์ scheme์ ๋ฐ๋ผ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
- "
about" -
request์ current URL์ path๊ฐ "
blank" ๋ฌธ์์ด์ด๋ฉด, response๋ฅผ ์๋ก ๋ง๋ค์ด ๋ฐํํ๋ค. status message๋ `OK`, header list๋ ยซ (`Content-Type`, `text/html;charset=utf-8`) ยป, body๋ ๋น ๋ฐ์ดํธ ์ํ์ค๋ฅผ body๋ก ๋ณํํ ๊ฐ์ด๋ค.URL "
about:config" ๋ฑ์ ๋ค๋น๊ฒ์ด์ ์ฒ๋ฆฌ ์ ๋ค๋ฃจ๋ฉฐ, fetch ๋งฅ๋ฝ์์๋ ๋คํธ์ํฌ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. - "
blob" -
-
blobURLEntry๋ฅผ request์ current URL์ blob URL entry๋ก ๋๋ค.
-
request์ method๊ฐ `
GET`์ด ์๋๊ฑฐ๋ blobURLEntry๊ฐ null์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. [FILEAPI]`
GET` method ์ ํ์ ์ํธ ์ด์ฉ ๊ฐ๋ฅํ๋ค๋ ๊ฒ ์ธ์๋ ์ ์ฉํ ๋ชฉ์ ์ ์ ๊ณตํ์ง ์๋๋ค. -
requestEnvironment๋ฅผ, request๋ฅผ ์ฃผ์ด environment๋ฅผ ๊ฒฐ์ ํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
isTopLevelSelfFetch๋ฅผ false๋ก ๋๋ค.
-
request์ client๊ฐ null์ด ์๋๋ฉด:
-
global์ request์ client์ global object๋ก ๋๋ค.
-
๋ค์ ๋ชจ๋ ์กฐ๊ฑด์ด ์ฐธ์ด๋ฉด:
-
global์
Window๊ฐ์ฒด์ด๋ค; -
global์ navigable์ด null์ด ์๋๋ค;
-
requestEnvironment์ creation URL์ด equals๋ก request์ current URL๊ณผ ๊ฐ๋ค,
๊ทธ๋ฌ๋ฉด isTopLevelSelfFetch๋ฅผ true๋ก ์ค์ ํ๋ค.
-
-
-
stringOrEnvironment๋ฅผ ๋ค์ ๋จ๊ณ์ ๊ฒฐ๊ณผ๋ก ๋๋ค:
-
request์ destination์ด "
document"์ด๋ฉด, "top-level-navigation"์ ๋ฐํํ๋ค. -
isTopLevelSelfFetch๊ฐ true์ด๋ฉด, "
top-level-self-fetch"๋ฅผ ๋ฐํํ๋ค. -
requestEnvironment๋ฅผ ๋ฐํํ๋ค.
-
-
blob์, blobURLEntry์ stringOrEnvironment๋ฅผ ์ฃผ์ด blob ๊ฐ์ฒด๋ฅผ ์ป๋ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
blob์ด
Blob๊ฐ์ฒด๊ฐ ์๋๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. -
response๋ฅผ ์๋ก์ด response๋ก ๋๋ค.
-
fullLength๋ฅผ blob์
size๋ก ๋๋ค. -
serializedFullLength๋ฅผ fullLength๋ฅผ serializedํ๊ณ isomorphic encodedํ ๊ฐ์ผ๋ก ๋๋ค.
-
type์ blob์
type์ผ๋ก ๋๋ค. -
request์ header list๊ฐ ํฌํจํ์ง ์๋๋ค๋ฉด `
Range`:-
bodyWithType๋ฅผ safely extracting blob์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
response์ status message๋ฅผ `
OK`๋ก ์ค์ ํ๋ค. -
response์ header list๋ฅผ ยซ (`
Content-Length`, serializedFullLength), (`Content-Type`, type) ยป๋ก ์ค์ ํ๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
response์ range-requested flag๋ฅผ ์ค์ ํ๋ค.
-
rangeHeader๋ฅผ, request์ header list์์ `
Range`๋ฅผ gettingํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
rangeValue๋ฅผ, rangeHeader์ true๋ฅผ ์ฃผ์ด parsing a single range header value์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
rangeValue๊ฐ failure์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
(rangeStart, rangeEnd)๋ฅผ rangeValue๋ก ๋๋ค.
-
rangeStart๊ฐ null์ด๋ฉด:
-
rangeStart๋ฅผ fullLength โ rangeEnd๋ก ์ค์ ํ๋ค.
-
rangeEnd๋ฅผ rangeStart + rangeEnd โ 1๋ก ์ค์ ํ๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
rangeStart๊ฐ fullLength ์ด์์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
rangeEnd๊ฐ null์ด๊ฑฐ๋ rangeEnd๊ฐ fullLength ์ด์์ด๋ฉด, rangeEnd๋ฅผ fullLength โ 1๋ก ์ค์ ํ๋ค.
-
-
slicedBlob์, blob, rangeStart, rangeEnd + 1, ๊ทธ๋ฆฌ๊ณ type์ ์ฃผ์ด slice blob์ ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
range ํค๋๋ ํฌํจ(inclusive)๋ ๋ฐ์ดํธ ๋ฒ์๋ฅผ ๋ํ๋ด์ง๋ง, slice blob ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ ฅ ๋ฒ์๋ ๊ทธ๋ ์ง ์๋ค. slice blob ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํ๋ ค๋ฉด rangeEnd๋ฅผ ์ฆ๊ฐ์์ผ์ผ ํ๋ค.
-
slicedBodyWithType๋ฅผ safely extracting slicedBlob์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
response์ body๋ฅผ slicedBodyWithType์ body๋ก ์ค์ ํ๋ค.
-
serializedSlicedLength๋ฅผ slicedBlob์
size๋ฅผ serializedํ๊ณ isomorphic encodedํ ๊ฐ์ผ๋ก ๋๋ค. -
contentRange๋ฅผ, rangeStart, rangeEnd, fullLength๋ฅผ ์ฃผ์ด build a content range๋ฅผ ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
response์ status๋ฅผ 206์ผ๋ก ์ค์ ํ๋ค.
-
response์ status message๋ฅผ `
Partial Content`๋ก ์ค์ ํ๋ค. -
response์ header list๋ฅผ ยซ (`
Content-Length`, serializedSlicedLength), (`Content-Type`, type), (`Content-Range`, contentRange) ยป๋ก ์ค์ ํ๋ค.
-
-
response๋ฅผ ๋ฐํํ๋ค.
-
- "
data" -
-
dataURLStruct๋ฅผ, request์ current URL์ ๋ํด
data:URL ์ฒ๋ฆฌ๊ธฐ๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
dataURLStruct๊ฐ failure์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
mimeType์ dataURLStruct์ MIME type์ ์ง๋ ฌํํ ๊ฐ์ผ๋ก ๋๋ค.
-
์๋ก์ด response๋ฅผ ๋ฐํํ๋๋ฐ, ๊ทธ status message๋ `
OK`์ด๊ณ , header list๋ ยซ (`Content-Type`, mimeType) ยป์ด๋ฉฐ, body ๋ dataURLStruct์ body๋ฅผ body๋ก์ ์ฌ์ฉํ ๊ฒ์ด๋ค.
-
- "
file" -
ํ์ฌ๋ก์๋ ์์ฝ์ง๋ง,
file:URLs ๋ ๋ ์๋ฅผ ์ํ ์ฐ์ต ๋ฌธ์ ๋ก ๋จ๊ฒจ๋๋ค.ํ์ ์ด ์์ง ์์ผ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
- HTTP(S) ์คํด
-
fetchParams๋ฅผ ์ฃผ์ด HTTP fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
- "
-
network error๋ฅผ ๋ฐํํ๋ค.
ํ๊ฒฝ ๊ฒฐ์ ํ๊ธฐ๋ request request๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ๋๋ค:
-
request์ reserved client๊ฐ null์ด ์๋๋ฉด, request์ reserved client๋ฅผ ๋ฐํํ๋ค.
-
request์ client๊ฐ null์ด ์๋๋ฉด, request์ client๋ฅผ ๋ฐํํ๋ค.
-
null์ ๋ฐํํ๋ค.
4.4. HTTP fetch
HTTP fetch๋ fetch params fetchParams์ ์ ํ์ boolean makeCORSPreflight (๊ธฐ๋ณธ๊ฐ false)๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ์, ๋ค์ ๋จ๊ณ๋ค์ ์คํํ๋ค:
-
request๋ฅผ fetchParams์ request๋ก ์ค์ ํ๋ค.
-
response์ internalResponse๋ฅผ null๋ก ์ค์ ํ๋ค.
-
request์ service-workers mode๊ฐ "
all"์ด๋ฉด:-
requestForServiceWorker๋ฅผ request์ clone์ผ๋ก ์ค์ ํ๋ค.
-
requestForServiceWorker์ body๊ฐ null์ด ์๋๋ฉด:
-
transformStream์ ์๋ก์ด
TransformStream๊ฐ์ฒด๋ก ์ค์ ํ๋ค. -
transformAlgorithm์ chunk์ ์ ๋ ฅ์ผ๋ก ์๋ ๋จ๊ณ๋ก ์ ์ํ๋ค:
-
fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด, ์ด ๋จ๊ณ๋ฅผ ์ค์งํ๋ค.
-
chunk๊ฐ
Uint8Array๊ฐ์ฒด๊ฐ ์๋๋ฉด terminate๋ฅผ fetchParams์ controller์ ์ ์ฉํ๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ, enqueue๋ฅผ ์ฌ์ฉํด chunk๋ฅผ transformStream์ ๋ฃ๋๋ค. ์ฌ์ฉ์ ์์ด์ ํธ๋ chunk๋ฅผ ๊ตฌํ ์ ์์ ์ ์ ํ ํฌ๊ธฐ๋ก ๋ถํ ํ์ฌ ๊ฐ๊ฐ enqueueํ๊ฑฐ๋, chunk๋ค์ ๊ตฌํ ์ ์์ ์ ์ ํ ํฌ๊ธฐ๋ก ๊ฒฐํฉํ์ฌ enqueueํ ์ ์๋ค.
-
-
Set up์ ์ฌ์ฉํด transformStream์ transformAlgorithm์ด transformAlgorithm์ด ๋๋๋ก ์ค์ ํ๋ค.
-
requestForServiceWorker์ body์ stream์ requestForServiceWorker์ body์ stream์ pipeThrough๋ก transformStream์ ์ฐ๊ฒฐํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
-
serviceWorkerStartTime์ coarsened shared current time์ fetchParams์ cross-origin isolated capability๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
fetchResponse๋ฅผ handle fetch์ requestForServiceWorker, fetchParams์ controller ๋ฐ fetchParams์ cross-origin isolated capability์ ํจ๊ป ํธ์ถํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. [HTML] [SW]
-
๋ง์ฝ fetchResponse๊ฐ response๋ผ๋ฉด:
-
response๋ฅผ fetchResponse๋ก ์ค์ ํ๋ค.
-
fetchParams์ timing info์ final service worker start time์ serviceWorkerStartTime์ผ๋ก ์ค์ ํ๋ค.
-
fetchParams์ timing info์ service worker timing info๋ฅผ response์ service worker timing info๋ก ์ค์ ํ๋ค.
-
request์ body๊ฐ null์ด ์๋๋ผ๋ฉด, cancel request์ body๋ฅผ undefined์ ํจ๊ป ํธ์ถํ๋ค.
-
internalResponse๋ฅผ response๋ก, ๋ง์ฝ response๊ฐ filtered response๊ฐ ์๋๋ผ๋ฉด response๋ก; ๊ทธ๋ ์ง ์์ผ๋ฉด response์ internal response๋ก ์ค์ ํ๋ค.
-
request์ response๋ก WebDriver BiDi ์๋ต ์์ ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
๋ค์ ์กฐ๊ฑด ์ค ํ๋๋ผ๋ ๋ง์กฑํ๋ฉด
-
response์ type์ด "
error"์ธ ๊ฒฝ์ฐ -
request์ mode๊ฐ "
same-origin"์ด๊ณ , response์ type์ด "cors"์ธ ๊ฒฝ์ฐ -
request์ mode๊ฐ "
no-cors"๊ฐ ์๋๊ณ , response์ type์ด "opaque"์ธ ๊ฒฝ์ฐ - request์ redirect mode๊ฐ
"
manual"์ด ์๋๊ณ , response์ type์ด "opaqueredirect"์ธ ๊ฒฝ์ฐ - request์ redirect mode๊ฐ
"
follow"๊ฐ ์๋๊ณ , response์ URL list์ ํญ๋ชฉ์ด ๋ ๊ฐ ์ด์ ์๋ ๊ฒฝ์ฐ
์ด ๊ฒฝ์ฐ network error๋ฅผ ๋ฐํํ๋ค.
-
-
-
๊ทธ ๋ฐ์, fetchResponse๊ฐ service worker timing info๋ผ๋ฉด, fetchParams์ timing info์ service worker timing info๋ฅผ fetchResponse๋ก ์ค์ ํ๋ค.
-
-
response๊ฐ null์ด๋ฉด:
-
makeCORSPreflight์ด true์ด๊ณ ๋ค์ ์กฐ๊ฑด ์ค ํ๋๋ผ๋ ์ฐธ์ด๋ฉด:
-
request์ method์ ๋ํด method cache entry match๊ฐ ์๊ณ , request์ method๊ฐ CORS-safelisted method๊ฐ ์๋๊ฑฐ๋ request์ use-CORS-preflight flag๊ฐ ์ค์ ๋ ๊ฒฝ์ฐ
- ํญ๋ชฉ์ด request์ ํค๋ ๋ชฉ๋ก๊ณผ ํจ๊ป CORS-unsafe ์์ฒญ ํค๋ ์ด๋ฆ์ ์ ์ด๋ ํ๋ ์์ผ๋ฉฐ, ๊ทธ ํญ๋ชฉ์ ๋ํด์๋ request๋ฅผ ์ฌ์ฉํ ํค๋ ์ด๋ฆ ์บ์ ํญ๋ชฉ ์ผ์น๊ฐ ์๋ค.
๊ทธ๋ ๋ค๋ฉด:
-
preflightResponse๋ฅผ CORS-ํ๋ฆฌํ๋ผ์ดํธ fetch๋ฅผ request์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
preflightResponse๊ฐ network error์ด๋ฉด preflightResponse๋ฅผ ๋ฐํํ๋ค.
์ด ๋จ๊ณ๋ CORS-ํ๋ฆฌํ๋ผ์ดํธ ์บ์๋ฅผ ํ์ธํ๊ณ ์ ์ ํ ์ํธ๋ฆฌ๊ฐ ์์ผ๋ฉด CORS-ํ๋ฆฌํ๋ผ์ดํธ fetch๋ฅผ ์ํํ๋ฉฐ, ์ฑ๊ณต ์ ์บ์๋ฅผ ์ฑ์ด๋ค. CORS-ํ๋ฆฌํ๋ผ์ดํธ fetch์ ๋ชฉ์ ์ fetch ๋ฆฌ์์ค๊ฐ CORS ํ๋กํ ์ฝ์ ์ธ์งํ๊ณ ์์์ ๋ณด์ฅํ๋ ๋ฐ ์๋ค. ์บ์๋ CORS-ํ๋ฆฌํ๋ผ์ดํธ fetch ํ์๋ฅผ ์ต์ํํ๊ธฐ ์ํด ์กด์ฌํ๋ค.
-
-
request์ redirect mode๊ฐ "
follow"์ด๋ฉด, request์ service-workers mode๋ฅผ "none"์ผ๋ก ์ค์ ํ๋ค.๋คํธ์ํฌ์์ ๋ฐ์ํ ๋ฆฌ๋ค์ด๋ ํธ๋(์๋น์ค ์์ปค๋ก๋ถํฐ ๋ฐ์ํ ๊ฒ์ด ์๋ ๊ฒฝ์ฐ) ์๋น์ค ์์ปค์ ๋ ธ์ถ๋์ด์๋ ์ ๋๋ค.
-
response์ internalResponse๋ฅผ HTTP-๋คํธ์ํฌ-๋๋-์บ์ fetch๋ฅผ fetchParams์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
request์ response tainting๊ฐ "
cors"์ด๊ณ CORS ์ฒดํฌ๋ฅผ request์ response์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๊ฐ ์คํจ์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.CORS ๊ฒ์ฌ๋ ์๋ต ์ค status๊ฐ 304 ๋๋ 407์ธ ๊ฒ, ๋๋ ๊ทธ ์ ์์ service worker์์ ์จ ์๋ต์๋ ์ ์ฉ๋์ง ์์์ผ ํ๋ฏ๋ก, ์ฌ๊ธฐ์ ์ ์ฉ๋๋ค.
-
TAO ์ฒดํฌ๋ฅผ request์ response์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๊ฐ ์คํจ์ด๋ฉด, request์ timing allow failed flag๋ฅผ ์ค์ ํ๋ค.
-
-
request์ response tainting ๋๋ response์ type์ด "
opaque"์ด๊ณ , cross-origin resource policy check๋ฅผ request์ origin, request์ client, request์ destination, ๊ทธ๋ฆฌ๊ณ internalResponse๋ก ์ํํ ๊ฒฐ๊ณผ๊ฐ blocked๋ฅผ ๋ฐํํ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.cross-origin resource policy check๋ ๋คํธ์ํฌ์์ ์ค๋ ์๋ต๊ณผ ์๋น์ค ์์ปค์์ ์ค๋ ์๋ต ๋ชจ๋์ ๋ํด ์คํ๋๋ค. ์ด๋ CORS check์๋ ๋ค๋ฅธ๋ฐ, request์ client์ ์๋น์ค ์์ปค๊ฐ ์๋ก ๋ค๋ฅธ ์๋ฒ ๋ ์ ์ฑ ์ ๊ฐ์ง ์ ์๊ธฐ ๋๋ฌธ์ด๋ค.
-
internalResponse์ status๊ฐ redirect status์ด๋ฉด:
-
request๊ฐ ๋ด๋น๊ฒ์ด์ ์์ฒญ์ด๋ฉด, request์ internalResponse๊ฐ ์ฃผ์ด์ก์ ๋ ์์ฒญ์ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ ๋ง๋ถ์ธ๋ค.
-
internalResponse์ status๊ฐ 303์ด ์๋๊ณ request์ body๊ฐ null์ด ์๋๋ฉฐ connection์ด HTTP/2๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ, ์ฌ์ฉ์ ์์ด์ ํธ๋
RST_STREAMํ๋ ์์ ์ ์กํด๋ ๋๋ค(๊ถ์ฅ๋จ).303์ ์ผ๋ถ ์ปค๋ฎค๋ํฐ์์ ํน๋ณํ ์๋ฏธ๋ฅผ ๊ฐ์ง๋ฏ๋ก ์ ์ธ๋๋ค.
-
request์ redirect mode์ ๋ฐ๋ผ ๋ค์ ๋จ๊ณ ์คํ:
- "
error" -
-
response๋ฅผ network error๋ก ์ค์ ํ๋ค.
-
- "
manual" -
-
request์ mode๊ฐ "
navigate"์ด๋ฉด, fetchParams์ controller์ next manual redirect steps๋ฅผ HTTP-๋ฆฌ๋ค์ด๋ ํธ fetch๋ฅผ fetchParams์ response๋ก ์คํํ๋ ๊ฒ์ผ๋ก ์ค์ ํ๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ, response๋ฅผ opaque-redirect filtered response๋ก ์ค์ ํ๊ณ internal response๋ internalResponse๋ก ํ๋ค.
-
- "
follow" -
- WebDriver BiDi ์๋ต ์๋ฃ ๋จ๊ณ๋ฅผ request์ response๋ก ์คํํ๋ค.
-
response๋ฅผ HTTP-redirect fetch๋ฅผ fetchParams์ response๋ก ์คํํ ๊ฒฐ๊ณผ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
- "
-
-
response๋ฅผ ๋ฐํํ๋ค. ์ผ๋ฐ์ ์ผ๋ก internalResponse์ body์ stream์ ๋ฐํ ํ์๋ ๊ณ์ enqueue๋๋ค.
4.5. HTTP-๋ฆฌ๋ค์ด๋ ํธ fetch
HTTP-๋ฆฌ๋ค์ด๋ ํธ fetch๋ fetch params fetchParams์ response response๋ฅผ ๋ฐ์, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
request๋ฅผ fetchParams์ request๋ก ๋๋ค.
-
internalResponse๋ฅผ, response๊ฐ filtered response๊ฐ ์๋๋ฉด response๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด response์ internal response๋ก ๋๋ค.
-
locationURL๋ฅผ, internalResponse์ location URL์ request์ current URL์ fragment๋ฅผ ์ฃผ์ด ์ป์ ๊ฐ์ผ๋ก ๋๋ค.
-
locationURL๊ฐ null์ด๋ฉด, response๋ฅผ ๋ฐํํ๋ค.
-
locationURL๊ฐ failure์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
locationURL์ scheme์ด HTTP(S) scheme์ด ์๋๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
request์ redirect count๊ฐ 20์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
request์ redirect count๋ฅผ 1 ์ฆ๊ฐ์ํจ๋ค.
-
request์ mode๊ฐ "
cors"์ด๊ณ , locationURL์ด credentials๋ฅผ ํฌํจํ๋ฉฐ, request์ origin์ด locationURL์ origin๊ณผ same origin์ด ์๋๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. -
request์ response tainting์ด "
cors"์ด๊ณ locationURL์ด credentials๋ฅผ ํฌํจํ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.์ด๋ ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค๊ฐ ๋์ผ ์ถ์ฒ URL๋ก ๋ฆฌ๋๋ ํธํ๋ ๊ฒฝ์ฐ๋ฅผ ํฌ์ฐฉํ๋ค.
-
internalResponse์ status๊ฐ 303์ด ์๋๊ณ , request์ body๊ฐ null์ด ์๋๋ฉฐ, request์ body์ source ๊ฐ null์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
๋ค์ ์ค ํ๋๊ฐ ์ฐธ์ด๋ฉด
-
internalResponse์ status๊ฐ 301 ๋๋ 302์ด๊ณ request์ method๊ฐ `
POST`์ธ ๊ฒฝ์ฐ -
internalResponse์ status๊ฐ 303์ด๊ณ request์ method๊ฐ `
GET` ๋๋ `HEAD`๊ฐ ์๋ ๊ฒฝ์ฐ
๊ทธ๋ ๋ค๋ฉด:
-
request์ method๋ฅผ `
GET`์ผ๋ก, request์ body๋ฅผ null๋ก ์ค์ ํ๋ค. -
๊ฐ๊ฐ์ headerName์ ๋ํด, request-body-header name ๋ชฉ๋ก์์ delete๋ฅผ ์ฌ์ฉํ์ฌ request์ header list์์ headerName์ ์ญ์ ํ๋ค.
-
-
request์ current URL์ origin์ด locationURL์ origin๊ณผ same origin์ด ์๋๋ฉด, ๊ฐ๊ฐ์ headerName์ ๋ํด, CORS non-wildcard request-header name ๋ชฉ๋ก์์ delete๋ฅผ ์ฌ์ฉํ์ฌ request์ header list์์ headerName์ ์ญ์ ํ๋ค.
์ฆ, ์ด๊ธฐ ์์ฒญ ์ดํ์ ๋ค๋ฅธ origin์ด ๋ณด์ด๋ ์๊ฐ, `
Authorization` ํค๋๊ฐ ์ ๊ฑฐ๋๋ค. -
request์ body๊ฐ null์ด ์๋๋ฉด, safely extracting์ ์ฌ์ฉํ์ฌ request์ body์ source๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ์ body๋ก request์ body๋ฅผ ์ค์ ํ๋ค.
request์ body์ source๊ฐ null์ธ์ง ์ฌ๋ถ๋ ์ด๋ฏธ ํ์ธ๋์๋ค.
-
timingInfo๋ฅผ fetchParams์ timing info๋ก ๋๋ค.
-
timingInfo์ redirect end time๊ณผ post-redirect start time์, coarsened shared current time์ผ๋ก ์ค์ ํ๋, ์ด๋ fetchParams์ cross-origin isolated capability๋ฅผ ์ฃผ์ด ์ป๋๋ค.
-
timingInfo์ redirect start time์ด 0์ด๋ฉด, timingInfo์ redirect start time์ timingInfo์ start time์ผ๋ก ์ค์ ํ๋ค.
-
Append๋ฅผ ์ฌ์ฉํ์ฌ locationURL์ request์ URL list์ ์ถ๊ฐํ๋ค.
-
set requestโs referrer policy on redirect๋ฅผ request์ internalResponse์ ๋ํด ํธ์ถํ๋ค. [REFERRER]
-
recursive๋ฅผ true๋ก ๋๋ค.
-
request์ redirect mode๊ฐ "
manual"์ด๋ฉด, ๋ค์์ ์ํํ๋ค: -
fetchParams์ recursive๋ฅผ ์ฃผ์ด main fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์ด๋ request์ main fetch๋ฅผ ํธ์ถํ์ฌ response tainting์ ์ฌ๋ฐ๋ฅด๊ฒ ์ค์ ํด์ผ ํ๋ค.
4.6. HTTP-๋คํธ์ํฌ-๋๋-์บ์ fetch
๋ค์์ด ์ฃผ์ด์ก์ ๋ HTTP-network-or-cache fetch๋ฅผ ์ํํ๋ ค๋ฉด, fetch params fetchParams, ์ ํ์ ๋ถ๋ฆฌ์ธ isAuthenticationFetch (๊ธฐ๋ณธ๊ฐ false), ๋ฐ ์ ํ์ ๋ถ๋ฆฌ์ธ isNewConnectionFetch (๊ธฐ๋ณธ๊ฐ false)๋ฅผ ์ฌ์ฉํ์ฌ ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
์ผ๋ถ ๊ตฌํ์ HTTP Caching์ ๋ฐ๋ผ ๋ถ๋ถ ์ฝํ ์ธ ์บ์ฑ์ ์ง์ํ ์ ์๋ค. ๊ทธ๋ฌ๋ ๋ธ๋ผ์ฐ์ ์บ์์์๋ ๋๋ฆฌ ์ง์๋์ง ์๋๋ค. [HTTP-CACHING]
-
request๋ฅผ fetchParams์ request๋ก ํ์.
-
httpFetchParams๋ฅผ null๋ก ํ์.
-
httpRequest๋ฅผ null๋ก ํ์.
-
response๋ฅผ null๋ก ํ์.
-
storedResponse๋ฅผ null๋ก ํ์.
-
httpCache๋ฅผ null๋ก ํ์.
-
revalidatingFlag๋ฅผ unset ์ํ๋ก ๋์.
-
๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋, abort when fetchParams๊ฐ canceled์ธ ๊ฒฝ์ฐ ์ค๋จํ๋ค:
-
๋ง์ฝ request์ traversable for user prompts๊ฐ "
no-traversable"์ด๊ณ request์ redirect mode๊ฐ "error"์ด๋ฉด, httpFetchParams๋ฅผ fetchParams๋ก, httpRequest๋ฅผ request๋ก ์ค์ ํ๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด:
-
httpRequest๋ฅผ request์ clone์ผ๋ก ์ค์ ํ๋ค.
๊ตฌํ์ฒด๋ request์ body์ stream์ teeํ๋ ๊ฒ์ ํผํ๋ ๊ฒ์ ๊ถ์ฅํ๋ค. ํนํ request์ body์ source๊ฐ null์ผ ๋๋ ๋จ์ผ ๋ฐ๋๋ง ํ์ํ๊ธฐ ๋๋ฌธ์ด๋ค. ์๋ฅผ ๋ค์ด, request์ body์ source๊ฐ null์ด๋ฉด, ๋ฆฌ๋ค์ด๋ ํธ์ ์ธ์ฆ์ ํ์น ์คํจ๋ก ์ด์ด์ง ์ ์๋ค.
-
httpFetchParams๋ฅผ fetchParams์ ๋ณต์ฌ๋ณธ์ผ๋ก ์ค์ ํ๋ค.
-
httpFetchParams์ request๋ฅผ httpRequest๋ก ์ค์ ํ๋ค.
์ฌ์ฉ์ ํ๋กฌํํธ๋ ๋ฆฌ๋ค์ด๋ ํธ๊ฐ ๊ฐ๋ฅํ๋ฉด, ์ฌ์ฉ์ ์๋ต์ด๋ ๋ฆฌ๋ค์ด๋ ํธ ๋์์ด ๊ฒฐ์ ๋ ํ์ ์์ฒญ์ ์๋ก์ด ํค๋ ์งํฉ์ผ๋ก ๋ค์ ์ ์กํด์ผ ํ ์ ์๋ค. ๊ทธ ์์ ์ ์๋ ์์ฒญ ๋ฐ๋๊ฐ ์ด๋ฏธ ๋ถ๋ถ์ ์ผ๋ก ์ ์ก๋์์ ์ ์์ผ๋ฏ๋ก, ์ฐ๋ฆฌ๋ ์ฌ๋ถ์ ์ฌ๋ณธ์ ํ๋ณดํ๊ธฐ ์ํด ๋ฏธ๋ฆฌ ์์ฒญ(๋ฐ๋ ํฌํจ)์ ๋ณต์ ํด์ผ ํ๋ค.
-
-
includeCredentials๋ฅผ ๋ค์ ์ค ํ๋๋ผ๋ true์ด๋ฉด true๋ก ํ์:
- request์ credentials mode๊ฐ
"
include"์ธ ๊ฒฝ์ฐ - request์ credentials mode๊ฐ
"
same-origin"์ด๊ณ request์ response tainting์ด "basic"์ธ ๊ฒฝ์ฐ
๊ทธ๋ ์ง ์์ผ๋ฉด false์ด๋ค.
- request์ credentials mode๊ฐ
"
-
๋ง์ฝ Cross-Origin-Embedder-Policy๊ฐ credentials ํ์ฉ์ด request์ ๋ํด false๋ฅผ ๋ฐํํ๋ฉด, includeCredentials๋ฅผ false๋ก ์ค์ ํ๋ค.
-
contentLength๋ฅผ httpRequest์ body์ length๋ก ํ๋, ๋ง์ฝ httpRequest์ body๊ฐ null์ด๋ฉด null๋ก ํ์.
-
contentLengthHeaderValue๋ฅผ null๋ก ํ์.
-
๋ง์ฝ httpRequest์ body๊ฐ null์ด๊ณ httpRequest์ method๊ฐ `
POST` ๋๋ `PUT`์ด๋ฉด, contentLengthHeaderValue๋ฅผ `0`์ผ๋ก ์ค์ ํ๋ค. -
๋ง์ฝ contentLength๊ฐ null์ด ์๋๋ฉด, contentLengthHeaderValue๋ฅผ contentLength์ ์ง๋ ฌํ๋ ๋ฐ isomorphic ์ธ์ฝ๋ฉ๋ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
๋ง์ฝ contentLengthHeaderValue๊ฐ null์ด ์๋๋ฉด, append (`
Content-Length`, contentLengthHeaderValue)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค. -
๋ง์ฝ contentLength๊ฐ null์ด ์๋๊ณ httpRequest์ keepalive๊ฐ true์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
inflightKeepaliveBytes๋ฅผ 0์ผ๋ก ํ์.
-
group๋ฅผ httpRequest์ client์ fetch group๋ก ํ์.
-
inflightRecords๋ฅผ group์ ์๋ fetch records ์ค์์ request์ keepalive๊ฐ true์ด๊ณ done flag๊ฐ unset์ธ ๊ฒ๋ค์ ์งํฉ์ผ๋ก ํ์.
-
For each fetchRecord์ ๋ํด inflightRecords์ ๋ํด ๋ค์์ ์ํํ๋ค:
-
๋ง์ฝ contentLength์ inflightKeepaliveBytes์ ํฉ์ด 64 kibibytes๋ฅผ ์ด๊ณผํ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
์์ ์ ํ์ ํ๊ฒฝ ์ค์ ๊ฐ์ฒด๋ณด๋ค ์ค๋ ์ ์ง๋ ์ ์๊ณ ๋ณธ๋ฌธ์ ํฌํจํ๋ ์์ฒญ์ ํฌ๊ธฐ๊ฐ ์ ํ๋๋ฉฐ ๋ฌด๊ธฐํ ์ ์ง๋๋ ๊ฒ์ด ํ์ฉ๋์ง ์๋๋ก ๋ณด์ฅํฉ๋๋ค.
-
-
๋ง์ฝ httpRequest์ referrer๊ฐ URL์ด๋ฉด:
-
referrerValue๋ฅผ httpRequest์ referrer์ serialized ๋ฐ isomorphic ์ธ์ฝ๋ฉ๋ ๊ฐ์ผ๋ก ํ์.
-
Append (`
Referer`, referrerValue)์ httpRequest์ header list์ ์ถ๊ฐํ๋ค.
-
-
์์ฒญ `
Origin` ํค๋ ์ถ๊ฐ๋ฅผ httpRequest์ ๋ํด ์ํํ๋ค. -
Fetch ๋ฉํ๋ฐ์ดํฐ ํค๋๋ฅผ httpRequest์ ์ถ๊ฐ. [FETCH-METADATA]
-
๋ง์ฝ httpRequest์ initiator๊ฐ "
prefetch"์ด๋ฉด, ๊ตฌ์กฐํ๋ ํ๋ ๊ฐ์ ์ค์ ํ๊ณ (`Sec-Purpose`, ํ ํฐprefetch)์ httpRequest์ header list์ ์ถ๊ฐํ๋ค. -
๋ง์ฝ httpRequest์ header list๊ฐ `
User-Agent`๋ฅผ ํฌํจํ์ง ์๋๋ค๋ฉด, ์ฌ์ฉ์ ์์ด์ ํธ๋ ๋ค์์ ์ํํด์ผ ํ๋ค:-
userAgent๋ฅผ httpRequest์ client์ ํ๊ฒฝ ๊ธฐ๋ณธ `
User-Agent` ๊ฐ๋ก ํ์. -
Append (`
User-Agent`, userAgent)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค.
-
-
๋ง์ฝ httpRequest์ cache mode๊ฐ "
default"์ด๊ณ httpRequest์ header list๊ฐ `If-Modified-Since`, `If-None-Match`, `If-Unmodified-Since`, `If-Match` ๋๋ `If-Range` ์ค ํ๋๋ฅผ ํฌํจํ๋ฉด, httpRequest์ cache mode๋ฅผ "no-store"๋ก ์ค์ ํ๋ค. -
๋ง์ฝ httpRequest์ cache mode๊ฐ "
no-cache"์ด๊ณ , httpRequest์ prevent no-cache cache-control header modification flag๊ฐ unset์ด๋ฉฐ, httpRequest์ header list๊ฐ `Cache-Control`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, append (`Cache-Control`, `max-age=0`)์ httpRequest์ header list์ ์ถ๊ฐํ๋ค. -
๋ง์ฝ httpRequest์ cache mode๊ฐ "
no-store" ๋๋ "reload"์ด๋ฉด, ๋ค์์ ์ํํ๋ค:-
๋ง์ฝ httpRequest์ header list๊ฐ `
Pragma`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, append (`Pragma`, `no-cache`)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค. -
๋ง์ฝ httpRequest์ header list๊ฐ `
Cache-Control`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, append (`Cache-Control`, `no-cache`)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค.
-
-
๋ง์ฝ httpRequest์ header list๊ฐ `
Range`๋ฅผ ํฌํจํ๋ฉด, append (`Accept-Encoding`, `identity`)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค.์ด๋ ์ธ์ฝ๋ฉ๋ response์ ์ผ๋ถ๋ก content codings๋ฅผ ์ฒ๋ฆฌํ ๋ ์คํจ๋ฅผ ๋ฐฉ์งํฉ๋๋ค.
๋ํ, ๋ง์ ์๋ฒ๋ค์ด ๋น-identity ์ธ์ฝ๋ฉ์ด ํ์ฉ๋ ๋ ์๋ชปํด์ `
Range` ํค๋๋ฅผ ๋ฌด์ํ๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. -
HTTP์ ๋ฐ๋ผ httpRequest ์ ํค๋ ๋ฆฌ์คํธ ๋ฅผ ์์ ํฉ๋๋ค. httpRequest ์ ํค๋ ๋ฆฌ์คํธ ๊ฐ ์ฃผ์ด์ง ํค๋ ์ ์ด๋ฆ ์ ํฌํจํ๋ฉด ํด๋น ํค๋ ๋ฅผ ์ถ๊ฐ ํ์ง ์์ต๋๋ค.
์ด ๋ถ๋ถ์ ๋ ๊ท๋ฒ์ ์ผ๋ก ๋ง๋ค ์ ์์ผ๋ฉด ์ข๊ฒ ๋ค. ํ์ฌ๋ก์๋ `
Accept-Encoding`, `Connection`, `DNT`, ๋ฐ `Host` ๊ฐ์ ํค๋๋ค์ ํ์์ ๋ฐ๋ผ ์ถ๊ฐ๋๋ค.`
Accept`, `Accept-Charset`, ๋ฐ `Accept-Language`๋ ์ด ์์ ์ ํฌํจ๋์ด์๋ ์ ๋๋ค.`
Accept`์ `Accept-Language`๋ ์ด๋ฏธ ํฌํจ๋์ด ์๋ค (๋จ,fetch()๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํ์๊ฐ ํฌํจ๋์ง ์๋๋ค), ๊ทธ๋ฆฌ๊ณ `Accept-Charset`์ ๋ฐ์ดํธ ๋ญ๋น์ด๋ค. ์์ธํ ๋ด์ฉ์ HTTP header layer division๋ฅผ ๋ณด๋ผ. -
๋ง์ฝ includeCredentials๊ฐ true์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
์์ฒญ `
Cookie` ํค๋ ์ถ๊ฐ๋ฅผ httpRequest์ ๋ํด ์ํํ๋ค. -
๋ง์ฝ httpRequest์ header list๊ฐ `
Authorization`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, ๋ค์์ ์ํํ๋ค:-
authorizationValue๋ฅผ null๋ก ๋๋ค.
-
httpRequest์ ๋ํ authentication entry๊ฐ ์กด์ฌํ๊ณ , httpRequest์ use-URL-credentials flag๊ฐ ์ค์ ๋์ด ์์ง ์๊ฑฐ๋ httpRequest์ current URL์ด credentials๋ฅผ ํฌํจํ์ง ์๋ ๊ฒฝ์ฐ, authorizationValue๋ฅผ authentication entry๋ก ์ค์ ํ๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, httpRequest์ current URL์ด credentials๋ฅผ ํฌํจํ๊ณ isAuthenticationFetch๊ฐ true์ด๋ฉด, authorizationValue๋ฅผ httpRequest์ current URL๋ก ์ค์ ํ๊ณ , `
Authorization` ๊ฐ์ผ๋ก ๋ณํํ๋ค. -
authorizationValue๊ฐ null์ด ์๋๋ฉด, append (`
Authorization`, authorizationValue)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค.
-
-
-
๋ง์ฝ proxy-authentication entry๊ฐ ์๋ค๋ฉด, ์ ์ ํ ์ฌ์ฉํ๋ค.
์ด๋ ์๋์ ์ผ๋ก httpRequest์ credentials mode์ ์์กดํ์ง ์๋๋ค.
-
request๋ก WebDriver BiDi ์์ฒญ ์ ์ ์ก ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
httpCache๋ฅผ HTTP ์บ์ ํํฐ์ ๊ฒฐ์ ์ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค, ์ฃผ์ด์ง httpRequest๋ฅผ ์ฌ์ฉํ์ฌ.
-
๋ง์ฝ httpCache๊ฐ null์ด๋ฉด, httpRequest์ cache mode๋ฅผ "
no-store"๋ก ์ค์ ํ๋ค. -
๋ง์ฝ httpRequest์ cache mode๊ฐ "
no-store"๋ ์๋๊ณ "reload"๋ ์๋๋ฉด, ๋ค์์ ์ํํ๋ค:-
storedResponse๋ฅผ httpCache์์ ์๋ต์ ์ ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. ์ด ์ ํ์ ํ์ํ ๊ฒฝ์ฐ ๊ฒ์ฆ์ ์๊ตฌํ ์ ์์ผ๋ฉฐ, HTTP Caching์ "Constructing Responses from Caches" ์ฅ์ ๋ฐ๋ฅธ๋ค. [HTTP-CACHING]
HTTP์ ์ํด `
Vary` ํค๋๋ฅผ ๊ณ ๋ คํ๋ค. -
๋ง์ฝ storedResponse๊ฐ non-null์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
๋ง์ฝ cache mode๊ฐ "
default"์ด๊ณ , storedResponse๊ฐ stale-while-revalidate response์ด๋ฉฐ httpRequest์ client๊ฐ non-null์ด๋ฉด:-
response๋ฅผ storedResponse๋ก ์ค์ ํ๋ค.
-
response์ cache state๋ฅผ "
local"๋ก ์ค์ ํ๋ค. -
revalidateRequest๋ฅผ request์ clone์ผ๋ก ํ์.
-
revalidateRequest์ cache mode๋ฅผ "
no-cache"๋ก ์ค์ ํ๋ค. -
revalidateRequest์ prevent no-cache cache-control header modification flag์ ์ค์ ํ๋ค.
-
revalidateRequest์ service-workers mode๋ฅผ "
none"๋ก ์ค์ ํ๋ค. -
In parallel๋ก, ์๋ก์ด fetch params์ ์ฌ์ฉํ์ฌ main fetch๋ฅผ ์คํํ๋ค. ๊ทธ ์ fetch params์ request๋ revalidateRequest์ด๋ค.
์ด fetch๋ ๋จ์ง httpCache์ ์ํ๋ฅผ ๊ฐฑ์ ํ๊ธฐ ์ํ ๊ฒ์ด๋ฉฐ, ๊ทธ ์๋ต์ ๋ ๋ค๋ฅธ ์บ์ ์ ๊ทผ๊น์ง ์ฌ์ฉ๋์ง ์๋๋ค. ์ค๋๋ ์๋ต์ ํ์ฌ ์์ฒญ์ ๋ํ ์๋ต์ผ๋ก ์ฌ์ฉ๋๋ค. ์ด fetch๋ ํด๋ผ์ด์ธํธ ๋ฌธ๋งฅ์์ ๋ฐํ๋๋ฏ๋ก ํด๋ผ์ด์ธํธ๊ฐ ์ฌ๋ผ์ง๋ฉด ์์ฒญ์ ์ข ๋ฃ๋๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด:
-
๋ง์ฝ storedResponse๊ฐ stale response์ด๋ฉด, revalidatingFlag๋ฅผ ์ค์ ํ๋ค.
-
๋ง์ฝ revalidatingFlag๊ฐ ์ค์ ๋์ด ์๊ณ httpRequest์ cache mode๊ฐ "
force-cache"๋ ์๋๊ณ "only-if-cached"๋ ์๋๋ฉด:-
๋ง์ฝ storedResponse์ header list๊ฐ `
ETag`๋ฅผ ํฌํจํ๋ฉด, append (`If-None-Match`, `ETag`์ value)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค. -
๋ง์ฝ storedResponse์ header list๊ฐ `
Last-Modified`๋ฅผ ํฌํจํ๋ฉด, append (`If-Modified-Since`, `Last-Modified`์ value)๋ฅผ httpRequest์ header list์ ์ถ๊ฐํ๋ค.
๋ํ HTTP Caching์ "Sending a Validation Request" ์ฅ์ ๋ณด๋ผ. [HTTP-CACHING]
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด response๋ฅผ storedResponse๋ก ์ค์ ํ๊ณ , response์ cache state๋ฅผ "
local"๋ก ์ค์ ํ๋ค.
-
-
-
-
-
If aborted์ด๋ฉด, fetchParams์ ๋ํ ์ ์ ํ network error๋ฅผ ๋ฐํํ๋ค.
-
๋ง์ฝ response๊ฐ null์ด ์๋๋ผ๋ฉด, request์ response๋ก WebDriver BiDi ์๋ต ์์ ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
๋ง์ฝ response๊ฐ null์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
๋ง์ฝ httpRequest์ cache mode๊ฐ "
only-if-cached"์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. -
forwardResponse๋ฅผ HTTP-network fetch๋ฅผ httpFetchParams, includeCredentials, ๋ฐ isNewConnectionFetch๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ํ์.
-
๋ง์ฝ httpRequest์ method๊ฐ unsafe์ด๊ณ , forwardResponse์ status๊ฐ 200์์ 399 ์ฌ์ด(ํฌํจ)์ด๋ฉด, ์ ์ ํ httpCache์ ์ ์ฅ๋ ์๋ต๋ค์ ๋ฌดํจํ(invalidate)ํ๊ณ , storedResponse๋ฅผ null๋ก ์ค์ ํ๋ค. ์ด๋ HTTP Caching์ "Invalidating Stored Responses" ์ฅ์ ๋ฐ๋ฅธ๋ค. [HTTP-CACHING]
-
๋ง์ฝ revalidatingFlag๊ฐ ์ค์ ๋์ด ์๊ณ forwardResponse์ status๊ฐ 304์ด๋ฉด:
-
forwardResponse์ header list๋ฅผ ์ฌ์ฉํ์ฌ storedResponse์ header list๋ฅผ ๊ฐฑ์ ํ๋ค. ์ด๋ HTTP Caching์ "Freshening Stored Responses upon Validation" ์ฅ์ ๋ฐ๋ฅธ๋ค. [HTTP-CACHING]
์ด๋ ์บ์์ ์ ์ฅ๋ ์๋ต๋ ์ ๋ฐ์ดํธํ๋ค.
-
response๋ฅผ storedResponse๋ก ์ค์ ํ๋ค.
-
response์ cache state๋ฅผ "
validated"๋ก ์ค์ ํ๋ค.
-
-
๋ง์ฝ response๊ฐ null์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
response๋ฅผ forwardResponse๋ก ์ค์ ํ๋ค.
-
httpRequest์ forwardResponse๋ฅผ httpCache์ ์ ์ฅํ๋ค. ์ด๋ HTTP Caching์ "Storing Responses in Caches" ์ฅ์ ๋ฐ๋ฅธ๋ค. [HTTP-CACHING]
๋ง์ฝ forwardResponse๊ฐ network error์ด๋ฉด, ์ด๋ ์ฌ์ค์ ๋คํธ์ํฌ ์ค๋ฅ๋ฅผ ์บ์ํ๋ ๊ฒ์ผ๋ก, ๋๋๋ก "negative caching"์ผ๋ก ์๋ ค์ง ๋์์ ํ๋ค.
๊ด๋ จ๋ body info๋ ์๋ต๊ณผ ํจ๊ป ์บ์์ ์ ์ฅ๋๋ค.
-
-
-
response์ URL list๋ฅผ cloneํ httpRequest์ URL list๋ก ์ค์ ํ๋ค.
-
๋ง์ฝ httpRequest์ header list๊ฐ `
Range`๋ฅผ ํฌํจํ๋ฉด, response์ range-requested flag๋ฅผ ์ค์ ํ๋ค. -
response์ request-includes-credentials๋ฅผ includeCredentials๋ก ์ค์ ํ๋ค.
-
๋ง์ฝ response์ status๊ฐ 401์ด๊ณ , httpRequest์ response tainting์ด "
cors"๊ฐ ์๋๋ฉฐ, includeCredentials๊ฐ true์ด๊ณ , request์ traversable for user prompts๊ฐ traversable navigable์ด๋ฉด:-
ํ ์คํธ ํ์: ์ฌ๋ฌ `
WWW-Authenticate` ํค๋, ๋๋ฝ, ํ์ฑ ๋ฌธ์ . -
๋ง์ฝ request์ body๊ฐ non-null์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
๋ง์ฝ request์ body์ source๊ฐ null์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
request์ body๋ฅผ body๋ก ์ค์ ํ๋ค. ์ด๋ ๊ทธ ๊ฐ์ ์์ ํ๊ฒ ์ถ์ถํ request์ body์ source์์ ์ป๋๋ค.
-
-
๋ง์ฝ request์ use-URL-credentials flag๊ฐ unset์ด๊ฑฐ๋ isAuthenticationFetch๊ฐ true์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
๋ง์ฝ fetchParams๊ฐ canceled์ด๋ฉด, fetchParams์ ๋ํ appropriate network error๋ฅผ ๋ฐํํ๋ค.
-
username๊ณผ password๋ฅผ ์๋ ์ ์ ์๊ฒ request์ traversable for user prompts์์ ๊ฐ๊ฐ ๋ฌผ์ด๋ณธ ๊ฒฐ๊ณผ๋ก ์ค์ ํ์.
-
Set the username๋ฅผ ํธ์ถํ์ฌ request์ current URL๊ณผ username์ ์ค์ ํ๋ค.
-
Set the password๋ฅผ ํธ์ถํ์ฌ request์ current URL๊ณผ password๋ฅผ ์ค์ ํ๋ค.
-
-
response๋ฅผ HTTP-network-or-cache fetch๋ฅผ fetchParams์ true๋ฅผ ์ฃผ์ด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
-
๋ง์ฝ response์ status๊ฐ 407์ด๋ฉด, ๋ค์์ ์ํํ๋ค:
-
๋ง์ฝ request์ traversable for user prompts๊ฐ "
no-traversable"์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. -
ํ ์คํธ ํ์: ์ฌ๋ฌ `
Proxy-Authenticate` ํค๋, ๋๋ฝ, ํ์ฑ ๋ฌธ์ . -
๋ง์ฝ fetchParams๊ฐ canceled์ด๋ฉด, fetchParams์ ๋ํ appropriate network error๋ฅผ ๋ฐํํ๋ค.
-
request์ traversable for user prompts์์ ์ ์ ํ ์๋ ์ ์ ๋ฅผ ํ๋กฌํํธํ๊ณ , ๊ฒฐ๊ณผ๋ฅผ proxy-authentication entry๋ก ์ ์ฅํ๋ค. [HTTP]
ํ๋ก์ ์ธ์ฆ์ ๊ดํ ๋๋จธ์ง ์ธ๋ถ์ฌํญ์ HTTP์์ ์ ์๋๋ค.
-
response๋ฅผ HTTP-network-or-cache fetch๋ฅผ fetchParams๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
-
๋ค์์ด ๋ชจ๋ ์ฐธ์ด๋ฉด
-
response์ status๊ฐ 421์ธ ๊ฒฝ์ฐ
-
isNewConnectionFetch๊ฐ false์ธ ๊ฒฝ์ฐ
-
request์ body๊ฐ null์ด๊ฑฐ๋, ๋๋ request์ body๊ฐ non-null์ด๊ณ request ์ body ์source๊ฐ non-null์ธ ๊ฒฝ์ฐ
๊ทธ๋ฌ๋ฉด:
-
๋ง์ฝ fetchParams๊ฐ canceled์ด๋ฉด, fetchParams์ ๋ํ appropriate network error๋ฅผ ๋ฐํํ๋ค.
-
response๋ฅผ HTTP-network-or-cache fetch๋ฅผ fetchParams, isAuthenticationFetch, ๋ฐ true๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
-
๋ง์ฝ isAuthenticationFetch๊ฐ true์ด๋ฉด, request์ ์ฃผ์ด์ง realm์ ๋ํ authentication entry๋ฅผ ์์ฑํ๋ค.
-
response๋ฅผ ๋ฐํํ๋ค. ์ผ๋ฐ์ ์ผ๋ก response์ body์ stream์ ๋ฐํ ํ์๋ ๊ณ์ํด์ ํ์ ๋ค์ด์จ๋ค.
4.7. HTTP-๋คํธ์ํฌ fetch
HTTP-๋คํธ์ํฌ fetch๋ fetch params fetchParams, ์ ํ์ boolean includeCredentials (๊ธฐ๋ณธ๊ฐ false), ์ ํ์ boolean forceNewConnection (๊ธฐ๋ณธ๊ฐ false)๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ฐ์, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
request๋ฅผ fetchParams์ request๋ก ์ค์ ํ๋ค.
-
๋ง์ฝ request์ client๊ฐ ์คํ๋ผ์ธ ์ํ๋ผ๋ฉด, ๋คํธ์ํฌ ์ค๋ฅ๋ฅผ ๋ฐํํ๋ค.
-
response๋ฅผ null๋ก ์ค์ ํ๋ค.
-
timingInfo๋ฅผ fetchParams์ timing info๋ก ์ค์ ํ๋ค.
-
networkPartitionKey๋ฅผ ๋คํธ์ํฌ ํํฐ์ ํค ๊ฒฐ์ ํ๊ธฐ๋ฅผ request์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
newConnection์ forceNewConnection์ด true์ด๋ฉด "
yes", ์๋๋ฉด "no"๋ก ์ค์ ํ๋ค. -
request์ mode์ ๋ฐ๋ผ ๋ถ๊ธฐํ๋ค:
- "
websocket" -
connection์ WebSocket ์ฐ๊ฒฐ ํ๋์ request์ current URL์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
- "
webtransport" -
connection์ WebTransport ์ฐ๊ฒฐ์ ํ๋ํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ฉฐ, ์ด๋ networkPartitionKey์ request๋ฅผ ์ ๋ฌํ๋ค.
- ๊ทธ ์ธ์ ๊ฒฝ์ฐ
-
connection์ ์ฐ๊ฒฐ ํ๋์ networkPartitionKey, request์ current URL, includeCredentials, newConnection์ ์ฌ์ฉํ์ฌ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
- "
-
๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋, abort when fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด ์ค๋จํ๋ค:
-
connection์ด ์คํจ์ด๋ฉด network error๋ฅผ ๋ฐํํ๋ค.
-
timingInfo์ ์ต์ข ์ฐ๊ฒฐ ํ์ด๋ฐ ์ ๋ณด๋ฅผ ์ฐ๊ฒฐ ํ์ด๋ฐ ์ ๋ณด ํด๋จํ ๋ฐ ์กฐ์ ํ๊ธฐ๋ฅผ connection์ ํ์ด๋ฐ ์ ๋ณด, timingInfo์ ๋ฆฌ๋ค์ด๋ ํธ ํ ์์ ์๊ฐ, fetchParams์ cross-origin ๊ฒฉ๋ฆฌ ๊ธฐ๋ฅ์ผ๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
connection์ด HTTP/1.x ์ฐ๊ฒฐ์ด๊ณ request์ body๊ฐ null์ด ์๋๋ฉฐ request์ body์ source๊ฐ null์ด๋ฉด network error๋ฅผ ๋ฐํํ๋ค.
-
timingInfo์ ์ต์ข ๋คํธ์ํฌ ์์ฒญ ์์ ์๊ฐ์ ๊ณต์ ํ์ฌ ์๊ฐ(์กฐ์ ๋จ)์ fetchParams์ cross-origin ๊ฒฉ๋ฆฌ ๊ธฐ๋ฅ์ผ๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
response๋ฅผ connection์์ request๋ฅผ ์ฌ์ฉํ์ฌ HTTP ์์ฒญ์ ๋ง๋ค์ด ์ป์ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋, ๋ค์ ์ฃผ์์ฌํญ์ ๋ฐ๋ฅธ๋ค:
-
HTTP์ ๊ด๋ จ ์๊ตฌ์ฌํญ์ ๋ฐ๋ฅธ๋ค. [HTTP] [HTTP-CACHING]
-
request์ body๊ฐ null์ด ์๋๊ณ request์ body์ source๊ฐ null์ด๋ฉด, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ต๋ 64ํค๋น๋ฐ์ดํธ์ ๋ฒํผ๋ฅผ ๊ฐ์ง๊ณ request์ body์ ์ผ๋ถ๋ฅผ ๊ทธ ๋ฒํผ์ ์ ์ฅํ ์ ์๋ค. ๋ง์ฝ ๊ทธ ๋ฒํผ ํฌ๊ธฐ๋ฅผ ์ด๊ณผํด์ request์ body๋ฅผ ์ฝ์ด์ผ ํ๊ณ , ์์ฒญ์ ์ฌ์ ์กํด์ผ ํ๋ค๋ฉด, ๋์ network error๋ฅผ ๋ฐํํ๋ค.
์๋ฅผ ๋ค๋ฉด ์ฐ๊ฒฐ์ด ํ์์์๋ ๊ฒฝ์ฐ ์ฌ์ ์ก์ด ํ์ํ๋ค.
request์ body์ source๊ฐ null์ด ์๋๋ฉด, request์ body๋ฅผ ์ฌ์์ฑํ ์ ์์ผ๋ฏ๋ก ๋ฒํผ๊ฐ ํ์ํ์ง ์๋ค.
request์ body์ source๊ฐ null์ธ ๊ฒฝ์ฐ, body๊ฐ
ReadableStream๊ฐ์ฒด์์ ์์ฑ๋ ๊ฒ์ด๋ฏ๋ก, body๋ฅผ ์ฌ์์ฑํ ์ ์์ด ๋ฒํผ๊ฐ ํ์ํ๋ค. -
๋ค์์ด ์ฐธ์ผ ๋์:
-
timingInfo์ final network-response start time์ fetchParams์ cross-origin isolated capability๋ก coarsened shared current time์ ๊ตฌํด ์ค์ ํ๋ค. ์ด ๋์์ user agent์ HTTP ํ์๊ฐ ์๋ต์ ์ฒซ ๋ฐ์ดํธ(์: HTTP/2๋ frame header ๋ฐ์ดํธ, HTTP/1.x๋ status line)๋ฅผ ์์ ํ์๋ง์ ์ฆ์ ์ด๋ค์ง๋ค.
-
๋ชจ๋ HTTP ์๋ต ํค๋๊ฐ ์ ์ก๋ ๋๊น์ง ๋๊ธฐํ๋ค.
-
request์ response๋ก WebDriver BiDi ์๋ต ์์ ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
status์ HTTP ์๋ต์ status code๋ฅผ ์ ์ฅํ๋ค.
-
status๊ฐ 100 ์ด์ 199 ์ดํ๋ผ๋ฉด:
-
๋ง์ฝ timingInfo์ first interim network-response start time์ด 0์ด๋ผ๋ฉด, timingInfo์ first interim network-response start time์ timingInfo์ final network-response start time์ผ๋ก ์ค์ ํ๋ค.
-
๋ง์ฝ request์ mode๊ฐ "
websocket"์ด๊ณ , status๊ฐ 101์ด๋ผ๋ฉด, breakํ๋ค. -
๋ง์ฝ status๊ฐ 103์ด๊ณ , fetchParams์ process early hints response๊ฐ null์ด ์๋๋ผ๋ฉด, fetchParams์ process early hints response๋ฅผ fetch task๋ก ํ์ํ๋ค(๋จ, response ์ฌ์ฉ).
์ด ํ์ ์ HTTP ์๋ต๋ค์ ๊ฒฐ๊ตญ "์ต์ข " HTTP ์๋ต์ด ๋ฐ๋ฅด๊ฒ ๋ฉ๋๋ค.
-
-
Fetch์ HTTP์ ์ ํํ ๊ณ์ธตํ๋ ์์ง ์ ๋ฆฌ๋ ํ์๊ฐ ์์ผ๋ฉฐ, ์ฌ๊ธฐ์ response๋ response์ HTTP ์๋ต์ ๋ชจ๋ ์๋ฏธํ๋ค.
HTTP ์์ฒญ์ผ๋ก ์ธํด TLS ํด๋ผ์ด์ธํธ ์ธ์ฆ์ ๋ค์ด์ผ๋ก๊ทธ๊ฐ ๋ฐ์ํ๋ฉด:
-
request์ ํ๋กฌํํธ๋ฅผ ์ํ ํ์ ๊ฐ๋ฅ๊ฐ ํ์ ๊ฐ๋ฅ ๊ฐ์ฒด๋ผ๋ฉด, ๊ทธ ๋ํ ์์๋ฅผ request์ ํ๋กฌํํธ๋ฅผ ์ํ ํ์ ๊ฐ๋ฅ์์ ์ฌ์ฉํ ์ ์๋๋ก ํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด network error๋ฅผ ๋ฐํํ๋ค.
request์ body body๋ฅผ ์ ์กํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
body๊ฐ null์ด๊ณ fetchParams์ process request end-of-body๊ฐ null์ด ์๋๋ฉด, fetch task ํ์์ fetchParams์ process request end-of-body์ fetchParams์ task destination์ผ๋ก ์คํํ๋ค.
-
๊ทธ๋ ์ง ์๊ณ body๊ฐ null์ด ์๋๋ฉด:
-
processBodyChunk๋ฅผ bytes๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ค์ ๋จ๊ณ๋ก ์ ์ํ๋ค:
-
fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด ์ด ๋จ๊ณ๋ฅผ ์ค๋จํ๋ค.
-
๋ณ๋ ฌ๋ก bytes๋ฅผ ์ ์กํ๋ค.
-
fetchParams์ process request body chunk length๊ฐ null์ด ์๋๋ฉด, fetchParams์ process request body chunk length๋ฅผ bytes์ ๊ธธ์ด๋ก ์คํํ๋ค.
-
-
processEndOfBody๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ ์ํ๋ค:
-
fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด ์ด ๋จ๊ณ๋ฅผ ์ค๋จํ๋ค.
-
fetchParams์ process request end-of-body๊ฐ null์ด ์๋๋ฉด, fetchParams์ process request end-of-body๋ฅผ ์คํํ๋ค.
-
-
processBodyError๋ฅผ e๋ฅผ ์ ๋ ฅ์ผ๋ก ๋ค์ ๋จ๊ณ๋ก ์ ์ํ๋ค:
-
fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด ์ด ๋จ๊ณ๋ฅผ ์ค๋จํ๋ค.
-
e๊ฐ "
AbortError"DOMException์ด๋ฉด ์ปจํธ๋กค๋ฌ ์ค๋จ์ fetchParams์ controller์ ์คํํ๋ค. -
๊ทธ ์ธ์๋ ์ปจํธ๋กค๋ฌ ์ข ๋ฃ๋ฅผ fetchParams์ controller์ ์คํํ๋ค.
-
-
body ์ ์ง์ ์ฝ๊ธฐ๋ฅผ request์ body, processBodyChunk, processEndOfBody, processBodyError, fetchParams์ task destination์ผ๋ก ์คํํ๋ค.
-
-
-
-
-
connection์ด HTTP/2๋ฅผ ์ฌ์ฉํ๋ฉด
RST_STREAMํ๋ ์์ ์ ์กํ๋ค. -
fetchParams์ ๋ํ ์ ์ ํ ๋คํธ์ํฌ ์ค๋ฅ๋ฅผ ๋ฐํํ๋ค.
-
-
buffer๋ฅผ ๋น ๋ฐ์ดํธ ์ํ์ค๋ก ์ค์ ํ๋ค.
์ด๋ ์ฌ์ฉ์ ์์ด์ ํธ์ ๋คํธ์ํฌ ๊ณ์ธต ๋ด๋ถ ๋ฒํผ๋ฅผ ์๋ฏธํ๋ค.
-
stream์ ์๋ก์ด
ReadableStream์ผ๋ก ์ค์ ํ๋ค. -
pullAlgorithm์ ๋ค์ ๋จ๊ณ๋ก ์ ์ํ๋ค:
-
promise๋ฅผ ์๋ก์ด promise๋ก ์ค์ ํ๋ค.
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
buffer์ ํฌ๊ธฐ๊ฐ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ ํํ ํํ๋ณด๋ค ์๊ณ ์งํ ์ค์ธ fetch๊ฐ ์ค๋จ๋จ์ด๋ผ๋ฉด, fetch ์ฌ๊ฐ๋ฅผ ์คํํ๋ค.
-
buffer๊ฐ ๋น์ด ์์ง ์์ ๋๊น์ง ๋๊ธฐํ๋ค.
-
fetch task ํ์์ ์คํํ์ฌ ๋ค์ ๋จ๊ณ๋ฅผ fetchParams์ task destination์ผ๋ก ์คํํ๋ค.
-
bytes์์ pull์ buffer์์ stream์ผ๋ก ์คํํ๋ค.
-
stream์ด errored ์ํ์ด๋ฉด ์ปจํธ๋กค๋ฌ ์ข ๋ฃ๋ฅผ fetchParams์ controller์ ์คํํ๋ค.
-
resolve promise๋ฅผ undefined๋ก ์คํํ๋ค.
-
-
-
promise๋ฅผ ๋ฐํํ๋ค.
-
-
cancelAlgorithm์ reason์ ์ ๋ ฅ๋ฐ์ ์ปจํธ๋กค๋ฌ ์ค๋จ์ fetchParams์ controller์ reason๊ณผ ํจ๊ป ์คํํ๋ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ์ค์ ํ๋ค.
-
byte ์ฝ๊ธฐ ์ง์์ผ๋ก stream ์ค์ ์ stream์ ๋ํด ์คํํ๋, pullAlgorithm์ pullAlgorithm์ผ๋ก, cancelAlgorithm์ cancelAlgorithm์ผ๋ก ์ค์ ํ๋ค.
-
response์ body๋ฅผ body๋ก ์๋ก ๋ง๋ค๊ณ , stream์ stream์ผ๋ก ์ค์ ํ๋ค.
-
request์ response๋ก WebDriver BiDi ๋คํธ์ํฌ ์๋ต ๋ณธ๋ฌธ ๋ณต์ ๋จ๊ณ๋ฅผ ์คํํ๋ค.
-
includeCredentials๊ฐ true์ด๋ฉด, ์ฌ์ฉ์ ์์ด์ ํธ๋ ์๋ต Set-Cookie ํค๋ ํ์ฑ ๋ฐ ์ ์ฅ์ request์ response๋ก ์คํํด์ผ ํ๋ค.
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
๋ค์ ๋จ๊ณ๋ฅผ abort when fetchParams๊ฐ ์ทจ์๋จ์ด๋ฉด ์ค๋จํ๋ค:
-
๋ค์์ด ์ฐธ์ผ ๋์:
-
response์ ๋ฉ์์ง body์์ ํ๋ ์ด์์ ๋ฐ์ดํธ๊ฐ ์ ์ก๋์๋ค๋ฉด:
-
bytes๋ฅผ ์ ์ก๋ ๋ฐ์ดํธ๋ก ์ค์ ํ๋ค.
-
codings๋ฅผ ํค๋ ๋ฆฌ์คํธ ๊ฐ ์ถ์ถ์ `
Content-Encoding`๊ณผ response์ header list์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. -
filteredCoding์ "
@unknown"์ผ๋ก ์ค์ ํ๋ค. -
codings๊ฐ null ๋๋ ์คํจ์ด๋ฉด filteredCoding์ ๋น ๋ฌธ์์ด๋ก ์ค์ ํ๋ค.
-
๊ทธ ์ธ์ codings์ size๊ฐ 1๋ณด๋ค ํฌ๋ฉด filteredCoding์ "
multiple"๋ก ์ค์ ํ๋ค. -
๊ทธ ์ธ์ codings[0]์ด ๋น ๋ฌธ์์ด์ด๊ฑฐ๋, ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ง์ํ๊ณ , ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด HTTP Content Coding Registry์ ํฌํจ๋ ์ํธ๋ฆฌ์ ์ผ์นํ๋ฉด, filteredCoding์ ๋ฐ์ดํธ ์๋ฌธ์ํ codings[0]์ผ๋ก ์ค์ ํ๋ค. [IANA-HTTP-PARAMS]
-
response์ body info์ content encoding์ filteredCoding์ผ๋ก ์ค์ ํ๋ค.
-
response์ body info์ encoded size๋ฅผ bytes์ ๊ธธ์ด๋งํผ ์ฆ๊ฐ์ํจ๋ค.
-
bytes๋ฅผ ์ฝํ ์ธ ์ฝ๋ฉ ์ฒ๋ฆฌ๋ฅผ codings๊ณผ bytes๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
์ด๋ก ์ธํด `
Content-Length` ํค๋์ ์ ๋ขฐ์ฑ์ด ์ ํ๋ ์ ์๋ค. -
response์ body info์ decoded size๋ฅผ bytes์ ๊ธธ์ด๋งํผ ์ฆ๊ฐ์ํจ๋ค.
-
bytes๊ฐ ์คํจ์ด๋ฉด ์ปจํธ๋กค๋ฌ ์ข ๋ฃ๋ฅผ fetchParams์ controller์ ์คํํ๋ค.
-
bytes๋ฅผ buffer์ ์ถ๊ฐํ๋ค.
-
buffer์ ํฌ๊ธฐ๊ฐ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ ํํ ์ํ๋ณด๋ค ํฌ๋ฉด, ์งํ ์ค์ธ fetch๋ฅผ ์ค๋จํ๋๋ก ์ฌ์ฉ์ ์์ด์ ํธ์ ์์ฒญํ๋ค.
-
-
๊ทธ ์ธ์ response์ ๋ฉ์์ง body ๋ฐ์ดํธ ์ ์ก์ด ์ ์์ ์ผ๋ก ์๋ฃ๋๊ณ stream์ด readable์ด๋ฉด, stream ๋ซ๊ธฐ๋ฅผ stream์ ์คํํ๊ณ ๋ณ๋ ฌ ์คํ ๋จ๊ณ๋ฅผ ์ค๋จํ๋ค.
-
-
-
-
fetchParams๊ฐ aborted์ด๋ฉด:
-
response์ aborted flag๋ฅผ ์ค์ ํ๋ค.
-
stream์ด readable์ด๋ฉด, stream error๋ฅผ stream์ ์คํํ๊ณ , ์ค๋จ ์ด์ ์ญ์ง๋ ฌํ๋ฅผ fetchParams์ controller์ serialized abort reason๊ณผ ๊ตฌํ ์ ์ realm์ผ๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์คํํ๋ค.
-
-
๊ทธ ์ธ์ stream์ด readable์ด๋ฉด, stream error๋ฅผ stream์
TypeError๋ก ์คํํ๋ค. -
connection์ด HTTP/2๋ฅผ ์ฌ์ฉํ๋ฉด
RST_STREAMํ๋ ์์ ์ ์กํ๋ค. -
๊ทธ ์ธ์๋, ๋ค์ fetch์ ์ฑ๋ฅ ์ ํ๊ฐ ์๋ค๋ฉด ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ connection์ ๋ซ์์ผ ํ๋ค.
์๋ฅผ ๋ค์ด, ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ฐ๊ฒฐ์์ ๋ช ๋ฐ์ดํธ๋ง ๋จ์๋ค๋ ๊ฒ์ ์๊ณ ์๋ค๋ฉด ๋ซ์ง ์๋ ๊ฒ์ด ๋ ์ข์ ์ ์๋ค. ์ด ๊ฒฝ์ฐ ์ฐ๊ฒฐ์ ๋ซ๊ณ ๋ค์ fetch์์ ํธ๋์ ฐ์ดํฌ๋ฅผ ๋ค์ ํ๋ ๊ฒ์ด ์คํ๋ ค ๋ ๋์ ์ ์๋ค.
-
์ด ๋จ๊ณ๋ ๋ณ๋ ฌ๋ก ์คํ๋๋ฉฐ, ์ด ์์ ์์๋ response์ body๊ฐ ๊ด๋ จ ์๋์ง ์ ์ ์๋ค(response๊ฐ ๋ฆฌ๋ค์ด๋ ํธ์ผ ์ ์์).
-
-
response๋ฅผ ๋ฐํํ๋ค. ์ผ๋ฐ์ ์ผ๋ก response์ body์ stream์ ๋ฐํ ํ์๋ ๊ณ์ enqueue๋๋ค.
4.8. CORS-ํ๋ฆฌํ๋ผ์ดํธ fetch
์ด ์๊ณ ๋ฆฌ์ฆ์ CORS ํ๋กํ ์ฝ์ ์ดํดํ๋์ง ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ํ์ธํ๋ ๊ตฌํ์ด๋ค. ์ด๋ฅธ๋ฐ CORS-ํ๋ฆฌํ๋ผ์ดํธ ์์ฒญ์ด๋ค. ์ฑ๊ณตํ๋ฉด CORS-ํ๋ฆฌํ๋ผ์ดํธ ์บ์๋ฅผ ์ฑ์ ์ด๋ฐ fetch์ ์๋ฅผ ์ต์ํํ๋ค.
์์ฒญ request๊ฐ ์ฃผ์ด์ก์ ๋ CORS-preflight fetchํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
preflight๋ฅผ ์ ์์ฒญ์ผ๋ก ๋๋ฉฐ, ๊ทธ method๋ `
OPTIONS`, URL list๋ request์ URL list์ clone, initiator๋ request์ initiator, destination์ request์ destination, origin์ request์ origin, referrer๋ request์ referrer, referrer policy๋ request์ referrer policy, mode๋ "cors", response tainting์ "cors", ๊ทธ๋ฆฌ๊ณ WebDriver id๋ request์ WebDriver id์ธ ๊ฒ์ด๋ค.preflight์ service-workers mode๋ ์ค์ํ์ง ์๋ค. ์ด ์๊ณ ๋ฆฌ์ฆ์ HTTP fetch๊ฐ ์๋๋ผ HTTP-network-or-cache fetch๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ด๋ค.
-
(`
Accept`, `*/*`)๋ฅผ preflight์ header list์ ๋ง๋ถ์ธ๋ค. -
(`
Access-Control-Request-Method`, request์ method)๋ฅผ preflight์ header list์ ๋ง๋ถ์ธ๋ค. -
headers๋ฅผ request์ header list์ ํจ๊ปํ CORS-unsafe request-header names๋ก ๋๋ค.
-
headers๊ฐ ๋น์ด ์์ง ์์ผ๋ฉด:
-
value๋ฅผ headers์ ํญ๋ชฉ๋ค์ ์๋ก `
,`๋ก ๊ตฌ๋ถํ ๊ฒ์ผ๋ก ๋๋ค. -
(`
Access-Control-Request-Headers`, value)๋ฅผ preflight์ header list์ ๋ง๋ถ์ธ๋ค.
์ด๋ ์๋์ ์ผ๋ก combine์ ์ฌ์ฉํ์ง ์๋๋ค. ์ข๋ ๋์๋ 0x2C ๋ค์ 0x20์ด ์ค๋ ๋ฐฉ์์ผ๋ก ๊ตฌํ๋์ง ์์๊ธฐ ๋๋ฌธ์ด๋ค.
-
-
response๋ฅผ, ๊ทธ request๊ฐ preflight์ธ ์ fetch params๊ฐ ์ฃผ์ด์ก์ ๋ HTTP-network-or-cache fetch๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
request์ response์ ๋ํ CORS check๊ฐ success๋ฅผ ๋ฐํํ๊ณ response์ status๊ฐ ok status์ด๋ฉด:
CORS check๋ preflight๊ฐ ์๋๋ผ request์ ๋ํด ์ํ๋๋ค. ์ด๋ ์ฌ๋ฐ๋ฅธ credentials mode๊ฐ ์ฌ์ฉ๋๋๋ก ๋ณด์ฅํ๊ธฐ ์ํ ๊ฒ์ด๋ค.
-
methods๋ฅผ `
Access-Control-Allow-Methods`์ response์ header list๊ฐ ์ฃผ์ด์ก์ ๋ header list values๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
headerNames๋ฅผ `
Access-Control-Allow-Headers`์ response์ header list๊ฐ ์ฃผ์ด์ก์ ๋ header list values๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
methods ๋๋ headerNames ์ค ํ๋๊ฐ failure์ด๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
methods๊ฐ null์ด๊ณ request์ use-CORS-preflight flag๊ฐ ์ค์ ๋์ด ์์ผ๋ฉด, methods๋ฅผ request์ method๋ฅผ ํฌํจํ๋ ์ ๋ชฉ๋ก์ผ๋ก ์ค์ ํ๋ค.
์ด๋ request์ use-CORS-preflight flag๊ฐ ์ค์ ๋์ด ๋ฐ์ํ CORS-preflight fetch๊ฐ ์บ์๋๋๋ก ๋ณด์ฅํ๋ค.
-
request์ method๊ฐ methods ์์ ์๊ณ , request์ method๊ฐ CORS-safelisted method๊ฐ ์๋๋ฉฐ, request์ credentials mode๊ฐ "
include"์ด๊ฑฐ๋ methods๊ฐ `*`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. -
request์ header list์ names ์ค ํ๋๊ฐ CORS non-wildcard request-header name์ด๊ณ , headerNames ์์ ํญ๋ชฉ์ ๋ํ byte-case-insensitive ์ผ์น๊ฐ ์๋๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
-
request์ header list์ ํจ๊ปํ CORS-unsafe request-header names์ ๊ฐ unsafeName์ ๋ํด For each ์ํํ๋, unsafeName์ด headerNames ์์ ํญ๋ชฉ์ ๋ํ byte-case-insensitive ์ผ์น๊ฐ ์๋๊ณ request์ credentials mode๊ฐ "
include"์ด๊ฑฐ๋ headerNames๊ฐ `*`๋ฅผ ํฌํจํ์ง ์์ผ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค. -
max-age๋ฅผ `
Access-Control-Max-Age`์ response์ header list๊ฐ ์ฃผ์ด์ก์ ๋ header list values๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
max-age๊ฐ failure ๋๋ null์ด๋ฉด, max-age๋ฅผ 5๋ก ์ค์ ํ๋ค.
-
max-age๊ฐ max-age์ ๋ํด ๋ถ๊ณผ๋ ํ๋๋ณด๋ค ํฌ๋ฉด, max-age๋ฅผ ๊ทธ ๋ถ๊ณผ๋ ํ๋๋ก ์ค์ ํ๋ค.
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ cache๋ฅผ ์ ๊ณตํ์ง ์์ผ๋ฉด, response๋ฅผ ๋ฐํํ๋ค.
-
methods ์์ ๊ฐ method ์ค, request๋ฅผ ์ฌ์ฉํ method cache entry match๊ฐ ์๋ ๊ฒ์ ๋ํด, ์ผ์นํ๋ ํญ๋ชฉ์ max-age๋ฅผ max-age๋ก ์ค์ ํ๋ค.
-
methods ์์ ๊ฐ method ์ค, request๋ฅผ ์ฌ์ฉํ method cache entry match๊ฐ ์๋ ๊ฒ์ ๋ํด, request, max-age, method, ๊ทธ๋ฆฌ๊ณ null๋ก ์ cache entry๋ฅผ ๋ง๋ ๋ค.
-
headerNames ์์ ๊ฐ headerName ์ค, request๋ฅผ ์ฌ์ฉํ header-name cache entry match๊ฐ ์๋ ๊ฒ์ ๋ํด, ์ผ์นํ๋ ํญ๋ชฉ์ max-age๋ฅผ max-age๋ก ์ค์ ํ๋ค.
-
headerNames ์์ ๊ฐ headerName ์ค, request๋ฅผ ์ฌ์ฉํ header-name cache entry match๊ฐ ์๋ ๊ฒ์ ๋ํด, request, max-age, null, ๊ทธ๋ฆฌ๊ณ headerName์ผ๋ก ์ cache entry๋ฅผ ๋ง๋ ๋ค.
-
response๋ฅผ ๋ฐํํ๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด, network error๋ฅผ ๋ฐํํ๋ค.
4.9. CORS-ํ๋ฆฌํ๋ผ์ดํธ ์บ์
์ ์ ์์ด์ ํธ๋ CORS-preflight ์บ์๋ฅผ ๊ฐ์ง๋ค. CORS-preflight ์บ์๋ ๋ฆฌ์คํธ ํํ์ ์บ์ ์ํธ๋ฆฌ๋ค๋ก ๊ตฌ์ฑ๋๋ค.
์บ์ ์ํธ๋ฆฌ๋ ๋ค์์ผ๋ก ๊ตฌ์ฑ๋๋ค:
- ํค (a ๋คํธ์ํฌ ํํฐ์ ํค)
- ๋ฐ์ดํธ ์ง๋ ฌํ origin (๋ฐ์ดํธ ์ํ์ค)
- URL (URL)
- max-age (์ด ๋จ์ ์ซ์)
- credentials (๋ถ๋ฆฌ์ธ)
- ๋ฉ์๋ (null, `
*`, ๋๋ ๋ฉ์๋) - ํค๋ ์ด๋ฆ (null, `
*`, ๋๋ ํค๋ ์ด๋ฆ)
์บ์ ์ํธ๋ฆฌ๋ ์ ์ฅ๋ ์ดํ, max-age ํ๋์ ์ด๋งํผ ์ง๋๋ฉด ์ญ์ ๋์ด์ผ ํ๋ค. ๋ํ ์บ์ ์ํธ๋ฆฌ๋ ๊ทธ ์ ์๋ ์ญ์ ๋ ์ ์๋ค.
์ ์บ์ ์ํธ๋ฆฌ ์์ฑ์ ํ๋ ค๋ฉด, request, max-age, method, headerName์ด ์ฃผ์ด์ง ๋, ๋ค์ ๋จ๊ณ๋ฅผ ์งํํ๋ค:
-
entry๋ฅผ ์บ์ ์ํธ๋ฆฌ๋ก ์์ฑํ๊ณ , ๋ค์๊ณผ ๊ฐ์ด ์ด๊ธฐํํ๋ค:
- ํค
- ๋ฐ์ดํธ ์ง๋ ฌํ origin
-
request origin์ ๋ฐ์ดํธ ์ง๋ ฌํ์ ๊ฒฐ๊ณผ
- URL
-
request์ current URL
- max-age
-
max-age
- credentials
-
request์ credentials mode๊ฐ "
include"์ด๋ฉด true, ์๋๋ฉด false - ๋ฉ์๋
-
method
- ํค๋ ์ด๋ฆ
-
headerName
-
entry๋ฅผ ์ฌ์ฉ์ ์์ด์ ํธ์ CORS-preflight ์บ์์ ์ถ๊ฐํ๋ค.
์บ์ ํญ๋ชฉ์ ์ง์ฐ๋ ค๋ฉด, request๊ฐ ์ฃผ์ด์ก์ ๋, ์ฌ์ฉ์ ์์ด์ ํธ์ ์ ๊ฑฐํฉ๋๋ค ๋ชจ๋ ์บ์ ํญ๋ชฉ์ ์ฌ์ฉ์ ์์ด์ ํธ์ CORS-preflight ์บ์์์ ๊ทธ ํค๊ฐ ๊ฐ์ ๊ฒฐ๊ณผ์ ๋คํธ์ํฌ ํํฐ์ ํค๋ฅผ ๊ฒฐ์ ํ request๊ฐ ์ฃผ์ด์ก์ ๋์ ๊ฒฐ๊ณผ์ด๊ณ , ๋ฐ์ดํธ ์ง๋ ฌํ๋ ์ถ์ฒ๊ฐ ๋ค์์ ๊ฒฐ๊ณผ์ด๋ฉฐ ์์ฒญ ์ถ์ฒ๋ฅผ ๋ฐ์ดํธ ์ง๋ ฌํํ ๊ฒฐ๊ณผ์ด๊ณ request๋ฅผ ์ฌ์ฉํ๋ฉฐ, ๋ํ URL์ด ๊ฐ์ต๋๋ค request์ ํ์ฌ URL๊ณผ.
์บ์ ํญ๋ชฉ entry๊ฐ request์ ์บ์ ํญ๋ชฉ ์ผ์น๋ฅผ ์ด๋ฃจ๋ ๊ฒ์ entry์ ํค๊ฐ ๋ค์์ ๊ฒฐ๊ณผ์ ๊ฐ๊ณ ๋คํธ์ํฌ ํํฐ์ ํค๋ฅผ ๊ฒฐ์ ํ ๊ฒฐ๊ณผ(request๊ฐ ์ฃผ์ด์ง), entry์ ๋ฐ์ดํธ ์ง๋ ฌํ๋ ์ถ์ฒ๊ฐ ๋ค์์ ๊ฒฐ๊ณผ์ด๋ฉฐ request๋ฅผ ์ฌ์ฉํด ์์ฒญ ์ถ์ฒ๋ฅผ ๋ฐ์ดํธ ์ง๋ ฌํํ ๊ฒฐ๊ณผ์ด๊ณ , entry์ URL์ด request์ ํ์ฌ URL๊ณผ ๊ฐ์ผ๋ฉฐ, ๋ค์ ์ค ํ๋๊ฐ ์ฑ๋ฆฝํ๋ ๊ฒฝ์ฐ์ ๋๋ค.
- entry์ credentials๊ฐ true์ธ ๊ฒฝ์ฐ
- entry์ credentials๊ฐ false์ด๊ณ request์
credentials mode๊ฐ "
include"๊ฐ ์๋ ๊ฒฝ์ฐ
์ฐธ์ผ๋ก ํ๋ค.
method์ request๋ฅผ ์ธ ๋,
์ฌ์ฉ์ ์์ด์ ํธ์ CORS-preflight ์บ์ ๋ด์
method์ ์บ์
์ํธ๋ฆฌ ์ผ์น๋ฅผ ๋ง์กฑํ๊ณ ,
๊ทธ ๋ฉ์๋๊ฐ
method ๋๋ `*`์ธ ์บ์ ์ํธ๋ฆฌ๊ฐ ์์ผ๋ฉด,
๋ฉ์๋ ์บ์ ์ํธ๋ฆฌ
์ผ์น๊ฐ ์กด์ฌํ๋ ๊ฒ์ผ๋ก ํ๋ค.
headerName๊ณผ request๋ฅผ ์ธ ๋, ์ฌ์ฉ์ ์์ด์ ํธ์ CORS-preflight ์บ์ ๋ด์, ์บ์ ์ํธ๋ฆฌ ์ผ์น์ request๋ฅผ ๋ง์กฑํ๊ณ , ๋ค์ ์ค ํ๋๋ฅผ ๋ง์กฑํ๋ ์บ์ ์ํธ๋ฆฌ๊ฐ ์์ผ๋ฉด, ํค๋ ์ด๋ฆ ์บ์ ์ํธ๋ฆฌ ์ผ์น๊ฐ ์กด์ฌํ๋ ๊ฒ์ผ๋ก ํ๋ค:
- ๊ทธ ํค๋ ์ด๋ฆ์ด byte-case-insensitiveํ๊ฒ headerName๊ณผ ์ผ์นํ๋ ๊ฒฝ์ฐ
- ๊ทธ ํค๋
์ด๋ฆ์ด `
*`์ด๊ณ , headerName์ด CORS non-wildcard request-header name์ด ์๋ ๊ฒฝ์ฐ
์ฐธ์ผ๋ก ํ๋ค.
4.10. CORS ์ฒดํฌ
CORS ์ฒดํฌ๋ request์ response์ ๋ํด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
origin์ ๊ฐ์ ธ์ค๊ธฐ๋ก `
Access-Control-Allow-Origin`์ response์ header list์์ ๊ฐ์ ธ์จ ๊ฐ์ผ๋ก ์ค์ ํ๋ค. -
origin์ด null์ด๋ฉด ์คํจ๋ฅผ ๋ฐํํ๋ค.
null์ `
null`์ ๋ค๋ฅด๋ค. -
request์ credentials mode๊ฐ "
include"๊ฐ ์๋๊ณ origin์ด `*`์ด๋ฉด ์ฑ๊ณต์ ๋ฐํํ๋ค. -
์์ฒญ origin ๋ฐ์ดํธ ์ง๋ ฌํ๋ฅผ request๋ก ์คํํ ๊ฒฐ๊ณผ๊ฐ origin๊ณผ ๋ค๋ฅด๋ฉด ์คํจ๋ฅผ ๋ฐํํ๋ค.
-
request์ credentials mode๊ฐ "
include"๊ฐ ์๋๋ฉด ์ฑ๊ณต์ ๋ฐํํ๋ค. -
credentials๋ฅผ ๊ฐ์ ธ์ค๊ธฐ๋ก `
Access-Control-Allow-Credentials`๋ฅผ response์ header list์์ ๊ฐ์ ธ์จ ๊ฐ์ผ๋ก ์ค์ ํ๋ค. -
credentials๊ฐ `
true`์ด๋ฉด ์ฑ๊ณต์ ๋ฐํํ๋ค. -
์คํจ๋ฅผ ๋ฐํํ๋ค.
4.11. TAO ์ฒดํฌ
TAO check๋ฅผ request์ response์ ๋ํด ์ํํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
request์ timing allow failed flag๊ฐ ์ค์ ๋์ด ์์ผ๋ฉด, ์คํจ๋ฅผ ๋ฐํํ๋ค.
-
values๋ฅผ, `
Timing-Allow-Origin` ํค๋๋ฅผ ๊ฐ์ ธ์ ๋์ฝ๋ฉ ๋ฐ ๋ถํ ํ response์ header list์ ๋ํ ๊ฒฐ๊ณผ๋ก ํ๋ค. -
values๊ฐ "
*"๋ฅผ ํฌํจํ๋ฉด, ์ฑ๊ณต์ ๋ฐํํ๋ค. -
values๊ฐ, request origin์ ์ง๋ ฌํํ ๊ฐ์ request๋ก ์ป์ด ํฌํจํ๋ฉด, ์ฑ๊ณต์ ๋ฐํํ๋ค.
-
request์ mode๊ฐ "
navigate"์ด๊ณ request์ current URL์ origin์ด request์ origin๊ณผ ๋์ผ ์ถ์ฒ๊ฐ ์๋๋ฉด, ์คํจ๋ฅผ ๋ฐํํ๋ค.์ด ๋จ๊ณ๋ nested navigable์ ๋ค๋น๊ฒ์ด์ ์ ์ํด ํ์ํ๋ค. ์ด ๊ฒฝ์ฐ request์ origin์ ์ปจํ ์ด๋ ๋ฌธ์์ origin์ด ๋๊ณ , TAO check๋ ์คํจ๋ฅผ ๋ฐํํ๋ค. ๋ค๋น๊ฒ์ด์ ํ์ด๋ฐ์ TAO check ๊ฒฐ๊ณผ๋ฅผ ๊ฒ์ฆํ์ง ์๊ธฐ ๋๋ฌธ์, nested document์์๋ ์ ์ฒด ํ์ด๋ฐ ์ ๋ณด๋ฅผ ๋ณผ ์ ์์ง๋ง, ์ปจํ ์ด๋ ๋ฌธ์์์๋ ๋ณผ ์ ์๋ค.
-
request์ response tainting์ด "
basic"์ด๋ฉด ์ฑ๊ณต์ ๋ฐํํ๋ค. -
์คํจ๋ฅผ ๋ฐํํ๋ค.
์์ฒญ request์ ์๋ต response๊ฐ ์ฃผ์ด์ก์ ๋, ์์ฒญ์ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ ๋ง๋ถ์ด๊ธฐ๋:
-
Assert: request๋ ๋ด๋น๊ฒ์ด์ ์์ฒญ์ด๋ค.
-
taoValues๋ฅผ response์ header list์์ `
Timing-Allow-Origin`์ ๊ฐ์ ธ์ค๊ณ , ๋์ฝ๋ฉํ๊ณ , ๋ถํ ํ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
taoValues๊ฐ null์ด๋ฉด, taoValues๋ฅผ ยซ ยป๋ก ์ค์ ํ๋ค.
-
taoValues๋ฅผ request์ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ ๋ง๋ถ์ธ๋ค.
์๋ต response์ origin destinationOrigin์ ๋ํด ๋ด๋น๊ฒ์ด์ TAO ๊ฒ์ฌ๋ฅผ ์ํํ๋ ค๋ฉด:
-
response์ ๋ด๋น๊ฒ์ด์ ํ์ด๋ฐ ํ์ฉ ๊ฐ ๋ชฉ๋ก์ ๊ฐ taoValues์ ๋ํด For each๋ฅผ ์ํํ๋ค:
-
taoValues๊ฐ "
*"๋ฅผ ํฌํจํ๋ฉด, continueํ๋ค. -
taoValues๊ฐ destinationOrigin์ ์ง๋ ฌํํ ๊ฐ์ ํฌํจํ๋ฉด, continueํ๋ค.
-
failure๋ฅผ ๋ฐํํ๋ค.
-
-
success๋ฅผ ๋ฐํํ๋ค.
4.12. ์ง์ฐ fetch
์ง์ฐ ํ์นญ(deferred fetching)์ ํธ์ถ์๊ฐ fetch๊ฐ ๊ฐ๋ฅํ ํ ๋ง์ง๋ง ์๊ฐ์ ํธ์ถ๋๋๋ก ์์ฒญํ ์ ์๊ฒ ํด์ค๋ค. ์ฆ, fetch group์ด ์ข ๋ฃ๋๊ฑฐ๋, ํ์์์์ด ์ง๋ ๋ค์ ํธ์ถ๋๋ค.
์ง์ฐ fetch ์์
์์ค(deferred fetch
task source)๋, ์ง์ฐ fetch์ ๊ฒฐ๊ณผ๋ฅผ ์
๋ฐ์ดํธํ๊ธฐ ์ํด ์ฌ์ฉํ๋ ์์
์์ค(task
source)์ด๋ค. ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ด ์์
์์ค์ ์ํ ์์
์ ๋ค๋ฅธ ์์
์์ค๋ณด๋ค, ํนํ DOM ์กฐ์ ์์
์์ค์ ๊ฐ์ด ์คํฌ๋ฆฝํธ๊ฐ ์คํ๋ ์ ์๋ ์์
์์ค๋ณด๋ค ์ฐ์ ์ฒ๋ฆฌํด์ผ ํ๋ค. ์ด๊ฒ์
์คํฌ๋ฆฝํธ๊ฐ fetch ๊ฒฐ๊ณผ์ ์์กดํ๊ธฐ ์ ์ ์ต์ fetchLater() ํธ์ถ์ ์ํ๊ฐ ๋ฐ์๋๋๋ก ํ๊ธฐ ์ํจ์ด๋ค.
์์ฒญ
request, null ๋๋
DOMHighResTimeStamp
activateAfter, ๊ทธ๋ฆฌ๊ณ ์ธ์๋ฅผ ๋ฐ์ง ์๋ ์๊ณ ๋ฆฌ์ฆ์ธ
onActivatedWithoutTermination์ด ์ฃผ์ด์ก์ ๋,
deferred
fetch๋ฅผ ํ์ ๋ฃ๊ธฐ๋:
-
request๊ฐ ์ฃผ์ด์ก์ ๋ ํด๋ผ์ด์ธํธ์์ ์์ฒญ์ ์ฑ์ด๋ค.
-
request์ service-workers mode๋ฅผ "
none"์ผ๋ก ์ค์ ํ๋ค. -
request์ keepalive๋ฅผ true๋ก ์ค์ ํ๋ค.
-
deferredRecord๋ฅผ ์ deferred fetch record๋ก ๋๋ฉฐ, ๊ทธ request๋ request์ด๊ณ , ๊ทธ notify invoked๋ onActivatedWithoutTermination์ด๋ค.
-
deferredRecord๋ฅผ request์ client์ fetch group์ deferred fetch records์ ๋ง๋ถ์ธ๋ค.
-
activateAfter๊ฐ null์ด ์๋๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
์ฌ์ฉ์ ์์ด์ ํธ๋ ๋ค์ ์กฐ๊ฑด ์ค ํ๋๊ฐ ์ถฉ์กฑ๋ ๋๊น์ง ๊ธฐ๋ค๋ ค์ผ ํ๋ค:
-
์ ์ด๋ activateAfter ๋ฐ๋ฆฌ์ด๊ฐ ์ง๋ฌ๋ค.
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ ๊ธฐํ๋ฅผ ๊ณง ์๊ฒ ๋๋ค๊ณ ๋ฏฟ์ ์ด์ ๊ฐ ์๋ค. ์๋ฅผ ๋ค์ด, ๋ธ๋ผ์ฐ์ ๊ฐ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์ด๋ํ๊ฑฐ๋, request์ client์ ์ ์ญ ๊ฐ์ฒด๊ฐ
Window๊ฐ์ฒด์ด๊ณ ๊ทธ ์ฐ๊ด ๋ฌธ์๊ฐ ์ค๋ ์๊ฐ ๋์ "hidden" visibility state๋ฅผ ๊ฐ์ง ๊ฒฝ์ฐ์ด๋ค.
-
-
deferredRecord๋ฅผ ์ฒ๋ฆฌํ๋ค.
-
-
deferredRecord๋ฅผ ๋ฐํํ๋ค.
์์ฒญ request์ total request length๋ฅผ ๊ณ์ฐํ๋ ค๋ฉด:
-
totalRequestLength๋ฅผ request์ URL์ exclude fragment๋ฅผ true๋ก ์ค์ ํ์ฌ ์ง๋ ฌํํ ๊ฒ์ ๊ธธ์ด๋ก ๋๋ค.
-
totalRequestLength๋ฅผ request์ referrer๋ฅผ ์ง๋ ฌํํ ๊ฒ์ ๊ธธ์ด๋งํผ ์ฆ๊ฐ์ํจ๋ค.
-
request์ header list์ ๊ฐ (name, value)์ ๋ํด For each๋ฅผ ์ํํ์ฌ, totalRequestLength๋ฅผ name์ ๊ธธ์ด + value์ ๊ธธ์ด๋งํผ ์ฆ๊ฐ์ํจ๋ค.
-
totalRequestLength๋ฅผ request์ body์ length๋งํผ ์ฆ๊ฐ์ํจ๋ค.
-
totalRequestLength๋ฅผ ๋ฐํํ๋ค.
fetch group fetchGroup๊ฐ ์ฃผ์ด์ก์ ๋ deferred fetch๋ค์ ์ฒ๋ฆฌํ๊ธฐ๋:
-
fetchGroup์ deferred fetch records์ ๊ฐ deferred fetch record deferredRecord์ ๋ํด For each๋ฅผ ์ํํ์ฌ, deferredRecord๋ฅผ deferred fetch ์ฒ๋ฆฌํ๊ธฐํ๋ค.
deferredRecord๋ฅผ deferred fetch ์ฒ๋ฆฌํ๊ธฐ๋:
-
deferredRecord์ invoke state๊ฐ "
pending"์ด ์๋๋ฉด ๋ฐํํ๋ค. -
deferredRecord์ invoke state๋ฅผ "
sent"๋ก ์ค์ ํ๋ค. -
deferredRecord์ request์ client์ ์ ์ญ ๊ฐ์ฒด์์ deferredRecord์ notify invoked๋ฅผ ์คํํ๋๋ก ์ ์ญ task๋ฅผ ํ์ ๋ฃ๋๋ค. ์ด๋ deferred fetch task source์์ ์ํํ๋ค.
4.12.1. ์ง์ฐ fetch ํ ๋น๋
์ด ์ ์ ๋น๊ท๋ฒ์ ์ด๋ค.
์ง์ฐ fetch ํ ๋น๋์ ์ต์์ traversable(์ฆ "ํญ") ๋จ์๋ก ํ ๋น๋๋ฉฐ, ์ด 640ํค๋น๋ฐ์ดํธ์ด๋ค. ์ต์์ ๋ฌธ์์ ๋์ผ ์ถ์ฒ์ ์ง์ ์ค์ฒฉ ๋ฌธ์๋ค์ด ์ด ํ ๋น๋์ ์ฌ์ฉํ์ฌ ์ง์ฐ fetch๋ฅผ ํ์ํ๊ฑฐ๋, ์ผ๋ถ๋ฅผ ๊ต์ฐจ ์ถ์ฒ ์ค์ฒฉ ๋ฌธ์๋ก ์์ํ ์ ์๋ค(permissions policy ์ฌ์ฉ).
๊ธฐ๋ณธ์ ์ผ๋ก 640ํค๋น๋ฐ์ดํธ ์ค 128ํค๋น๋ฐ์ดํธ๊ฐ ๊ต์ฐจ ์ถ์ฒ ์ค์ฒฉ ๋ฌธ์๋ก ํ ๋น๋ ์์์ ์ฐ์ด๋ฉฐ, ๊ฐ ์ค์ฒฉ ๋ฌธ์๋ 8ํค๋น๋ฐ์ดํธ๋ฅผ ์์ฝํ๋ค.
์ต์์ ๋ฌธ์ ๋ฐ ๊ทธ ์ค์ฒฉ ๋ฌธ์๋ permissions policy๋ฅผ ํตํด ๊ต์ฐจ ์ถ์ฒ ์์ ๋ฌธ์์ ์ผ๋ง๋ ํ ๋น๋์ ์์ํ ์ง ์ ์ดํ ์
์๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก
"deferred-fetch-minimal"
์ ์ฑ
์ ๋ชจ๋ origin์ ๋ํด ํ์ฑํ๋์ด ์๊ณ ,
"deferred-fetch"
์ ์ฑ
์ ์ต์์ ๋ฌธ์์ origin์ ๋ํด์๋ง ํ์ฑํ๋์ด ์๋ค. ํน์ origin ๋๋ ์ค์ฒฉ ๋ฌธ์์ ๋ํด
"deferred-fetch"
์ ์ฑ
์ relaxํ๋ฉด ํด๋น ์ค์ฒฉ ๋ฌธ์์ 64ํค๋น๋ฐ์ดํธ๋ฅผ ํ ๋นํ ์ ์๋ค. ๋ฐ๋๋ก
"deferred-fetch-minimal"
์ ์ฑ
์ origin ๋๋ ์ค์ฒฉ ๋ฌธ์์ ์ ํํ๋ฉด, ํด๋น ๋ฌธ์๊ฐ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ฐ์ 8ํค๋น๋ฐ์ดํธ ์์ฝ์ด ๋ฐฉ์ง๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ต์์ ๋ฌธ์ ์์ฒด์ ๋ํด
"deferred-fetch-minimal"
์ ์ฑ
์ ๋นํ์ฑํํ๋ฉด, ์์๋ 128ํค๋น๋ฐ์ดํธ ์ ์ฒด ํ ๋น๋์ด 640ํค๋น๋ฐ์ดํธ ๋ฉ์ธ ํ๋ก ๋ค์ ํฉ์ณ์ง๋ค.
์ด๋ค ๋ฌธ์์ ๋ํด ํ ๋น๋ ์ ์ฒด ํ ๋น๋ ์ค, ๋์ผ ๋ฆฌํฌํ origin(์ฆ request์ URL์ origin)์ ๋ํด ๋์์ ์ฌ์ฉํ ์ ์๋ ๊ฒ์ 64ํค๋น๋ฐ์ดํธ๊น์ง์ด๋ค. ์ด๋ ํน์ ์๋ํํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ค์ ๋ก ๋ณด๋ผ ๋ฐ์ดํฐ๊ฐ ์์ด ํ ๋น๋๋ง ์ ์ ํ๋ ์ํฉ์ ๋ฐฉ์งํ๋ค.
์๋์ fetchLater() ํธ์ถ์ ์์ฒญ ์์ฒด๊ฐ ํ ๋ณด๊ณ ์ค๋ฆฌ์ง์ ํ ๋น๋ 64ํค๋น๋ฐ์ดํธ
ํ ๋น๋์ ์ด๊ณผํ๋ฏ๋ก ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค. ์์ฒญ์ ํฌ๊ธฐ์๋ URL๊ณผ body, header list, referrer๊ฐ ๋ชจ๋ ํฌํจ๋ฉ๋๋ค.
fetchLater(a_72_kb_url);
fetchLater("https://origin.example.com", {headers: headers_exceeding_64kb});
fetchLater(a_32_kb_url, {headers: headers_exceeding_32kb});
fetchLater("https://origin.example.com", {method: "POST", body: body_exceeding_64_kb});
fetchLater(a_62_kb_url /* with a 3kb referrer */);
๋ค์ ์ํ์ค์์ ์ฒ์ ๋ ์์ฒญ์ ์ฑ๊ณตํ์ง๋ง, ์ธ ๋ฒ์งธ๋ ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ฒ์ ๋ ๋ฒ์ ์ ์ฒด 640ํค๋น๋ฐ์ดํธ ํ ๋น๋์ ์ด๊ณผํ์ง ์์ง๋ง, ์ธ ๋ฒ์งธ ์์ฒญ์
https://a.example.com์ ๋ํ ๋ณด๊ณ ์ค๋ฆฌ์ง ํ ๋น๋์ ์ด๊ณผํ๊ธฐ ๋๋ฌธ์ ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค.
fetchLater("https://a.example.com", {method: "POST", body: a_64kb_body});
fetchLater("https://b.example.com", {method: "POST", body: a_64kb_body});
fetchLater("https://a.example.com");
๋์ผ ์ถ์ฒ ์ค์ฒฉ ๋ฌธ์๋ ๋ถ๋ชจ์ ํ ๋น๋์ ๊ณต์ ํฉ๋๋ค. ํ์ง๋ง ๊ต์ฐจ ์ถ์ฒ ๋๋ ๊ต์ฐจ agent iframe์ ๊ธฐ๋ณธ์ ์ผ๋ก 8kb๋ง ํ ๋น๋ฐ์ต๋๋ค. ๋ฐ๋ผ์ ์๋ ์์์ ์ฒ์ ์ธ ๋ฒ ํธ์ถ์ ์ฑ๊ณตํ๊ณ , ๋ง์ง๋ง์ ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค.
// In main page
fetchLater("https://a.example.com", {method: "POST", body: a_64kb_body});
// In same-origin nested document
fetchLater("https://b.example.com", {method: "POST", body: a_64kb_body});
// In cross-origin nested document at https://fratop.example.com
fetchLater("https://a.example.com", {body: a_5kb_body});
fetchLater("https://a.example.com", {body: a_12kb_body});
์ด์ ์์์ ์์ธ๊ฐ ๋ฐ์ํ์ง ์๊ฒ ํ๋ ค๋ฉด, ์ต์์ ๋ฌธ์๊ฐ https://fratop.example.com์ ์ผ๋ถ ํ ๋น๋์ ์์ํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ค์ ํค๋๋ฅผ
์ ๊ณตํ๋ฉด ๋ฉ๋๋ค:
Permissions-Policy: deferred-fetch=(self "https://fratop.example.com")
๊ฐ ์ค์ฒฉ ๋ฌธ์๋ ์์ฒด ํ ๋น๋์ ์์ฝํฉ๋๋ค. ๋ฐ๋ผ์ ๋ค์ ์๋ ๊ฐ ํ๋ ์์ด 8ํค๋น๋ฐ์ดํธ๋ฅผ ์์ฝํ๋ฏ๋ก ์ ์์ ์ผ๋ก ๋์ํฉ๋๋ค:
// In cross-origin nested document at https://fratop.example.com/frame-1
fetchLater("https://a.example.com", {body: a_6kb_body});
// In cross-origin nested document at https://fratop.example.com/frame-2
fetchLater("https://a.example.com", {body: a_6kb_body});
์๋ ํธ๋ฆฌ๋ ํธ๋ฆฌ ๋ด ๋ค๋ฅธ ์ค์ฒฉ ๋ฌธ์์ ํ ๋น๋์ด ์ด๋ป๊ฒ ๋ถ๋ฐฐ๋๋์ง ๋ณด์ฌ์ค๋๋ค:
-
https://top.example.com(permissions policy:Permissions-policy: deferred-fetch=(self "https://ok.example.com"))-
https://top.example.com/frame: ์ต์์ traversable๊ณผ ๋์ผ ์ถ์ฒ์ด๋ฏ๋ก ํ ๋น๋์ ๊ณต์ ํจ.-
https://x.example.com: 8ํค๋น๋ฐ์ดํธ ํ ๋น.
-
-
https://x.example.com: 8ํค๋น๋ฐ์ดํธ ํ ๋น.-
https://top.example.com: 0. ์ต์์ traversable๊ณผ ๋์ผ ์ถ์ฒ์ด์ง๋ง, ๊ต์ฐจ ์ถ์ฒ ์ค๊ฐ ๋จ๊ณ๊ฐ ์์ผ๋ฏ๋ก ์๋์ผ๋ก ํ ๋น๋์ ๊ณต์ ํ์ง ์๋๋ค.
-
-
https://ok.example.com/good: "deferred-fetch" ์ ์ฑ ์ผ๋ก 64ํค๋น๋ฐ์ดํธ ํ ๋น.-
https://x.example.com: ํ ๋น๋ ์์. ์ค์ง ์ต์์ traversable๊ณผ ๋์ผ ์ถ์ฒ ๋ฌธ์๋ง "deferred-fetch-minimal" ์ ์ฑ ์ผ๋ก 8ํค๋น๋ฐ์ดํธ๋ฅผ ํ ๋นํ ์ ์๋ค.
-
-
https://ok.example.com/redirect์์https://x.example.com์ผ๋ก ๋ค๋น๊ฒ์ด์ : ํ ๋น๋ ์์.https://ok.example.com์ ์์ฝ๋ 64ํค๋น๋ฐ์ดํธ๋https://x.example.com์ ์ฌ์ฉํ ์ ์๋ค. -
https://ok.example.com/back์์https://top.example.com์ผ๋ก ๋ค๋น๊ฒ์ด์ : ๋์ผ ์ถ์ฒ์ด๋ฏ๋ก ์ต์์ traversable๊ณผ ํ ๋น๋์ ๊ณต์ ํจ.
-
์ ์์์, ์ต์์ traversable๊ณผ ๋์ผ ์ถ์ฒ ์์๋ค์ 384ํค๋น๋ฐ์ดํธ ํ ๋น๋์ ๊ณต์ ํฉ๋๋ค. ๊ทธ ๊ฐ ๊ณ์ฐ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
640ํค๋น๋ฐ์ดํธ๊ฐ ์ต์์ traversable์ ์ฒ์ ํ ๋น๋ฉ๋๋ค.
-
128ํค๋น๋ฐ์ดํธ๊ฐ "
deferred-fetch-minimal" ์ ์ฑ ์ ์์ฝ๋ฉ๋๋ค. -
64ํค๋น๋ฐ์ดํธ๊ฐ
https://ok.example/good๋ค๋น๊ฒ์ด์ ์ ์์ฝ๋ฉ๋๋ค. -
64ํค๋น๋ฐ์ดํธ๊ฐ
https://ok.example/redirect๋ค๋น๊ฒ์ด์ ์ ์์ฝ๋๊ณ , ๋ค๋น๊ฒ์ด์ ํ๋ฉด ์๊ฒ ๋ฉ๋๋ค. https://ok.example.com/back๋ 64ํค๋น๋ฐ์ดํธ๋ฅผ ์์ฝํ์ง ์์์ต๋๋ค. ์ต์์ traversable์ ์ค๋ฆฌ์ง์ผ๋ก ๋์๊ฐ๊ธฐ ๋๋ฌธ์ ๋๋ค.-
640 โ 128 โ 64 โ 64 = 384ํค๋น๋ฐ์ดํธ.
์ด ๋ช
์ธ๋ "deferred-fetch" ๋ฌธ์์ด๋ก ์๋ณ๋๋ ์ ์ฑ
์ ์ด ๊ธฐ๋ฅ์ ์ ์ํฉ๋๋ค. ๊ทธ ๊ธฐ๋ณธ ํ์ฉ ๋ฆฌ์คํธ๋ "self"์
๋๋ค.
์ด ๋ช
์ธ๋ "deferred-fetch-minimal"
๋ฌธ์์ด๋ก ์๋ณ๋๋ ์ ์ฑ
์ ์ด ๊ธฐ๋ฅ์ ์ ์ํฉ๋๋ค. ๊ทธ ๊ธฐ๋ณธ ํ์ฉ ๋ฆฌ์คํธ๋ "*"์
๋๋ค.
deferred-fetch-minimal์ ์์ฝ๋ ํ ๋น๋์
128ํค๋น๋ฐ์ดํธ์
๋๋ค.
๊ฐ navigable container๋ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ ๊ฐ์ต๋๋ค. ๊ฐ๋ฅํ ๊ฐ์ ์ต์ ํ ๋น๋(8ํค๋น๋ฐ์ดํธ)๊ณผ ์ผ๋ฐ ํ ๋น๋(0 ๋๋ 64ํค๋น๋ฐ์ดํธ)์ ๋๋ค. ๋ณ๋ค๋ฅธ ์ธ๊ธ์ด ์์ผ๋ฉด 0์ ๋๋ค.
์ฌ์ฉ ๊ฐ๋ฅ ์ง์ฐ fetch ํ ๋น๋์ ์ป์ผ๋ ค๋ฉด, document document์ origin-๋๋-null origin์ ๋ฐ์:
-
controlDocument๋ฅผ document์ ์ง์ฐ fetch ์ ์ด ๋ฌธ์๋ก ๋๋ค.
-
navigable์ controlDocument์ node navigable๋ก ๋๋ค.
-
isTopLevel์ controlDocument์ node navigable์ด ์ต์์ traversable์ด๋ฉด true, ์๋๋ฉด false๋ก ๋๋ค.
-
deferredFetchAllowed๋ฅผ controlDocument๊ฐ ์ฌ์ฉ ํ๊ฐ๋จ์ด๊ณ , ์ ์ฑ ์ ์ด ๊ธฐ๋ฅ "
deferred-fetch"๋ ํ๊ฐ๋จ์ด๋ฉด true, ์๋๋ฉด false. -
deferredFetchMinimalAllowed๋ฅผ controlDocument๊ฐ ์ฌ์ฉ ํ๊ฐ๋จ์ด๊ณ , ์ ์ฑ ์ ์ด ๊ธฐ๋ฅ "
deferred-fetch-minimal"๋ ํ๊ฐ๋จ์ด๋ฉด true, ์๋๋ฉด false. -
quota๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ๋ ์ฒซ ๋ฒ์งธ ์ผ์น ์กฐ๊ฑด์ ๊ฒฐ๊ณผ๋ก ๋๋ค:
- isTopLevel์ด true์ด๊ณ deferredFetchAllowed๊ฐ false์
- 0
- isTopLevel์ด true์ด๊ณ deferredFetchMinimalAllowed๊ฐ false์
-
640ํค๋น๋ฐ์ดํธ
640kb๋ฉด ๋๊ตฌ์๊ฒ๋ ์ถฉ๋ถํ ์ฉ๋์ ๋๋ค.
- isTopLevel์ด true์
-
512ํค๋น๋ฐ์ดํธ
๊ธฐ๋ณธ๊ฐ 640ํค๋น๋ฐ์ดํธ์์ deferred-fetch-minimal์ ์์ฝ๋ ํ ๋น๋ ๋งํผ ์ฐจ๊ฐ๋จ
- deferredFetchAllowed๊ฐ true์ด๊ณ , navigable์ navigable container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ด ์ผ๋ฐ ํ ๋น๋์ด๋ฉด
- ์ผ๋ฐ ํ ๋น๋
- deferredFetchMinimalAllowed๊ฐ true์ด๊ณ , navigable์ navigable container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ด ์ต์ ํ ๋น๋์ด๋ฉด
- ์ต์ ํ ๋น๋
- ๊ทธ ์ธ์ ๊ฒฝ์ฐ
- 0
-
quotaForRequestOrigin์ 64ํค๋น๋ฐ์ดํธ๋ก ๋๋ค.
-
controlDocument์ node navigable์ inclusive descendant navigables ์ค, ๊ทธ active document์ deferred-fetch control document๊ฐ controlDocument์ธ ๊ฐ navigable์ ๋ํด For each๋ฅผ ์ํํ๋ค:
-
navigable์ active document์ shadow-including inclusive descendants ์ค navigable container์ธ ๊ฐ container์ ๋ํด For each๋ฅผ ์ํํ์ฌ, quota๋ฅผ container์ reserved deferred-fetch quota๋งํผ ๊ฐ์์ํจ๋ค.
-
navigable์ active document์ relevant settings object์ fetch group์ deferred fetch records์ ๊ฐ deferred fetch record deferredRecord์ ๋ํด For each๋ฅผ ์ํํ๋ค:
-
deferredRecord์ invoke state๊ฐ "
pending"์ด ์๋๋ฉด, continueํ๋ค. -
requestLength๋ฅผ deferredRecord์ request์ total request length๋ก ๋๋ค.
-
quota๋ฅผ requestLength๋งํผ ๊ฐ์์ํจ๋ค.
-
deferredRecord์ request์ URL์ origin์ด origin๊ณผ same origin์ด๋ฉด, quotaForRequestOrigin๋ฅผ requestLength๋งํผ ๊ฐ์์ํจ๋ค.
-
-
-
quota๊ฐ 0 ์ดํ์ด๋ฉด 0์ ๋ฐํํ๋ค.
-
quota๊ฐ quotaForRequestOrigin๋ณด๋ค ์์ผ๋ฉด quota๋ฅผ ๋ฐํํ๋ค.
-
quotaForRequestOrigin์ ๋ฐํํ๋ค.
์ง์ฐ fetch ํ ๋น๋ ์์ฝ์ ์คํํ๋ ค๋ฉด, navigable container container์ origin originToNavigateTo๋ฅผ ๋ฐ์:
์ด ์๊ณ ๋ฆฌ์ฆ์ ํ์ ์, ํ์์ ์์ค ๋ฌธ์๊ฐ navigable์ ๋ถ๋ชจ ๋ฌธ์์ผ ๋ ํธ์ถ๋๋ค. ๊ถํ ์ ์ฑ ์ ๋ฐ๋ผ ์ปจํ ์ด๋ ๋ฐ ๊ทธ navigable์ ๋ํด 64kb ๋๋ 8kb์ ํ ๋น๋์ ์ ์ฌ์ ์ผ๋ก ์์ฝํ๋ค. ์ค์ ๋ก ์์ฝ๋ ํ ๋น๋์ด ์ฌ์ฉ๋๋์ง๋ ์ปจํ ์ด๋ ๋ฌธ์์์ ๊ด์ฐฐํ ์ ์๋ค. ์ด ์๊ณ ๋ฆฌ์ฆ์ ์ปจํ ์ด๋์ ๋ฌธ์๊ฐ ํ์๋ ์ปจํ ์ด๋์ ํ ๋น๋์ ์์ํ ์ ์๊ณ , ์์ฝ๋ ํ ๋น๋์ ๊ทธ ๊ฒฝ์ฐ์๋ง ์ ์ฉ๋๋ฉฐ, ๊ณต์ ๋ ๊ฒฝ์ฐ ๋ฌด์๋จ์ ๊ฐ์ ํ๋ค. ํ ๋น๋์ด ์์ฝ๋์๊ณ ๋ฌธ์๊ฐ ๊ฒฐ๊ตญ ๋ถ๋ชจ์ ๋์ผ ์ถ์ฒ๊ฐ ๋๋ฉด, ํ ๋น๋์ ํด์ ๋๋ค.
-
container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ 0์ผ๋ก ์ค์ ํ๋ค.
-
controlDocument๋ฅผ container์ node document์ ์ง์ฐ fetch ์ ์ด ๋ฌธ์๋ก ๋๋ค.
-
"
deferred-fetch"์ ๋ํ ์์๋ ์ ์ฑ ์ด container์ originToNavigateTo์ ๋ํด"Enabled"์ด๊ณ , ์ฌ์ฉ ๊ฐ๋ฅ ์ง์ฐ fetch ํ ๋น๋์ด controlDocument์ ๋ํด ์ผ๋ฐ ํ ๋น๋ ์ด์์ด๋ฉด, container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ ์ผ๋ฐ ํ ๋น๋์ผ๋ก ์ค์ ํ๊ณ ๋ฐํํ๋ค. -
์๋ ์กฐ๊ฑด์ด ๋ชจ๋ true์ด๋ฉด:
-
controlDocument์ node navigable์ด ์ต์์ traversable์
-
"
deferred-fetch-minimal"์ ๋ํ ์์๋ ์ ์ฑ ์ด container์ originToNavigateTo์ ๋ํด"Enabled" -
controlDocument์ node navigable์ ์์ navigables์์, removeํ์ฌ navigable์ navigable container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ด ์ต์ ํ ๋น๋์ด ์๋ ๊ฒ์ ์ ์ธํ ํ, ํฌ๊ธฐ๊ฐ deferred-fetch-minimal์ ์์ฝ๋ ํ ๋น๋ / ์ต์ ํ ๋น๋ ๋ฏธ๋ง์
์ด ๊ฒฝ์ฐ container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ ์ต์ ํ ๋น๋์ผ๋ก ์ค์ ํ๋ค.
-
์ง์ฐ fetch ํ ๋น๋ ํด์ ๊ฐ๋ฅ์ ์คํํ๋ ค๋ฉด, document document๋ฅผ ๋ฐ์, document์ node navigable์ container document๊ฐ null์ด ์๋๊ณ , ๊ทธ origin์ด document์ ๋์ผ ์ถ์ฒ์ด๋ฉด, document์ node navigable์ navigable container์ ์์ฝ๋ ์ง์ฐ fetch ํ ๋น๋์ 0์ผ๋ก ์ค์ ํ๋ค.
์ด ์๊ณ ๋ฆฌ์ฆ์ ๋ฌธ์๊ฐ ์์ฑ๋ ๋ ํธ์ถ๋๋ค. ๋์ผ ์ถ์ฒ ์ค์ฒฉ ๋ฌธ์๋ ์ด์ฐจํผ ๋ถ๋ชจ์ ํ ๋น๋์ ๊ณต์ ํ๋ฏ๋ก ํ ๋น๋์ ์์ฝํ์ง ์๋๋ก ํ๋ค. ์ด๋ ๋ฌธ์ ์์ฑ ์์๋ง ํธ์ถ๋ ์ ์๋๋ฐ, origin์ ๋ฆฌ๋ค์ด๋ ํธ๊ฐ ์ฒ๋ฆฌ๋ ํ์๋ง ์ ์ ์๊ธฐ ๋๋ฌธ์ด๋ค.
์ง์ฐ fetch ์ ์ด ๋ฌธ์๋ฅผ ์ป์ผ๋ ค๋ฉด, document document๋ฅผ ๋ฐ์:
-
document์ node navigable์ container document๊ฐ null์ด๊ฑฐ๋, ๋ฌธ์์ origin์ด document์ ๋์ผ ์ถ์ฒ๊ฐ ์๋๋ฉด, document๋ฅผ ๋ฐํํ๋ค. ๊ทธ ์ธ์๋, ์ง์ฐ fetch ์ ์ด ๋ฌธ์๋ฅผ document์ node navigable์ container document๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
5. Fetch API
fetch() ๋ฉ์๋๋ ๋ฆฌ์์ค ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ์ํ ๋น๊ต์ ์ ์์ค์ API์
๋๋ค. XMLHttpRequest๋ณด๋ค
์ฝ๊ฐ ๋ ๋์ ์์ญ์ ๋ค๋ฃจ์ง๋ง, ํ์ฌ๋ ์์ฒญ ์งํ ์ํฉ(์๋ต ์งํ ์ํฉ ์๋)์ ์์ด ๋ถ์กฑํ ๋ถ๋ถ์ด ์์ต๋๋ค.
fetch() ๋ฉ์๋๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฆฌ์์ค๋ฅผ ๊ฐ์ ธ์ค๊ณ ๊ทธ ๋ด์ฉ์ Blob์ผ๋ก
์ถ์ถํ๋ ๊ฒ์ด ๋งค์ฐ ๊ฐ๋จํฉ๋๋ค:
fetch("/music/pk/altes-kamuffel.flac")
.then(res => res.blob()).then(playBlob)
ํน์ ์๋ต ํค๋๋ง ๋ก๊ทธ๋ก ๋จ๊ธฐ๊ณ ์ถ๋ค๋ฉด:
fetch("/", {method:"HEAD"})
.then(res => log(res.headers.get("strict-transport-security")))
๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค์ ํน์ ์๋ต ํค๋๋ฅผ ํ์ธํ ๋ค ์๋ต์ ์ฒ๋ฆฌํ๋ ค๋ฉด:
fetch("https://pk.example/berlin-calling.json", {mode:"cors"})
.then(res => {
if(res.headers.get("content-type") &&
res.headers.get("content-type").toLowerCase().indexOf("application/json") >= 0) {
return res.json()
} else {
throw new TypeError()
}
}).then(processJSON)
URL ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ๋ฅผ ๋ค๋ฃจ๊ณ ์ถ๋ค๋ฉด:
var url = new URL("https://geo.example.org/api"),
params = {lat:35.696233, long:139.570431}
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
fetch(url).then(/* โฆ */)
๋ฐ๋ ๋ฐ์ดํฐ๋ฅผ ์ ์ง์ ์ผ๋ก ๋ฐ๊ณ ์ถ๋ค๋ฉด:
function consume(reader) {
var total = 0
return pump()
function pump() {
return reader.read().then(({done, value}) => {
if (done) {
return
}
total += value.byteLength
log(`received ${value.byteLength} bytes (${total} bytes in total)`)
return pump()
})
}
}
fetch("/music/pk/altes-kamuffel.flac")
.then(res => consume(res.body.getReader()))
.then(() => log("์ ์ฒด ๋ฐ๋๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ๋ณด์กดํ์ง ์๊ณ ๋ชจ๋ ์๋นํจ!"))
.catch(e => log("๋ฌธ์ ๊ฐ ๋ฐ์ํจ: " + e))
5.1. Headers ํด๋์ค
typedef (sequence <sequence <ByteString >>or record <ByteString ,ByteString >); [HeadersInit Exposed =(Window ,Worker )]interface {Headers constructor (optional HeadersInit );init undefined append (ByteString ,name ByteString );value undefined delete (ByteString );name ByteString ?get (ByteString );name sequence <ByteString >getSetCookie ();boolean has (ByteString );name undefined set (ByteString ,name ByteString );value iterable <ByteString ,ByteString >; };
Headers ๊ฐ์ฒด๋
์ฐ๊ด๋
ํค๋ ๋ฆฌ์คํธ (์ฆ,
header list)๋ฅผ
๊ฐ์ง๋ค.
์ด ๋ฆฌ์คํธ๋ ์ฒ์์ ๋น์ด ์๋ค. ์ด ๊ฐ์ ๋ค๋ฅธ ๊ฐ์ฒด์ header list๋ฅผ ๊ฐ๋ฆฌํฌ ์๋ ์๋ค. ์๋ฅผ ๋ค์ด,
Request ๊ฐ์ฒด๊ฐ
๋ณด์ฌ์ฃผ๋ฏ์ด
request์ ํค๋ ๋ฆฌ์คํธ๋ฅผ ๊ฐ๋ฆฌํฌ
์ ์๋ค.
Headers ๊ฐ์ฒด๋
guard๋ ๊ฐ์ง๋ฉฐ, ์ด๋ ํค๋ guard์
๋๋ค. ํค๋ guard๋
"immutable", "request",
"request-no-cors", "response", "none" ์ค ํ๋์
๋๋ค.
headers = new Headers([init])-
์
Headers๊ฐ์ฒด๋ฅผ ์์ฑํฉ๋๋ค. init์ ์ฌ์ฉํด ๋ด๋ถ ํค๋ ๋ฆฌ์คํธ๋ฅผ ์ฑ์ธ ์ ์์ต๋๋ค. ์๋ ์์ ์ฐธ๊ณ . headers . append(name, value)-
headers์ ํค๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
headers . delete(name)-
headers์์ ํค๋๋ฅผ ์ ๊ฑฐํฉ๋๋ค.
headers . get(name)-
name์ธ ๋ชจ๋ ํค๋ ๊ฐ๋ค์ ๋ฌธ์์ด๋ก ๋ฐํํ๋ฉฐ, ๊ฐ๋ค์ ์ฝค๋ง์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถ๋ฉ๋๋ค.
headers . getSetCookie()-
์ด๋ฆ์ด `
Set-Cookie`์ธ ๋ชจ๋ ํค๋ ๊ฐ์ ๋ฆฌ์คํธ๋ก ๋ฐํํฉ๋๋ค. headers . has(name)-
name์ธ ํค๋๊ฐ ์กด์ฌํ๋์ง ์ฌ๋ถ๋ฅผ ๋ฐํํฉ๋๋ค.
headers . set(name, value)-
์ด๋ฆ์ด name์ธ ์ฒซ ๋ฒ์งธ ํค๋ ๊ฐ์ value๋ก ๋์ฒดํ๊ณ , ๋์ผํ ์ด๋ฆ์ ๋จ์ ํค๋๋ ๋ชจ๋ ์ ๊ฑฐํฉ๋๋ค.
for(const [name, value] of headers)-
headers๋ฅผ ๋ฐ๋ณต(iterate)ํ ์ ์์ต๋๋ค.
์ ํจ์ฑ ๊ฒ์ฌ๋ฅผ header (name, value)์ ๋ํด
Headers
๊ฐ์ฒด headers๋ก ์คํํ๋ ค๋ฉด:
-
name์ด ํค๋ ์ด๋ฆ์ด ์๋๊ฑฐ๋ value๊ฐ ํค๋ ๊ฐ์ด ์๋๋ฉด, TypeError๋ฅผ ๋์ง๋ค.
-
headers์ guard๊ฐ "
immutable"์ด๋ฉด TypeError๋ฅผ ๋์ง๋ค. -
headers์ guard๊ฐ "
request"์ด๊ณ , (name, value)๊ฐ ๊ธ์ง๋ ์์ฒญ ํค๋๋ฉด false๋ฅผ ๋ฐํํ๋ค. -
headers์ guard๊ฐ "
response"์ด๊ณ , name์ด ๊ธ์ง๋ ์๋ต ํค๋ ์ด๋ฆ์ด๋ฉด false๋ฅผ ๋ฐํํ๋ค. -
true๋ฅผ ๋ฐํํ๋ค.
"request-no-cors"์ ๋จ๊ณ๋ ๊ณต์ ๋์ง ์์ต๋๋ค. delete()์์
ํญ์ ์ฑ๊ณตํ๋ ๊ฐ์ง ๊ฐ(CORS ์์ ๋ชฉ๋ก ์์ฒญ ํค๋์ ๋ํด)์ด ์์ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค.
์ถ๊ฐ๋ฅผ header
(name, value)์ ๋ํด Headers ๊ฐ์ฒด
headers์ ์คํํ๋ ค๋ฉด:
-
value ์ ๊ทํ๋ฅผ value์ ์คํํ๋ค.
-
์ ํจ์ฑ ๊ฒ์ฌ (name, value)๋ฅผ headers์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๊ฐ false๋ฉด returnํ๋ค.
-
headers์ guard๊ฐ "
request-no-cors"์ด๋ฉด:-
temporaryValue๋ฅผ get name์ headers์ ํค๋ ๋ฆฌ์คํธ๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
temporaryValue๊ฐ null์ด๋ฉด temporaryValue๋ฅผ value๋ก ์ค์ ํ๋ค.
-
๊ทธ ์ธ์๋ temporaryValue์ 0x2C 0x20์ ์ด์ด ๋ถ์ด๊ณ , value๋ฅผ ์ด์ด ๋ถ์ธ๋ค.
-
(name, temporaryValue)๊ฐ no-CORS ์์ ๋ชฉ๋ก ์์ฒญ ํค๋๊ฐ ์๋๋ฉด return ํ๋ค.
-
-
append (name, value)๋ฅผ headers์ ํค๋ ๋ฆฌ์คํธ์ ์ถ๊ฐํ๋ค.
-
headers์ guard๊ฐ "
request-no-cors"์ด๋ฉด ๊ถํ ์๋ no-CORS ์์ฒญ ํค๋ ์ ๊ฑฐ๋ฅผ headers์ ์คํํ๋ค.
์ฑ์ฐ๊ธฐ๋ฅผ Headers ๊ฐ์ฒด
headers์ ๊ฐ์ฒด object๋ก ์คํํ๋ ค๋ฉด:
๊ถํ ์๋ no-CORS ์์ฒญ ํค๋ ์ ๊ฑฐ๋ฅผ
Headers ๊ฐ์ฒด
(headers)์ ์คํํ๋ ค๋ฉด:
-
๊ฐ headerName์ ๋ํด ๊ถํ ์๋ no-CORS ์์ฒญ ํค๋ ์ด๋ฆ๋ค์์:
-
Delete headerName์ headers์ ํค๋ ๋ฆฌ์คํธ์์ ์ญ์ ํ๋ค.
-
์ด ๋จ๊ณ๋ ๊ถํ ์๋ ์ฝ๋๊ฐ ํค๋๋ฅผ ์์ ํ ๋ ํธ์ถ๋๋ค.
new Headers(init)
์์ฑ์ ๋จ๊ณ:
delete(name) ๋ฉ์๋ ๋จ๊ณ:
-
์ ํจ์ฑ ๊ฒ์ฌ (name, ``)๋ฅผ this์ ์คํํ ๊ฒฐ๊ณผ๊ฐ false๋ฉด returnํ๋ค.
์์์ ํค๋ ๊ฐ์ ์ ๋ฌํด๋ ๋ถ์์ฉ์ด ์์ด์ผ ํ๋ค.
-
this์ guard๊ฐ "
request-no-cors"์ด๊ณ , name์ด no-CORS ์์ ๋ชฉ๋ก ์์ฒญ ํค๋ ์ด๋ฆ์ด ์๋๊ณ , name์ด ๊ถํ ์๋ no-CORS ์์ฒญ ํค๋ ์ด๋ฆ์ด ์๋๋ฉด returnํ๋ค. -
this์ ํค๋ ๋ฆฌ์คํธ์ name์ด ์์ผ๋ฉด returnํ๋ค.
-
Delete name์ this์ ํค๋ ๋ฆฌ์คํธ์์ ์ญ์ ํ๋ค.
-
this์ guard๊ฐ "
request-no-cors"์ด๋ฉด ๊ถํ ์๋ no-CORS ์์ฒญ ํค๋ ์ ๊ฑฐ๋ฅผ this์ ์คํํ๋ค.
get(name) ๋ฉ์๋ ๋จ๊ณ:
-
name์ด ํค๋ ์ด๋ฆ์ด ์๋๋ฉด TypeError๋ฅผ ๋์ง๋ค.
-
get name์ this์ ํค๋ ๋ฆฌ์คํธ๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
getSetCookie() ๋ฉ์๋ ๋จ๊ณ:
-
this์ ํค๋ ๋ฆฌ์คํธ์ `
Set-Cookie`๊ฐ ์์ผ๋ฉด ยซ ยป๋ฅผ ๋ฐํํ๋ค. -
๊ฐ๋ค์ ๋ฐํํ๋ค. ํค๋ ์ค this์ ํค๋ ๋ฆฌ์คํธ์์ ์ด๋ฆ์ด `
Set-Cookie`์ ๋ฐ์ดํธ ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ์ผ์นํ๋ ๋ชจ๋ ํค๋์ ๊ฐ์ ์์๋๋ก ๋ฐํํ๋ค.
has(name) ๋ฉ์๋ ๋จ๊ณ:
-
name์ด ํค๋ ์ด๋ฆ์ด ์๋๋ฉด TypeError๋ฅผ ๋์ง๋ค.
-
this์ ํค๋ ๋ฆฌ์คํธ์ name์ด ์์ผ๋ฉด true, ์๋๋ฉด false๋ฅผ ๋ฐํํ๋ค.
set(name, value)
๋ฉ์๋ ๋จ๊ณ:
-
value ์ ๊ทํ๋ฅผ value์ ์คํํ๋ค.
-
์ ํจ์ฑ ๊ฒ์ฌ (name, value)๋ฅผ this์ ์คํํ ๊ฒฐ๊ณผ๊ฐ false๋ฉด returnํ๋ค.
-
this์ guard๊ฐ "
request-no-cors"์ด๊ณ , (name, value)๊ฐ no-CORS ์์ ๋ชฉ๋ก ์์ฒญ ํค๋๊ฐ ์๋๋ฉด returnํ๋ค. -
set (name, value)๋ฅผ this์ ํค๋ ๋ฆฌ์คํธ์ ์คํํ๋ค.
-
this์ guard๊ฐ "
request-no-cors"์ด๋ฉด ๊ถํ ์๋ no-CORS ์์ฒญ ํค๋ ์ ๊ฑฐ๋ฅผ this์ ์คํํ๋ค.
๋ฐ๋ณตํ ๊ฐ ์์ ์ ๋ ฌ ๋ฐ ๊ฒฐํฉ์ this์ ํค๋ ๋ฆฌ์คํธ์ ์คํํ ๊ฒฐ๊ณผ์ด๋ค.
5.2. BodyInit ์ ๋์ธ
typedef (Blob or BufferSource or FormData or URLSearchParams or USVString );XMLHttpRequestBodyInit typedef (ReadableStream or XMLHttpRequestBodyInit );BodyInit
์์ ์ถ์ถ์ ํ์
์ด ์ง์ ๋ body๋ฅผ
๋ฐ์ดํธ
์ํ์ค ๋๋ BodyInit ๊ฐ์ฒด
object์์ ์ถ์ถํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ๋ค:
-
object๊ฐ
ReadableStream๊ฐ์ฒด๋ผ๋ฉด:-
Assert: object๋ ํ๋ค๋ฆผ(disturbed)๋ ์๋๊ณ locked๋ ์๋๋ค.
-
-
์ถ์ถ์ object์ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์์ ์ถ์ถ ๋์์ ์์ธ๋ฅผ ๋์ง์ง ์๋ ์ถ์ถ์ ๋ถ๋ถ์งํฉ์ด๋ค.
์ถ์ถ์
ํ์
์ด ์ง์ ๋ body๋ก
๋ฐ์ดํธ
์ํ์ค ๋๋ BodyInit ๊ฐ์ฒด
object์์,
์ ํ์ ๋ถ๋ฆฌ์ธ keepalive(๊ธฐ๋ณธ๊ฐ false)๋ก ์คํํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ๋ค:
-
stream์ null๋ก ๋๋ค.
-
object๊ฐ
ReadableStream๊ฐ์ฒด๋ผ๋ฉด stream์ object๋ก ์ค์ ํ๋ค. -
๊ทธ ์ธ์ object๊ฐ
Blob๊ฐ์ฒด๋ผ๋ฉด, stream์ object์ get stream ์คํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค. -
๊ทธ ์ธ์๋ stream์ ์
ReadableStream๊ฐ์ฒด๋ก ๋๊ณ , ๋ฐ์ดํธ ์ฝ๊ธฐ ์ง์์ผ๋ก set up์ stream์ ์คํํ๋ค. -
Assert: stream์
ReadableStream๊ฐ์ฒด๋ค. -
action์ null๋ก ๋๋ค.
-
source๋ฅผ null๋ก ๋๋ค.
-
length๋ฅผ null๋ก ๋๋ค.
-
type์ null๋ก ๋๋ค.
-
object ํ์ ์ ๋ฐ๋ผ ๋ค์์ ์คํํ๋ค:
Blob-
source๋ฅผ object๋ก ์ค์ ํ๋ค.
length๋ฅผ object์
size๋ก ์ค์ ํ๋ค.object์
type์์ฑ์ด ๋น ๋ฐ์ดํธ ์ํ์ค๊ฐ ์๋๋ฉด, type์ ํด๋น ๊ฐ์ผ๋ก ์ค์ ํ๋ค. - ๋ฐ์ดํธ ์ํ์ค
-
source๋ฅผ object๋ก ์ค์ ํ๋ค.
BufferSource-
source๋ฅผ object๊ฐ ๊ฐ์ง ๋ฐ์ดํธ์ ๋ณต์ฌ๋ณธ์ผ๋ก ์ค์ ํ๋ค.
FormData-
action์ ๋ค์ ๋จ๊ณ๋ก ์ค์ :
multipart/form-data์ธ์ฝ๋ฉ ์๊ณ ๋ฆฌ์ฆ์ object์ entry list์ UTF-8๋ก ์คํ.source๋ฅผ object๋ก ์ค์ ํ๋ค.
length๋ฅผ ๋ถ๋ช ํ, ๊ฐ์ ์ html/6424 ์ฐธ๊ณ ๋ก ์ค์ ํ๋ค.
type์ `
multipart/form-data; boundary=` +multipart/form-data๊ฒฝ๊ณ ๋ฌธ์์ด ( multipart/form-data ์ธ์ฝ๋ฉ ์๊ณ ๋ฆฌ์ฆ ์ผ๋ก ์์ฑ๋จ)๋ก ์ค์ ํ๋ค. URLSearchParams-
source๋ฅผ
application/x-www-form-urlencodedserializer๋ฅผ object์ list์ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.type์ `
application/x-www-form-urlencoded;charset=UTF-8`์ผ๋ก ์ค์ ํ๋ค. - ์ค์นผ๋ผ ๊ฐ ๋ฌธ์์ด
-
source๋ฅผ UTF-8 ์ธ์ฝ๋ฉ์ object์ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
type์ `
text/plain;charset=UTF-8`๋ก ์ค์ ํ๋ค. ReadableStream-
keepalive๊ฐ true๋ฉด TypeError๋ฅผ ๋์ง๋ค.
object๊ฐ ํ๋ค๋ฆผ(disturbed)์ด๋ locked์ด๋ฉด TypeError๋ฅผ ๋์ง๋ค.
-
source๊ฐ ๋ฐ์ดํธ ์ํ์ค๋ผ๋ฉด, action์ source๋ฅผ ๋ฐํํ๋ ๋จ๊ณ๋ก ์ค์ ํ๊ณ , length๋ฅผ source์ ๊ธธ์ด๋ก ๋๋ค.
-
action์ด null์ด ์๋๋ฉด, ์๋ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
action์ ์คํํ๋ค.
๋ฐ์ดํธ๊ฐ ํ๋ ์ด์ ์ฌ์ฉ ๊ฐ๋ฅํ๊ณ stream์ด errored๊ฐ ์๋๋ฉด, enqueue๋ฅผ, Uint8Array ์์ฑ์ ์ฌ์ฉํ์ฌ ์ฌ์ฉ ๊ฐ๋ฅํ ๋ฐ์ดํธ๋ฅผ stream์ ์ถ๊ฐํ๋ค.
action ์คํ์ด ๋๋๋ฉด, close๋ฅผ stream์ ์คํํ๋ค.
-
-
body๋ฅผ body์ ์ ์ธ์คํด์ค๋ก ๋๊ณ , stream์ stream, source๋ source, length๋ length๋ก ์ค์ ํ๋ค.
-
(body, type)์ ๋ฐํํ๋ค.
5.3. Body ๋ฏน์ค์ธ
interface mixin {Body readonly attribute ReadableStream ?body ;readonly attribute boolean bodyUsed ; [NewObject ]Promise <ArrayBuffer >arrayBuffer (); [NewObject ]Promise <Blob >blob (); [NewObject ]Promise <Uint8Array >bytes (); [NewObject ]Promise <FormData >formData (); [NewObject ]Promise <any >json (); [NewObject ]Promise <USVString >text (); [NewObject ]ReadableStream textStream (); };
๋คํธ์ํฌ ๊ณ์ธต์ ์์กดํ๋ฉด ์ ๋๋ ํฌ๋งท(์: HTML)์ ์ฌ๊ธฐ์ ๋ ธ์ถํ์ง ์์ต๋๋ค. ๋์ HTML ํ์ API๊ฐ ์คํธ๋ฆผ์ ๋ฐ๋๋ก ์ค๊ณ๋ ์ ์์ต๋๋ค.
Body ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ํฌํจํ ๊ฐ์ฒด๋
body (null ๋๋ body)๋ฅผ ๊ฐ์ง๋ค.
Body ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ํฌํจํ ๊ฐ์ฒด๋
์ฌ์ฉ ๋ถ๊ฐ๋ก
๊ฐ์ฃผ๋๋๋ฐ, body๊ฐ null์ด ์๋๊ณ ,
body์ stream์ด disturbed ๋๋
locked์ธ ๊ฒฝ์ฐ๋ฅผ ๋งํ๋ค.
requestOrResponse . body-
requestOrResponse์ body๋ฅผ
ReadableStream์ผ๋ก ๋ฐํํฉ๋๋ค. requestOrResponse . bodyUsed-
requestOrResponse์ body๊ฐ ์ฝํ๋์ง ์ฌ๋ถ๋ฅผ ๋ฐํํฉ๋๋ค.
requestOrResponse . arrayBuffer()-
requestOrResponse์ body๋ฅผ
ArrayBuffer๋ก ํฌํจํ์ฌ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค. requestOrResponse . blob()-
requestOrResponse์ body๋ฅผ
Blob์ผ๋ก ํฌํจํ์ฌ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค. requestOrResponse . bytes()-
requestOrResponse์ body๋ฅผ
Uint8Array๋ก ํฌํจํ์ฌ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค. requestOrResponse . formData()-
requestOrResponse์ body๋ฅผ
FormData๋ก ํฌํจํ์ฌ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค. requestOrResponse . json()-
requestOrResponse์ body๋ฅผ JSON์ผ๋ก ํ์ฑํ์ฌ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค.
requestOrResponse . text()-
requestOrResponse์ body๋ฅผ ๋ฌธ์์ด๋ก ํฌํจํ์ฌ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค.
requestOrResponse . textStream()-
ReadableStream๊ฐ์ฒด๋ฅผ requestOrResponse์ body๋ฅผ ๋ฌธ์์ด ์ฒญํฌ๋ก ๊ฐ์ง๋๋ก ๋ฐํํฉ๋๋ค.
MIME ํ์
์ป๊ธฐ๋ Request ๋๋
Response
๊ฐ์ฒด requestOrResponse๋ฅผ ๋ฐ์ ๋ค์์ ์ํํ๋ค:
-
headers๋ฅผ null๋ก ๋๋ค.
-
requestOrResponse๊ฐ
Request์ด๋ฉด, headers๋ฅผ requestOrResponse์ request์ ํค๋ ๋ฆฌ์คํธ๋ก ์ค์ ํ๋ค. -
๊ทธ ์ธ์๋ headers๋ฅผ requestOrResponse์ response์ ํค๋ ๋ฆฌ์คํธ๋ก ์ค์ ํ๋ค.
-
mimeType์ MIME ํ์ ์ถ์ถ์ headers๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋๋ค.
-
mimeType์ด ์คํจ์ด๋ฉด null์ ๋ฐํํ๋ค.
-
mimeType์ ๋ฐํํ๋ค.
body getter ๋จ๊ณ๋ this์ body๊ฐ null์ด๋ฉด null์ ๋ฐํํ๊ณ ,
์๋๋ฉด this์ body์ stream์
๋ฐํํ๋ค.
bodyUsed getter ๋จ๊ณ๋ this์ body๊ฐ null์ด ์๋๊ณ ,
this์ body์ stream์ด disturbed๋ฉด true๋ฅผ, ์๋๋ฉด false๋ฅผ ๋ฐํํ๋ค.
body ์๋น
์๊ณ ๋ฆฌ์ฆ์ Body
๋ฏน์ค์ธ์ ํฌํจํ ๊ฐ์ฒด object์,
๋ฐ์ดํธ ์ํ์ค๋ฅผ ๋ฐ์ JS ๊ฐ์ด๋ ์์ธ๋ฅผ ๋ฐํํ๋ ์๊ณ ๋ฆฌ์ฆ convertBytesToJSValue๋ฅผ
๋ฐ์ ๋ค์์ ์ํํ๋ค:
-
object๊ฐ ์ฌ์ฉ ๋ถ๊ฐ๋ฉด, TypeError๋ก reject๋ promise๋ฅผ ๋ฐํํ๋ค.
-
promise๋ฅผ ์ promise๋ก ๋๋ค.
- errorSteps๋ฅผ error๋ฅผ ๋ฐ์ promise๋ฅผ rejectํ๋ ๋จ๊ณ๋ก ๋๋ค.
- successSteps๋ฅผ ๋ฐ์ดํธ ์ํ์ค data๋ฅผ ๋ฐ์, promise๋ฅผ resolveํ๋ ๋จ๊ณ๋ก ๋๋ค. convertBytesToJSValue๋ฅผ data์ ์คํํด ์์ธ๊ฐ ๋ฐ์ํ๋ฉด errorSteps๋ฅผ ์คํํ๋ค.
-
object์ body๊ฐ null์ด๋ฉด, successSteps๋ฅผ ๋น ๋ฐ์ดํธ ์ํ์ค๋ก ์คํํ๋ค.
-
๊ทธ ์ธ์๋ ์์ ํ ์ฝ๊ธฐ๋ฅผ object์ body, successSteps, errorSteps, object์ ๊ด๋ จ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ก ์คํํ๋ค.
-
promise๋ฅผ ๋ฐํํ๋ค.
arrayBuffer() ๋ฉ์๋์ ๋จ๊ณ๋,
consume
body๋ฅผ
this์ ์๋ ๋จ๊ณ๋ฅผ
์ธ์๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์๋ ๋จ๊ณ๋ byte sequence bytes๊ฐ ์ฃผ์ด์ก์ ๋:
์์ฑ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
ArrayBuffer
์ bytes๋ก this์ relevant realm์์ ์์ฑํ๋ค.
์ ๋ฉ์๋๋ RangeError๋ก
reject๋ ์ ์๋ค.
blob() ๋ฉ์๋์ ๋จ๊ณ๋
consume body๋ฅผ
this์ ์๋ ๋จ๊ณ๋ฅผ
์ธ์๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์๋ ๋จ๊ณ๋ byte sequence bytes๊ฐ ์ฃผ์ด์ก์ ๋:
Blob
๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ฉฐ, ๋ด์ฉ์ bytes์ด๊ณ ,
type
attribute๋ get the MIME type์
this ๊ฒฐ๊ณผ์ด๋ค.
bytes() ๋ฉ์๋์ ๋จ๊ณ๋,
consume body๋ฅผ
this์ ์๋ ๋จ๊ณ๋ฅผ
์ธ์๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์๋ ๋จ๊ณ๋ byte sequence bytes๊ฐ ์ฃผ์ด์ก์ ๋:
์์ฑ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
Uint8Array
์ bytes๋ก this์ relevant realm์์ ์์ฑํ๋ค.
์ ๋ฉ์๋๋ RangeError๋ก
reject๋ ์ ์๋ค.
formData() ๋ฉ์๋์ ๋จ๊ณ๋,
consume body๋ฅผ
this์ ์๋ ๋จ๊ณ๋ฅผ
์ธ์๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์๋ ๋จ๊ณ๋ byte sequence bytes๊ฐ ์ฃผ์ด์ก์ ๋:
-
mimeType์ get the MIME type์ this ๊ฒฐ๊ณผ๋ก ํ๋ค.
-
mimeType์ด null์ด ์๋๋ฉด mimeType์ essence์ ๋ฐ๋ผ ๋ถ๊ธฐํ๋ค:
- "
multipart/form-data" -
-
bytes๋ฅผ ํ์ฑํ๋ค. mimeType์ `
boundary` ํ๋ผ๋ฏธํฐ ๊ฐ์ ์ฌ์ฉํ๊ณ , Returning Values from Forms: multipart/form-data์ ์ ์๋ ๊ท์น์ ๋ฐ๋ฅธ๋ค. [RFC7578]`Content-Disposition` ํค๋์ `filename` ํ๋ผ๋ฏธํฐ๊ฐ ์๋ ๊ฐ ํํธ๋, ๊ฐ์ด ํด๋น ํํธ์ ๋ด์ฉ์ ๋ด์ File ๊ฐ์ฒด์ธ ์ํธ๋ฆฌ ๋ก ํ์ฑํด์ผ ํฉ๋๋ค. File ๊ฐ์ฒด์ name ์์ฑ์ ํด๋น ํํธ์ `filename` ํ๋ผ๋ฏธํฐ ๊ฐ์ด์ด์ผ ํฉ๋๋ค. File ๊ฐ์ฒด์ type ์์ฑ์ ํด๋น ํํธ์ `Content-Type` ํค๋๊ฐ ์์ผ๋ฉด ๊ทธ ๊ฐ์ด๊ณ , ์์ผ๋ฉด `text/plain`์ด์ด์ผ ํฉ๋๋ค([RFC7578] 4.4์ ์ ์ ์๋ ๊ธฐ๋ณธ๊ฐ).
`
Content-Disposition` ํค๋์ `filename` ํ๋ผ๋ฏธํฐ๊ฐ ์๋ ๊ฐ ํํธ๋, ๊ฐ์ด entry์ธ BOM ์๋ UTF-8 ๋์ฝ๋ ๋ด์ฉ์ ๊ฐ์ง๋ค. ์ด ๊ณผ์ ์ `Content-Type` ํค๋ ๋ฐ `charset` ํ๋ผ๋ฏธํฐ์ ์กด์ฌ ์ฌ๋ถ์ ์๊ด์์ด ์ํ๋๋ค.`
Content-Disposition` ํค๋์ `name` ํ๋ผ๋ฏธํฐ ๊ฐ์ด `_charset_`์ธ ํํธ๋ ๋ค๋ฅธ ํํธ์ ๋์ผํ๊ฒ ํ์ฑ๋๋ค. ์ธ์ฝ๋ฉ์๋ ์ํฅ์ ์ฃผ์ง ์๋๋ค. -
ํ์ฑ์ ์คํจํ๋ฉด, TypeError๋ฅผ
TypeError๋ก throw ํ๋ค. -
ํ์ฑ ๊ฒฐ๊ณผ๋ก ์ป์ ๊ฐ entry๋ฅผ entry list์ appendํ๋, ์
FormData๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ค.
์๋ `
multipart/form-data` ์ฒ๋ฆฌ์ ํ์ํ ๋๋ต์ ์ค๋ช ์ด๋ฉฐ, ๋ ์์ธํ ํ์ฑ ๋ช ์ธ๋ ์์ฑ๋์ด์ผ ํ๋ค. ์์๋ด์ฌ ํ์. -
- "
application/x-www-form-urlencoded" -
-
entries๋ฅผ parsing bytes์ ๊ฒฐ๊ณผ๋ก ํ๋ค.
-
entry list๊ฐ entries์ธ, ์
FormData๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ค.
-
- "
json() ๋ฉ์๋์ ๋จ๊ณ๋,
consume body๋ฅผ
this์
๋ฐ์ดํธ๋ก๋ถํฐ JSON ํ์ฑ์ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
์ ๋ฉ์๋๋ SyntaxError๋ก
reject๋ ์ ์๋ค.
text() ๋ฉ์๋์ ๋จ๊ณ๋,
consume body๋ฅผ
this์
UTF-8 ๋์ฝ๋๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
textStream() ๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
this๊ฐ ์ฌ์ฉ ๋ถ๊ฐ๋ฅ์ด๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
this์ body๊ฐ null์ด๋ฉด:
-
emptyStream์ this์ ๊ด๋ จ ์์ญ์ ์๋ ์
ReadableStream์ผ๋ก ๋ก๋๋ค. -
emptyStream์ ์ค์ ํฉ๋๋ค.
-
emptyStream์ ๋ซ์ต๋๋ค.
-
emptyStream์ ๋ฐํํฉ๋๋ค.
-
-
decoder๋ฅผ this์ ๊ด๋ จ ์์ญ์ ์๋ ์
TextDecoderStream๊ฐ์ฒด๋ก ๋ก๋๋ค. -
decoder๋ฅผ UTF-8๋ก ์ค์ ํฉ๋๋ค.
์ด๋ `
Content-Type` ํค๋์ ์กด์ฌ ์ฌ๋ถ๋ ๊ฐ์ ๊ด๊ณ์์ด, ๊ทธ๋ฆฌ๊ณ `charset` ๋งค๊ฐ๋ณ์์ ์กด์ฌ ์ฌ๋ถ๋ ๊ฐ์ ๊ด๊ณ์์ด ์ํ๋ฉ๋๋ค. -
stream์ decoder๋ฅผ ํตํด ํ์ดํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
5.4. Request ํด๋์ค
typedef (Request or USVString ); [RequestInfo Exposed =(Window ,Worker )]interface {Request constructor (RequestInfo ,input optional RequestInit = {});init readonly attribute ByteString method ;readonly attribute USVString url ; [SameObject ]readonly attribute Headers headers ;readonly attribute RequestDestination destination ;readonly attribute USVString referrer ;readonly attribute ReferrerPolicy referrerPolicy ;readonly attribute RequestMode mode ;readonly attribute RequestCredentials credentials ;readonly attribute RequestCache cache ;readonly attribute RequestRedirect redirect ;readonly attribute DOMString integrity ;readonly attribute boolean keepalive ;readonly attribute boolean isReloadNavigation ;readonly attribute boolean isHistoryNavigation ;readonly attribute AbortSignal signal ;readonly attribute RequestDuplex duplex ; [NewObject ]Request clone (); };Request includes Body ;dictionary {RequestInit ByteString ;method HeadersInit ;headers BodyInit ?;body USVString ;referrer ReferrerPolicy ;referrerPolicy RequestMode ;mode RequestCredentials ;credentials RequestCache ;cache RequestRedirect ;redirect DOMString ;integrity boolean ;keepalive AbortSignal ?;signal RequestDuplex ;duplex RequestPriority ;priority any ; // can only be set to null };window enum {RequestDestination ,"" ,"audio" ,"audioworklet" ,"document" ,"embed" ,"font" ,"frame" ,"iframe" ,"image" ,"json" ,"manifest" ,"object" ,"paintworklet" ,"report" ,"script" ,"sharedworker" ,"style" ,"text" ,"track" ,"video" ,"worker" };"xslt" enum {RequestMode ,"navigate" ,"same-origin" ,"no-cors" };"cors" enum {RequestCredentials ,"omit" ,"same-origin" };"include" enum {RequestCache ,"default" ,"no-store" ,"reload" ,"no-cache" ,"force-cache" };"only-if-cached" enum {RequestRedirect ,"follow" ,"error" };"manual" enum {RequestDuplex };"half" enum {RequestPriority ,"high" ,"low" };"auto"
"serviceworker"๋
JavaScript์์ ๊ด์ฐฐํ ์ ์์ผ๋ฏ๋ก RequestDestination์์ ์๋ต๋ฉ๋๋ค. ํ์ง๋ง ๊ตฌํ์์๋ ์ฌ์ ํ destination์ผ๋ก ์ง์ํด์ผ ํฉ๋๋ค. "websocket"๊ณผ
"webtransport"๋ JavaScript์์ ์ฌ์ฉํ ์ ์๊ฑฐ๋ ๊ด์ฐฐํ ์ ์์ผ๋ฏ๋ก RequestMode์์ ์๋ต๋ฉ๋๋ค.
Request ๊ฐ์ฒด๋
request(request ๊ฐ์ฒด)์ ๊ฐ์ง๋ค.
Request ๊ฐ์ฒด๋ ๋ํ
headers(null ๋๋ Headers ๊ฐ์ฒด, ์ด๊ธฐ๊ฐ์
null)์ ๊ฐ์ง๋ค.
Request ๊ฐ์ฒด๋ signal(null ๋๋ AbortSignal
๊ฐ์ฒด, ์ด๊ธฐ๊ฐ์ null)์ ๊ฐ์ง๋ค.
Request ๊ฐ์ฒด์
body๋
request์
body์ด๋ค.
request = new Request(input [, init])-
์ request๋ฅผ ๋ฐํํ๋ฉฐ, input์ด ๋ฌธ์์ด์ผ ๊ฒฝ์ฐ
url์์ฑ์ input์ด ๋๋ค. input์ดRequest๊ฐ์ฒด์ผ ๊ฒฝ์ฐ,url์์ฑ์ input์ ๊ฐ์ด ๋๋ค.init ์ธ์๋ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ์ ์ค์ ํ ์ ์๋ ๊ฐ์ฒด์ด๋ค:
method- request์
method๋ฅผ ์ค์ ํ๋ ๋ฌธ์์ด. headersHeaders๊ฐ์ฒด, ๊ฐ์ฒด ๋ฆฌํฐ๋ด, ๋๋ 2-์์ ๋ฐฐ์ด์ ๋ฐฐ์ด๋ก, request์headers๋ฅผ ์ค์ .bodyBodyInit๊ฐ์ฒด ๋๋ null. request์ body๋ฅผ ์ค์ .referrer- ๋์ผ ์ถ์ฒ URL, "
about:client", ๋๋ ๋น ๋ฌธ์์ด์ด์ด์ผ ํ๋ฉฐ, request์ referrer๋ฅผ ์ค์ . referrerPolicy- referrer policy์ด๋ฉฐ,
request์
referrerPolicy๋ฅผ ์ค์ . mode- ํด๋น ์์ฒญ์ด CORS๋ฅผ ์ฌ์ฉํ ์ง, ๋์ผ ์ถ์ฒ๋ก ์ ํํ ์ง๋ฅผ ์ง์ ํ๋ ๋ฌธ์์ด.
request์
mode๋ฅผ ์ค์ . input์ด ๋ฌธ์์ด์ด๋ฉด, ๊ธฐ๋ณธ๊ฐ์ "cors"์. credentials- ์๊ฒฉ ์ฆ๋ช
์ ํญ์, ์ ๋, ๋๋ ๋์ผ ์ถ์ฒ๋ก๋ง ๋ณด๋ผ์ง ์ฌ๋ถ์,
์๋ต์์ ๋ฐ์ ์๊ฒฉ ์ฆ๋ช
์ ์ฌ์ฉํ ์ง๋ฅผ ๊ฒฐ์ ํ๋ ๋ฌธ์์ด.
request์
credentials๋ฅผ ์ค์ . input์ด ๋ฌธ์์ด์ด๋ฉด, ๊ธฐ๋ณธ๊ฐ์ "same-origin"์. cache- ํด๋น ์์ฒญ์ด ๋ธ๋ผ์ฐ์ ์ ์บ์์ ์ํธ์์ฉํ๋ ๋ฐฉ์์ ์ง์ ํ๋ ๋ฌธ์์ด๋ก,
request์
cache๋ฅผ ์ค์ . redirect- request๊ฐ ๋ฆฌ๋๋ ์
์ ๋ฐ๋ฅผ์ง, ์๋ฌ๋ก ์ฒ๋ฆฌํ ์ง, ๋๋ ๋ฆฌ๋๋ ์
(opaque ๋ฐฉ์)์ผ๋ก ๋ฐํํ ์ง๋ฅผ
๊ฒฐ์ ํ๋ ๋ฌธ์์ด. request์
redirect๋ฅผ ์ค์ . integrity- request๋ก ๊ฐ์ ธ์ฌ ๋ฆฌ์์ค์ ์ํธํ ํด์๊ฐ.
request์
integrity๋ฅผ ์ค์ . keepalive- ๋ถ๋ฆฌ์ธ ๊ฐ์ผ๋ก,
request์
keepalive๋ฅผ ์ค์ . signalAbortSignal๋ฅผ ๋ฐ์ request์signal๋ฅผ ์ค์ .window- null๋ง ํ์ฉ๋๋ฉฐ, request๋ฅผ ์ด๋ค
Window์๋ ์ฐ๊ด์ํค์ง ์๊ธฐ ์ํด ์ฌ์ฉ๋จ. duplex- "
half"๋ง ์ ํจํ๋ฉฐ, ์์ฒญ ์ ์ฒด๋ฅผ ๋ณด๋ธ ๋ค ์๋ต์ ์ฒ๋ฆฌํ๋ half-duplex fetch ๋ฅผ ์์ํ ๋ ์ฌ์ฉ. "full"์ ๋ฏธ๋์ full-duplex fetch(์์ฒญ ์ ์ฒด๋ฅผ ๋ณด๋ด๊ธฐ ์ ์๋ ์๋ต์ ์ฒ๋ฆฌ ๊ฐ๋ฅ)๋ฅผ ์ํด ์์ฝ๋จ.body๊ฐReadableStream๊ฐ์ฒด์ธ ๊ฒฝ์ฐ ์ด ์์ฑ์ ๋ฐ๋์ ์ง์ ํด์ผ ํ๋ค. "full" ๊ด๋ จ ๋ ผ์๋ issue #1254 ์ฐธ๊ณ . priority- ๋ฌธ์์ด๋ก, request์ priority๋ฅผ ์ค์ .
request . method- request์ HTTP method๋ฅผ ๋ฐํํ๋ฉฐ, ๊ธฐ๋ณธ๊ฐ์ "
GET"์. request . url- request์ URL์ ๋ฌธ์์ด๋ก ๋ฐํ.
request . headers- request์ ์ฐ๊ฒฐ๋ ํค๋๋ฅผ ๋ด์
Headers๊ฐ์ฒด๋ฅผ ๋ฐํ. ๋คํธ์ํฌ ๊ณ์ธต์์ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ถ๊ฐํ๋ ํค๋(์: "Host")๋ ์ฌ๊ธฐ์๋ ๋ฐ์๋์ง ์๋๋ค. request . destination- request๊ฐ ์์ฒญํ๋ ๋ฆฌ์์ค์ ์ข
๋ฅ(์: "
document" ๋๋ "script")๋ฅผ ๋ฐํ. request . referrer- request์ referrer๋ฅผ ๋ฐํ.
init์์ ๋ช
์์ ์ผ๋ก ์ค์ ํ๋ฉด ๋์ผ ์ถ์ฒ URL ๋๋ ๋น ๋ฌธ์์ด,
๊ทธ๋ ์ง ์์ผ๋ฉด "
about:client"์ด ๋๋ค. fetch ์ค์๋ ์ค์ ์์ฒญ์ `Referer` ํค๋ ๊ฐ์ ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉ๋จ. request . referrerPolicy- request์ ์ฐ๊ฒฐ๋ referrer policy๋ฅผ ๋ฐํ. fetch ์ค request์ referrer ๊ฐ์ ๊ณ์ฐํ๋ ๋ฐ ์ฐ์.
request . mode- request์ ์ฐ๊ฒฐ๋ mode๋ฅผ ๋ฐํ. CORS๋ฅผ ์ฌ์ฉํ ์ง, ๋์ผ ์ถ์ฒ๋ก ์ ํํ ์ง์ ๋ํ ๋ฌธ์์ด์.
request . credentials- request์ ์ฐ๊ฒฐ๋ credentials mode๋ฅผ ๋ฐํ. ์๊ฒฉ ์ฆ๋ช ์ ํญ์, ์ ๋ ํน์ ๋์ผ ์ถ์ฒ์๋ง ๋ณด๋ผ์ง ๋ํ๋ด๋ ๋ฌธ์์ด์.
request . cache- request์ ์ฐ๊ฒฐ๋ cache mode๋ฅผ ๋ฐํ. fetch ์ ๋ธ๋ผ์ฐ์ ์ ์บ์์ ์ด๋ป๊ฒ ์ํธ์์ฉํ ์ง์ ๋ํ ๋ฌธ์์ด์.
request . redirect- request์ ์ฐ๊ด๋ redirect mode๋ฅผ ๋ฐํํ๋ฉฐ, ์ด ๊ฐ์ ์์ฒญ์ ๋ฆฌ๋๋ ์ ์ด fetch ๋์ค ์ด๋ป๊ฒ ์ฒ๋ฆฌ๋ ์ง ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋๋ค. request๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ฆฌ๋๋ ์ ์ ๋ฐ๋ฆ ๋๋ค.
request . integrity- request๋ก ๊ฐ์ ธ์ค๋ ๋ฆฌ์์ค์ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฆ์ฉ ์ํธ ํด์(metadata) ๋ฐํ. ๊ฐ์ ์ฌ๋ฌ ํด์๊ฐ ๊ณต๋ฐฑ ๋ฌธ์๋ก ๊ตฌ๋ถ๋ ๋ฌธ์์ด. [SRI]
request . keepalive- request๊ฐ ์์ฑ๋ ์ ์ญ(global) ํ๊ฒฝ์ด ์ข ๋ฃ๋์ด๋ ํด๋น ์์ฒญ์ด ์ด์๋จ์ ์ ์๋์ง์ ๋ํ true/false ์ฌ๋ถ ๋ฐํ.
request . isReloadNavigation- request๊ฐ ์๋ก๊ณ ์นจ ๋ค๋น๊ฒ์ด์ ์ฉ์ธ์ง true/false๋ก ๋ฐํ.
request . isHistoryNavigation- request๊ฐ ํ์คํ ๋ฆฌ ๋ค๋น๊ฒ์ด์ (์ฆ, ๋ค๋ก/์์ผ๋ก)์ด์๋์ง true/false๋ก ๋ฐํ.
request . signal- request์ ์ฐ๊ฒฐ๋
AbortSignal๊ฐ์ฒด๋ฅผ ๋ฐํ. ํด๋น ๊ฐ์ฒด๋ request๊ฐ abort(์ทจ์)๋์๋์ง ๋ฐ abort ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ฅผ ๋ํ๋. request . duplex- "
half"๋ฅผ ๋ฐํ. ์ฆ, ์์ฒญ ์ ์ฒด๋ฅผ ๋ณด๋ธ ๋ค์์ ์๋ต์ ์ฒ๋ฆฌํ๋ half-duplex fetch์์ ์๋ฏธ. ๋ฏธ๋์๋ "full"๋ ๋ฐํ๋ ์ ์์. ์ฆ, ์์ฒญ์ด ๋๋๊ธฐ ์ ์ ์๋ต์ ์ฒ๋ฆฌํ๋ full-duplex fetch๋ฅผ ๊ตฌ๋ถํ ์๋ ์์. "full" ๊ด๋ จ ๋ด์ฉ์ issue #1254 ์ฐธ๊ณ . request . clone()-
request์ ๋ณต์ ๋ณธ์ ๋ฐํ.
์์ฑ์ ์คํํ๋ ค๋ฉด, Request
๊ฐ์ฒด๋ฅผ ๋ง๋ค ๋,
request
request,
headers guard
guard,
AbortSignal
๊ฐ์ฒด signal, ๊ทธ๋ฆฌ๊ณ realm realm์ ๋ฐ์ ๋ค์์ ์ํํ๋ค:
-
requestObject๋ฅผ ์๋ก์ด
Request๊ฐ์ฒด๋ก realm๊ณผ ํจ๊ป ์์ฑํ๋ค. -
requestObject์ request๋ฅผ request๋ก ์ค์ ํ๋ค.
-
requestObject์ headers๋ฅผ ์๋ก์ด
Headers๊ฐ์ฒด๋ก realm๊ณผ ํจ๊ป ์์ฑํ๋ฉฐ, ํค๋ ๋ฆฌ์คํธ๋ request์ ํค๋ ๋ฆฌ์คํธ๋ก, guard๋ guard๋ก ์ค์ ํ๋ค. -
requestObject์ signal์ signal๋ก ์ค์ ํ๋ค.
-
requestObject๋ฅผ ๋ฐํํ๋ค.
new Request(input, init)
์์ฑ์ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
request๋ฅผ null๋ก ๋ก๋๋ค.
-
fallbackMode๋ฅผ null๋ก ๋ก๋๋ค.
-
baseURL์ this์ ๊ด๋ จ ์ค์ ๊ฐ์ฒด์ API ๊ธฐ๋ณธ URL๋ก ๋ก๋๋ค.
-
signal์ null๋ก ๋ก๋๋ค.
-
input์ด ๋ฌธ์์ด์ด๋ฉด:
-
๊ทธ๋ ์ง ์์ผ๋ฉด:
-
origin์ this์ ๊ด๋ จ ์ค์ ๊ฐ์ฒด์ origin์ผ๋ก ๋ก๋๋ค.
-
traversableForUserPrompts๋ฅผ "
client"๋ก ๋ก๋๋ค. -
request์ ์ฌ์ฉ์ ํ๋กฌํํธ์ฉ traversable์ด ํ๊ฒฝ ์ค์ ๊ฐ์ฒด์ด๊ณ ๊ทธ origin์ด origin๊ณผ ๋์ผ ์ถ์ฒ์ด๋ฉด, traversableForUserPrompts๋ฅผ request์ ์ฌ์ฉ์ ํ๋กฌํํธ์ฉ traversable๋ก ์ค์ ํฉ๋๋ค.
-
init["
window"]๊ฐ ์กด์ฌํ๊ณ null์ด ์๋๋ฉด,TypeError๋ฅผ throwํฉ๋๋ค. -
init["
window"]๊ฐ ์กด์ฌํ๋ฉด, traversableForUserPrompts๋ฅผ "no-traversable"๋ก ์ค์ ํฉ๋๋ค. -
request๋ฅผ ๋ค์ ์์ฑ์ ๊ฐ๋ ์ ์์ฒญ์ผ๋ก ์ค์ ํฉ๋๋ค:
- URL
- request์ URL.
- method
- request์ method.
- header list
- request์ header list์ ๋ณต์ฌ๋ณธ.
- unsafe-request flag
- ์ค์ ๋จ.
- client
- This์ ๊ด๋ จ ์ค์ ๊ฐ์ฒด.
- traversable for user prompts
- traversableForUserPrompts.
- internal priority
- request์ internal priority.
- origin
- request์ origin. ์ด origin์ ์ ํ๋ ์๋น์ค ์์ปค๊ฐ ์ฒ๋ฆฌํ๋ ํ์ ์์ฒญ์์๋ง ์ค์ํฉ๋๋ค. ์ด ์๋๋ฆฌ์ค์์ ์์ฒญ์ ํ์ฌ ํด๋ผ์ด์ธํธ์ ๋ค๋ฅธ origin์ ๊ฐ์ง ์ ์์ต๋๋ค.
- referrer
- request์ referrer.
- referrer policy
- request์ referrer policy.
- mode
- request์ mode.
- credentials mode
- request์ credentials mode.
- cache mode
- request์ cache mode.
- redirect mode
- request์ redirect mode.
- integrity metadata
- request์ integrity metadata.
- keepalive
- request์ keepalive.
- reload-navigation flag
- request์ reload-navigation flag.
- history-navigation flag
- request์ history-navigation flag.
- URL list
- request์ URL list์ ํด๋ก .
- initiator type
- "
fetch".
-
init์ด ๋น์ด ์์ง ์์ผ๋ฉด:
-
request์ mode๊ฐ "
navigate"์ด๋ฉด, ์ด๋ฅผ "same-origin"์ผ๋ก ์ค์ ํฉ๋๋ค. -
request์ reload-navigation flag๋ฅผ ํด์ ํฉ๋๋ค.
-
request์ history-navigation flag๋ฅผ ํด์ ํฉ๋๋ค.
-
request์ origin์ "
client"๋ก ์ค์ ํฉ๋๋ค. -
request์ referrer๋ฅผ "
client"๋ก ์ค์ ํฉ๋๋ค. -
request์ referrer policy๋ฅผ ๋น ๋ฌธ์์ด๋ก ์ค์ ํฉ๋๋ค.
-
request์ URL์ request์ current URL๋ก ์ค์ ํฉ๋๋ค.
-
request์ URL list๋ฅผ ยซ request์ URL ยป๋ก ์ค์ ํฉ๋๋ค.
์ด๋ ์๋น์ค ์์ปค๊ฐ ์์ฒญ์ "๋ฆฌ๋๋ ์ "ํ๊ณ , ์๋ฅผ ๋ค์ด ๊ต์ฐจ ์ถ์ฒ ์คํ์ผ ์ํธ ์์ ์ด๋ฏธ์ง์์ ์จ ์์ฒญ์ ์์ ํ๋ ๊ฒฝ์ฐ, ๊ทธ ์์ฒญ์ด ๋ ์ด์ ์๋ ์์ค(์ฆ, ๊ต์ฐจ ์ถ์ฒ ์คํ์ผ ์ํธ)์์ ์จ ๊ฒ์ผ๋ก ๋ณด์ด์ง ์๊ณ ๋์ ๊ทธ ์์ฒญ์ "๋ฆฌ๋๋ ์ "ํ ์๋น์ค ์์ปค์์ ์จ ๊ฒ์ผ๋ก ๋ณด์ด๊ฒ ํ๊ธฐ ์ํด ์ํ๋ฉ๋๋ค. ์๋ ์์ค๊ฐ ์๋น์ค ์์ปค์ ๋์ผํ ์ข ๋ฅ์ ์์ฒญ์กฐ์ฐจ ์์ฑํ์ง ๋ชปํ ์ ์์ผ๋ฏ๋ก ์ด๋ ์ค์ํฉ๋๋ค. ์๋ ์์ค๋ฅผ ์ ๋ขฐํ๋ ์๋น์ค๋ ์ด ์ฒ๋ฆฌ๊ฐ ์๋ค๋ฉด ์ ์ฉ๋ ์ ์์ง๋ง, ์ด๋ ๋ค์ ๊ฐ๋ฅ์ฑ์ด ๋ฎ์ต๋๋ค.
-
-
init["
referrer"]๊ฐ ์กด์ฌํ๋ฉด:-
referrer๋ฅผ init["
referrer"]๋ก ๋ก๋๋ค. -
referrer๊ฐ ๋น ๋ฌธ์์ด์ด๋ฉด, request์ referrer๋ฅผ "
no-referrer"๋ก ์ค์ ํฉ๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด:
-
parsedReferrer๋ฅผ referrer๋ฅผ baseURL๊ณผ ํจ๊ป ํ์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
parsedReferrer๊ฐ ์คํจ์ด๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
๋ค์ ์ค ํ๋๊ฐ ์ฐธ์ด๋ฉด
-
parsedReferrer์ scheme์ด "
about"์ด๊ณ path๊ฐ ๋ฌธ์์ด "client"์ธ ๊ฒฝ์ฐ -
parsedReferrer์ origin์ด origin๊ณผ ๋์ผ ์ถ์ฒ๊ฐ ์๋ ๊ฒฝ์ฐ
๊ทธ๋ฌ๋ฉด request์ referrer๋ฅผ "
client"๋ก ์ค์ ํฉ๋๋ค. -
-
๊ทธ๋ ์ง ์์ผ๋ฉด, request์ referrer๋ฅผ parsedReferrer๋ก ์ค์ ํฉ๋๋ค.
-
-
-
init["
referrerPolicy"]๊ฐ ์กด์ฌํ๋ฉด, request์ referrer policy๋ฅผ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
mode๋ฅผ init["
mode"]๊ฐ ์กด์ฌํ๋ฉด ๊ทธ๊ฒ์ผ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด fallbackMode๋ก ๋ก๋๋ค. -
mode๊ฐ null์ด ์๋๋ฉด, request์ mode๋ฅผ mode๋ก ์ค์ ํฉ๋๋ค.
-
init["
credentials"]๊ฐ ์กด์ฌํ๋ฉด, request์ credentials mode๋ฅผ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
init["
cache"]๊ฐ ์กด์ฌํ๋ฉด, request์ cache mode๋ฅผ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
request์ cache mode๊ฐ "
only-if-cached"์ด๊ณ request์ mode๊ฐ "same-origin"์ด ์๋๋ฉด,TypeError๋ฅผ throwํฉ๋๋ค. -
init["
redirect"]๊ฐ ์กด์ฌํ๋ฉด, request์ redirect mode๋ฅผ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
init["
integrity"]๊ฐ ์กด์ฌํ๋ฉด, request์ integrity metadata๋ฅผ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
init["
keepalive"]๊ฐ ์กด์ฌํ๋ฉด, request์ keepalive๋ฅผ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
init["
signal"]๊ฐ ์กด์ฌํ๋ฉด, signal์ ๊ทธ๊ฒ์ผ๋ก ์ค์ ํฉ๋๋ค. -
init["
priority"]๊ฐ ์กด์ฌํ๋ฉด:-
request์ internal priority๊ฐ null์ด ์๋๋ฉด, request์ internal priority๋ฅผ ๊ตฌํ ์ ์ ๋ฐฉ์์ผ๋ก ๊ฐฑ์ ํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, request์ priority๋ฅผ init["
priority"]๋ก ์ค์ ํฉ๋๋ค.
-
-
signals๋ฅผ signal์ด null์ด ์๋๋ฉด ยซ signal ยป๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด ยซ ยป๋ก ๋ก๋๋ค.
-
this์ signal์ signals์์
AbortSignal๊ณผ this์ ๊ด๋ จ ์์ญ์ ์ฌ์ฉํด ์ข ์ abort signal์ ์์ฑํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. -
this์ headers๋ฅผ this์ ๊ด๋ จ ์์ญ์ ๊ฐ๋ ์
Headers๊ฐ์ฒด๋ก ์ค์ ํ๋ฉฐ, ๊ทธ header list๋ request์ header list์ด๊ณ guard๋ "request"์ ๋๋ค. -
init์ด ๋น์ด ์์ง ์์ผ๋ฉด:
์ด mode์์ ํ์ฉ๋์ง ์๋ ํค๋๊ฐ ํฌํจ๋์ด ์์ ์ ์์ผ๋ฏ๋ก headers๊ฐ ์ ๋ฆฌ๋ฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ์ด์ ์ ์ ๋ฆฌ๋์๊ฑฐ๋ ๊ถํ ์๋ API์ ์ํด ์ค์ ๋ ์ดํ ์์ ๋์ง ์์ ์ํ์ ๋๋ค.
-
headers๋ฅผ this์ headers์ ๊ทธ ์ฐ๊ฒฐ๋ header list์ ๋ณต์ฌ๋ณธ์ผ๋ก ๋ก๋๋ค.
-
init["
headers"]๊ฐ ์กด์ฌํ๋ฉด, headers๋ฅผ init["headers"]๋ก ์ค์ ํฉ๋๋ค. -
this์ headers์ header list๋ฅผ ๋น์๋๋ค.
-
headers๊ฐ
Headers๊ฐ์ฒด์ด๋ฉด, ๊ทธ header list์ ๊ฐ header์ ๋ํด for each๋ฅผ ์ํํ์ฌ, header๋ฅผ this์ headers์ ๋ง๋ถ์ธ๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, this์ headers๋ฅผ headers๋ก ์ฑ์๋๋ค.
-
-
inputBody๋ฅผ input์ด
Request๊ฐ์ฒด์ด๋ฉด input์ request์ body๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด null๋ก ๋ก๋๋ค. -
init["
body"]๊ฐ ์กด์ฌํ๊ณ null์ด ์๋๊ฑฐ๋ inputBody๊ฐ null์ด ์๋๋ฉฐ, request์ method๊ฐ `GET` ๋๋ `HEAD`์ด๋ฉด,TypeError๋ฅผ throwํฉ๋๋ค. -
initBody๋ฅผ null๋ก ๋ก๋๋ค.
-
init["
body"]๊ฐ ์กด์ฌํ๊ณ null์ด ์๋๋ฉด:-
bodyWithType์ request์ keepalive๋ก ์ค์ ๋ keepalive์ ํจ๊ป init["
body"]๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. -
initBody๋ฅผ bodyWithType์ body๋ก ์ค์ ํฉ๋๋ค.
-
type์ bodyWithType์ type์ผ๋ก ๋ก๋๋ค.
-
type์ด null์ด ์๋๊ณ this์ headers์ header list๊ฐ `
Content-Type`์ ํฌํจํ์ง ์์ผ๋ฉด, (`Content-Type`, type)์ this์ headers์ appendํฉ๋๋ค.
-
-
inputOrInitBody๋ฅผ initBody๊ฐ null์ด ์๋๋ฉด ๊ทธ๊ฒ์ผ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด inputBody๋ก ๋ก๋๋ค.
-
inputOrInitBody๊ฐ null์ด ์๋๊ณ inputOrInitBody์ source๊ฐ null์ด๋ฉด:
-
finalBody๋ฅผ inputOrInitBody๋ก ๋ก๋๋ค.
-
initBody๊ฐ null์ด๊ณ inputBody๊ฐ null์ด ์๋๋ฉด:
-
inputBody๊ฐ ์ฌ์ฉ ๋ถ๊ฐ๋ฅํ๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
finalBody๋ฅผ inputBody์ ๋ํ ํ๋ก์ ์์ฑ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
The method getter ๋จ๊ณ๋ this์
request์
method๋ฅผ
๋ฐํํ๋ ๊ฒ์
๋๋ค.
The url getter ๋จ๊ณ๋ this์
request์
URL์ ์ง๋ ฌํํ์ฌ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The headers getter ๋จ๊ณ๋
this์ headers๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The destination getter ๋จ๊ณ๋ this์
request์
destination์ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The referrer getter ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
The referrerPolicy getter ๋จ๊ณ๋
this์ request์
referrer
policy๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The mode getter ๋จ๊ณ๋ this์
request์
mode๋ฅผ ๋ฐํํ๋
๊ฒ์
๋๋ค.
The credentials getter ๋จ๊ณ๋
this์ request์
credentials
mode๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The cache getter ๋จ๊ณ๋ this์
request์
cache
mode๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The redirect getter ๋จ๊ณ๋
this์ request์
redirect mode๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The integrity getter ๋จ๊ณ๋
this์ request์
integrity
metadata๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The keepalive getter ๋จ๊ณ๋
this์ request์
keepalive๋ฅผ
๋ฐํํ๋ ๊ฒ์
๋๋ค.
The isReloadNavigation getter ๋จ๊ณ๋ this์
request์
reload-navigation flag๊ฐ ์ค์ ๋์ด ์์ผ๋ฉด
true๋ฅผ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The isHistoryNavigation getter ๋จ๊ณ๋
true if this์
request์
history-navigation flag๊ฐ
์ค์ ๋์ด ์์ผ๋ฉด true๋ฅผ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The signal getter ๋จ๊ณ๋ this์
signal์ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
This์ signal์ ํญ์ constructor์์, ๊ทธ๋ฆฌ๊ณ cloningํ ๋ ์ด๊ธฐํ๋ฉ๋๋ค.
The duplex getter ๋จ๊ณ๋
"half"๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
The clone() ๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
this๊ฐ ์ฌ์ฉ ๋ถ๊ฐ๋ฅํ๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
clonedRequest๋ฅผ this์ request๋ฅผ ๋ณต์ ํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
clonedSignal์ ยซ this์ signal ยป์์
AbortSignal๊ณผ this์ ๊ด๋ จ ์์ญ์ ์ฌ์ฉํด ์ข ์ abort signal์ ์์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. -
clonedRequestObject๋ฅผ clonedRequest, this์ headers์ guard, clonedSignal ๋ฐ this์ ๊ด๋ จ ์์ญ์ด ์ฃผ์ด์ง ์ํ์์
Request๊ฐ์ฒด๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. -
clonedRequestObject๋ฅผ ๋ฐํํฉ๋๋ค.
5.5. Response ํด๋์ค
[Exposed =(Window ,Worker )]interface {Response constructor (optional BodyInit ?=body null ,optional ResponseInit = {}); [init NewObject ]static Response error (); [NewObject ]static Response redirect (USVString ,url optional unsigned short = 302); [status NewObject ]static Response json (any ,data optional ResponseInit = {});init readonly attribute ResponseType type ;readonly attribute USVString url ;readonly attribute boolean redirected ;readonly attribute unsigned short status ;readonly attribute boolean ok ;readonly attribute ByteString statusText ; [SameObject ]readonly attribute Headers headers ; [NewObject ]Response clone (); };Response includes Body ;dictionary {ResponseInit unsigned short = 200;status ByteString = "";statusText HeadersInit ; };headers enum {ResponseType ,"basic" ,"cors" ,"default" ,"error" ,"opaque" };"opaqueredirect"
Response
๊ฐ์ฒด์๋ ์ฐ๊ด๋
response๊ฐ ์์ต๋๋ค(ํ๋์
response).
Response
๊ฐ์ฒด์๋ ๋ํ ์ฐ๊ด๋ headers๊ฐ ์์ต๋๋ค(null ๋๋
Headers ๊ฐ์ฒด),
์ด๊ธฐ๊ฐ์ null์
๋๋ค.
Response
๊ฐ์ฒด์ body๋ ๊ทธ
response์ body์
๋๋ค.
response = new Response(body = null [, init])-
body๋ฅผ body๋ก ๊ฐ์ง๋ฉฐ, status, status message ๋ฐ headers๊ฐ init์ ์ํด ์ ๊ณต๋๋
Response๋ฅผ ์์ฑํฉ๋๋ค. response = Response . error()-
๋คํธ์ํฌ ์ค๋ฅ
Response๋ฅผ ์์ฑํฉ๋๋ค. response = Response . redirect(url, status = 302)-
status ์ํ๋ก url๋ก ๋ฆฌ๋๋ ์ ํ๋ ๋ฆฌ๋๋ ์
Response๋ฅผ ์์ฑํฉ๋๋ค. response = Response . json(data [, init])-
body๊ฐ JSON์ผ๋ก ์ธ์ฝ๋ฉ๋ data์ด๊ณ , status, status message ๋ฐ headers๊ฐ init์ ์ํด ์ ๊ณต๋๋
Response๋ฅผ ์์ฑํฉ๋๋ค. response . type-
response์ type์ ๋ฐํํฉ๋๋ค. ์: "
cors". response . url-
response์ URL์ด ์์ผ๋ฉด ๊ทธ URL์ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด ๋น ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค.
response . redirected-
response๊ฐ ๋ฆฌ๋๋ ์ ์ ํตํด ์ป์ด์ก๋์ง ์ฌ๋ถ๋ฅผ ๋ฐํํฉ๋๋ค.
response . status-
response์ status๋ฅผ ๋ฐํํฉ๋๋ค.
response . ok-
response์ status๊ฐ ok status์ธ์ง ์ฌ๋ถ๋ฅผ ๋ฐํํฉ๋๋ค.
response . statusText-
response์ status message๋ฅผ ๋ฐํํฉ๋๋ค.
response . headers-
response์ headers๋ฅผ
Headers๋ก ๋ฐํํฉ๋๋ค. response . clone()-
response์ ๋ณต์ ๋ณธ์ ๋ฐํํฉ๋๋ค.
response
response, headers
guard guard, ๊ทธ๋ฆฌ๊ณ
realm
realm์ด ์ฃผ์ด์ก์ ๋, Response
๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์คํํฉ๋๋ค:
-
responseObject๋ฅผ realm์ ๊ฐ๋ ์
Response๊ฐ์ฒด๋ก ๋ก๋๋ค. -
responseObject์ response๋ฅผ response๋ก ์ค์ ํฉ๋๋ค.
-
responseObject์ headers๋ฅผ realm์ ๊ฐ๋ ์
Headers๊ฐ์ฒด๋ก ์ค์ ํ๋ฉฐ, ๊ทธ headers list๋ response์ headers list์ด๊ณ guard๋ guard์ ๋๋ค. -
responseObject๋ฅผ ๋ฐํํฉ๋๋ค.
Response
๊ฐ์ฒด response,
ResponseInit
init, ๊ทธ๋ฆฌ๊ณ null ๋๋ body with type body๊ฐ ์ฃผ์ด์ก์ ๋,
response๋ฅผ
์ด๊ธฐํํ๋ ค๋ฉด:
-
init["
status"]๊ฐ 200๋ถํฐ 599๊น์ง(ํฌํจ) ๋ฒ์์ ์์ง ์์ผ๋ฉด,RangeError๋ฅผ throwํฉ๋๋ค. -
init["
statusText"]๊ฐ ๋น ๋ฌธ์์ด์ด ์๋๊ณ reason-phrase ํ ํฐ ์์ฑ์๊ณผ ์ผ์นํ์ง ์์ผ๋ฉด,TypeError๋ฅผ throwํฉ๋๋ค. -
response์ response์ status๋ฅผ init["
status"]๋ก ์ค์ ํฉ๋๋ค. -
response์ response์ status message๋ฅผ init["
statusText"]๋ก ์ค์ ํฉ๋๋ค. -
init["
headers"]๊ฐ ์กด์ฌํ๋ฉด, response์ headers๋ฅผ init["headers"]๋ก ์ฑ์๋๋ค. -
body๊ฐ null์ด ์๋๋ฉด:
-
response์ status๊ฐ null body status์ด๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค.101๊ณผ 103์ ๋ค๋ฅธ ๊ณณ์์ ์ฌ์ฉ๋๊ธฐ ๋๋ฌธ์ null body status์ ํฌํจ๋ฉ๋๋ค. ์ด ๋จ๊ณ์๋ ์ํฅ์ ์ฃผ์ง ์์ต๋๋ค.
-
body์ type์ด null์ด ์๋๊ณ response์ header list๊ฐ `
Content-Type`์ ํฌํจํ์ง ์์ผ๋ฉด, (`Content-Type`, body์ type)์ response์ header list์ appendํฉ๋๋ค.
-
new Response(body, init)
์์ฑ์ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
this์ headers๋ฅผ this์ ๊ด๋ จ ์์ญ์ ๊ฐ๋ ์
Headers๊ฐ์ฒด๋ก ์ค์ ํ๋ฉฐ, ๊ทธ header list๋ this์ response์ header list์ด๊ณ guard๋ "response"์ ๋๋ค. -
bodyWithType์ null๋ก ๋ก๋๋ค.
-
body๊ฐ null์ด ์๋๋ฉด, bodyWithType์ body๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
this, init, ๊ทธ๋ฆฌ๊ณ bodyWithType์ด ์ฃผ์ด์ง ์ํ์์ response๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
์ ์ error() ๋ฉ์๋ ๋จ๊ณ๋ ์ network error,
"immutable", ๊ทธ๋ฆฌ๊ณ current realm์ด ์ฃผ์ด์ง ์ํ์์ Response ๊ฐ์ฒด๋ฅผ
์์ฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
์ ์
redirect(url, status) ๋ฉ์๋
๋จ๊ณ๋
๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
parsedURL์ url์ current settings object์ API base URL๊ณผ ํจ๊ป ํ์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
status๊ฐ redirect status๊ฐ ์๋๋ฉด,
RangeError๋ฅผ throwํฉ๋๋ค. -
responseObject๋ฅผ ์ response, "
immutable", ๊ทธ๋ฆฌ๊ณ current realm์ด ์ฃผ์ด์ง ์ํ์์Response๊ฐ์ฒด๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. -
responseObject์ response์ status๋ฅผ status๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ parsedURL์ด ์ง๋ ฌํ๋๊ณ ๋ํ ์ธ์ฝ๋ฉ๋ ๊ฒ์ผ๋ก ๋ก๋๋ค.
-
(`
Location`, value)์ responseObject์ response์ header list์ Appendํฉ๋๋ค. -
responseObject๋ฅผ ๋ฐํํฉ๋๋ค.
์ ์
json(data, init) ๋ฉ์๋ ๋จ๊ณ๋
๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
bytes๋ฅผ data์ ๋ํด JavaScript ๊ฐ์ JSON ๋ฐ์ดํธ๋ก ์ง๋ ฌํ๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
body๋ฅผ bytes๋ฅผ ์ถ์ถํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
responseObject๋ฅผ ์ response, "
response", ๊ทธ๋ฆฌ๊ณ current realm์ด ์ฃผ์ด์ง ์ํ์์Response๊ฐ์ฒด๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. -
responseObject, init, ๊ทธ๋ฆฌ๊ณ (body, "
application/json")์ด ์ฃผ์ด์ง ์ํ์์ response๋ฅผ ์ด๊ธฐํํฉ๋๋ค. -
responseObject๋ฅผ ๋ฐํํฉ๋๋ค.
type getter ๋จ๊ณ๋ this์
response์ type์ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
url getter ๋จ๊ณ๋
this์ response์ URL์ด null์ด๋ฉด ๋น ๋ฌธ์์ด์ ๋ฐํํ๊ณ ,
๊ทธ๋ ์ง ์์ผ๋ฉด this์
response์ URL์,
exclude fragment๋ฅผ true๋ก ์ค์ ํ์ฌ
์ง๋ ฌํํ ๊ฒ์ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
redirected getter ๋จ๊ณ๋
this์ response์ URL list์ size๊ฐ
1๋ณด๋ค ํฌ๋ฉด true๋ฅผ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
๋ฆฌ๋๋ ์
์ ๊ฒฐ๊ณผ์ธ responses๋ฅผ ํํฐ๋งํ๋ ค๋ฉด, ์๋ฅผ ๋ค์ด
fetch(url, { redirect:"error" })์ฒ๋ผ
API๋ฅผ ํตํด ์ง์ ์ฒ๋ฆฌํ์ญ์์ค.
์ด๋ ๊ฒ ํ๋ฉด ์ ์ฌ์ ์ผ๋ก ์์ ํ์ง ์์ response๊ฐ ์ฐ๋ฐ์ ์ผ๋ก ๋์ถ๋ ์ ์์ต๋๋ค.
status getter ๋จ๊ณ๋
this์ response์ status๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
ok getter ๋จ๊ณ๋
this์ response์ status๊ฐ ok status์ด๋ฉด true๋ฅผ ๋ฐํํ๊ณ ,
๊ทธ๋ ์ง ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
statusText getter ๋จ๊ณ๋
this์ response์ status
message๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
headers getter ๋จ๊ณ๋
this์ headers๋ฅผ ๋ฐํํ๋ ๊ฒ์
๋๋ค.
clone() ๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
5.6. fetch ๋ฉ์๋
partial interface mixin WindowOrWorkerGlobalScope { [NewObject ]Promise <Response >fetch (RequestInfo ,input optional RequestInit = {}); };init dictionary :DeferredRequestInit RequestInit {DOMHighResTimeStamp ; }; [activateAfter Exposed =Window ]interface {FetchLaterResult readonly attribute boolean activated ; };partial interface Window { [NewObject ,SecureContext ]FetchLaterResult fetchLater (RequestInfo ,input optional DeferredRequestInit = {}); };init
fetch(input, init)
๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
p๋ฅผ ์ promise๋ก ๋ก๋๋ค.
-
requestObject๋ฅผ
Request์ ์ด๊ธฐ๊ฐ์ input๊ณผ init์ ์ธ์๋ก ํ์ฌ constructor๋ก ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. ์ด๊ฒ์ด ์์ธ๋ฅผ throwํ๋ฉด, p๋ฅผ ๊ทธ ์์ธ๋ก rejectํ๊ณ p๋ฅผ ๋ฐํํฉ๋๋ค. -
request๋ฅผ requestObject์ request๋ก ๋ก๋๋ค.
-
requestObject์ signal์ด aborted์ด๋ฉด, ๋ค์์ ์ํํฉ๋๋ค:
-
p, request, null ๋ฐ requestObject์ signal์ abort reason์ผ๋ก
fetch()ํธ์ถ์ ์ค๋จํฉ๋๋ค. -
p๋ฅผ ๋ฐํํฉ๋๋ค.
-
- globalObject๋ฅผ request์ client์ global object๋ก ๋ก๋๋ค.
- globalObject๊ฐ
ServiceWorkerGlobalScope๊ฐ์ฒด์ด๋ฉด, request์ service-workers mode๋ฅผ "none"์ผ๋ก ์ค์ ํฉ๋๋ค. -
responseObject๋ฅผ null๋ก ๋ก๋๋ค.
-
relevantRealm์ this์ ๊ด๋ จ ์์ญ์ผ๋ก ๋ก๋๋ค.
-
locallyAborted๋ฅผ false๋ก ๋ก๋๋ค.
์ด๋ ์ค๋จ ์์ฒญ์ด fetch ํธ์ถ๊ณผ ๊ฐ์ ์ค๋ ๋์์ ์ค๋ ๊ฒฝ์ฐ, ์์ธก ๊ฐ๋ฅํ ํ์ด๋ฐ์ผ๋ก promise๋ฅผ rejectํ ์ ์๊ฒ ํฉ๋๋ค.
-
controller๋ฅผ null๋ก ๋ก๋๋ค.
-
requestObject์ signal์ ๋ค์ abort ๋จ๊ณ๋ฅผ ์ถ๊ฐํฉ๋๋ค:
-
locallyAborted๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
-
Assert: controller๋ null์ด ์๋๋๋ค.
-
controller๋ฅผ requestObject์ signal์ abort reason์ผ๋ก ์ค๋จํฉ๋๋ค.
-
p, request, responseObject, ๊ทธ๋ฆฌ๊ณ requestObject์ signal์ abort reason์ผ๋ก
fetch()ํธ์ถ์ ์ค๋จํฉ๋๋ค.
-
-
controller๋ฅผ request์, response๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ์ธ processResponse๊ฐ ์ฃผ์ด์ง ์ํ์์ fetch๋ฅผ ํธ์ถํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค:
-
locallyAborted๊ฐ true์ด๋ฉด, ์ด ๋จ๊ณ๋ฅผ ์ค๋จํฉ๋๋ค.
-
response์ aborted flag๊ฐ ์ค์ ๋์ด ์์ผ๋ฉด:
-
deserializedError๋ฅผ controller์ serialized abort reason๊ณผ relevantRealm์ด ์ฃผ์ด์ง ์ํ์์ serialized abort reason์ ์ญ์ง๋ ฌํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
p, request, responseObject, ๊ทธ๋ฆฌ๊ณ deserializedError๋ก
fetch()ํธ์ถ์ ์ค๋จํฉ๋๋ค. -
์ด ๋จ๊ณ๋ฅผ ์ค๋จํฉ๋๋ค.
-
-
response๊ฐ network error์ด๋ฉด, p๋ฅผ
TypeError๋ก rejectํ๊ณ ์ด ๋จ๊ณ๋ฅผ ์ค๋จํฉ๋๋ค. -
responseObject๋ฅผ response, "
immutable", ๊ทธ๋ฆฌ๊ณ relevantRealm์ด ์ฃผ์ด์ง ์ํ์์Response๊ฐ์ฒด๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. -
p๋ฅผ responseObject๋ก resolveํฉ๋๋ค.
-
-
p๋ฅผ ๋ฐํํฉ๋๋ค.
promise, request, responseObject, ๊ทธ๋ฆฌ๊ณ error๋ก
fetch() ํธ์ถ์ ์ค๋จํ๋ ค๋ฉด:
-
promise๋ฅผ error๋ก rejectํฉ๋๋ค.
promise๊ฐ ์ด๋ฏธ fulfilled๋ ๊ฒฝ์ฐ ์ด๋ no-op์ ๋๋ค.
-
request์ body๊ฐ null์ด ์๋๊ณ readable์ด๋ฉด, request์ body๋ฅผ error๋ก cancelํฉ๋๋ค.
-
responseObject๊ฐ null์ด๋ฉด ๋ฐํํฉ๋๋ค.
-
response๋ฅผ responseObject์ response๋ก ๋ก๋๋ค.
-
response์ body๊ฐ null์ด ์๋๊ณ readable์ด๋ฉด, response์ body๋ฅผ error๋ก error ์ฒ๋ฆฌํฉ๋๋ค.
FetchLaterResult์๋
์ฐ๊ด๋ activated getter steps๊ฐ ์์ผ๋ฉฐ,
์ด๋ boolean์ ๋ฐํํ๋ ์๊ณ ๋ฆฌ์ฆ์
๋๋ค.
activated getter ๋จ๊ณ๋
this์ activated getter steps๋ฅผ ์คํํ ๊ฒฐ๊ณผ๋ฅผ
๋ฐํํ๋ ๊ฒ์
๋๋ค.
fetchLater(input, init)
๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
requestObject๋ฅผ
Request์ ์ด๊ธฐ๊ฐ์ input๊ณผ init์ ์ธ์๋ก ํ์ฌ constructor๋ก ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. -
requestObject์ signal์ด aborted์ด๋ฉด, signal์ abort reason์ throwํฉ๋๋ค.
-
request๋ฅผ requestObject์ request๋ก ๋ก๋๋ค.
-
activateAfter๋ฅผ null๋ก ๋ก๋๋ค.
-
init์ด ์ฃผ์ด์ง๊ณ init["
activateAfter"]๊ฐ ์กด์ฌํ๋ฉด, activateAfter๋ฅผ init["activateAfter"]๋ก ์ค์ ํฉ๋๋ค. -
activateAfter๊ฐ 0๋ณด๋ค ์์ผ๋ฉด,
RangeError๋ฅผ throwํฉ๋๋ค. -
this์ ๊ด๋ จ global object์ associated document๊ฐ fully active๊ฐ ์๋๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
request์ URL์ scheme์ด HTTP(S) scheme์ด ์๋๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
request์ URL์ด potentially trustworthy URL์ด ์๋๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค. -
request์ body๊ฐ null์ด ์๋๊ณ , request์ body์ length๊ฐ null์ด๋ฉด,
TypeError๋ฅผ throwํฉ๋๋ค.body๊ฐ
ReadableStream๊ฐ์ฒด์ธ ์์ฒญ์ ์ง์ฐ๋ ์ ์์ต๋๋ค. -
quota๋ฅผ request์ client์ request์ URL์ origin์ด ์ฃผ์ด์ง ์ํ์์์ available deferred-fetch quota๋ก ๋ก๋๋ค.
-
requested๋ฅผ request์ total request length๋ก ๋ก๋๋ค.
-
quota๊ฐ requested๋ณด๋ค ์์ผ๋ฉด, quota๊ฐ quota์ด๊ณ requested๊ฐ requested์ธ
QuotaExceededError๋ฅผ throwํฉ๋๋ค. -
activated๋ฅผ false๋ก ๋ก๋๋ค.
-
deferredRecord๋ฅผ request, activateAfter, ๊ทธ๋ฆฌ๊ณ ๋ค์ ๋จ๊ณ, ์ฆ activated๋ฅผ true๋ก ์ค์ ํ๋ ๋จ๊ณ๊ฐ ์ฃผ์ด์ง ์ํ์์ deferred fetch๋ฅผ ํ์ ๋ฃ๊ธฐ๋ฅผ ํธ์ถํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
requestObject์ signal์ ๋ค์ abort ๋จ๊ณ๋ฅผ ์ถ๊ฐํฉ๋๋ค: deferredRecord์ invoke state๋ฅผ "
aborted"๋ก ์ค์ ํฉ๋๋ค. -
activated getter steps๊ฐ activated๋ฅผ ๋ฐํํ๋ ์
FetchLaterResult๋ฅผ ๋ฐํํฉ๋๋ค.
๋ค์ ํธ์ถ์ ๋ฌธ์๊ฐ ์ข ๋ฃ๋ ๋ ๊ฐ์ ธ์ฌ ์์ฒญ์ ํ์ ์ถ๊ฐํฉ๋๋ค:
fetchLater( "https://report.example.com" , {
method: "POST" ,
body: JSON. stringify( myReport),
headers: { "Content-Type" : "application/json" }
})
๋ค์ ํธ์ถ์ 5์ด ํ์๋ ์ด ์์ฒญ์ ํ์ ์ถ๊ฐํ๋ฉฐ, ๋ฐํ๋ ๊ฐ์ผ๋ก ํธ์ถ์๊ฐ ์ค์ ๋ก ํ์ฑํ๋์๋์ง ๊ด์ฐฐํ ์ ์์ต๋๋ค. ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ํ์ด๋จธ๋ฅผ ์ ํํ๋ ๊ฒฝ์ฐ์๋ ์์ฒญ์ ๋ฐ๋์ ํธ์ถ๋ฉ๋๋ค.
const result = fetchLater( "https://report.example.com" , {
method: "POST" ,
body: JSON. stringify( myReport),
headers: { "Content-Type" : "application/json" },
activateAfter: 5000
});
function check_if_fetched() {
return result. activated;
}
FetchLaterResult
๊ฐ์ฒด๋ AbortSignal
๊ณผ ํจ๊ป ์ฌ์ฉํ ์ ์์ต๋๋ค. ์์:
let accumulated_events = [];
let previous_result = null ;
const abort_signal = new AbortSignal();
function accumulate_event( event) {
if ( previous_result) {
if ( previous_result. activated) {
// ์์ฒญ์ด ์ด๋ฏธ ํ์ฑํ๋์์ผ๋ฏ๋ก, ์๋กญ๊ฒ ์์ํ ์ ์์ต๋๋ค.
accumulated_events = [];
} else {
// ์ด ์์ฒญ์ ์ค๋จํ๊ณ , ๋ชจ๋ ์ด๋ฒคํธ๋ก ์๋ก์ด ์์ฒญ์ ์์ํฉ๋๋ค.
signal. abort();
}
}
accumulated_events. push( event);
result = fetchLater( "https://report.example.com" , {
method: "POST" ,
body: JSON. stringify( accumulated_events),
headers: { "Content-Type" : "application/json" },
activateAfter: 5000 ,
abort_signal
});
}
๋ค์ fetchLater() ํธ์ถ์ ๋ชจ๋ ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค:
// ์ค์ง ์ ๋ขฐํ ์ ์๋ URL ๋ง ์ง์๋ฉ๋๋ค.
fetchLater( "http://untrusted.example.com" );
// ์ง์ฐ๋ ์์ฒญ์ ๊ธธ์ด๋ ๋ฐ๋์ ๋ฏธ๋ฆฌ ์์์ผ ํฉ๋๋ค.
fetchLater( "https://origin.example.com" , { body: someDynamicStream});
// ์ง์ฐ๋ fetch๋ ํ์ฑ ์๋์ฐ์์๋ง ๋์ํฉ๋๋ค.
const detachedWindow = iframe. contentWindow;
iframe. remove();
detachedWindow. fetchLater( "https://origin.example.com" );
์ง์ฐ fetch ํ ๋น๋ ์์๋ฅผ ์ฐธ๊ณ ํ๋ฉด ์ง์ฐ fetch ํ ๋น๋์ด ์ด๋ป๊ฒ ๋์ํ๋์ง ์ ์ ์์ต๋๋ค.
5.7. ๊ฐ๋น์ง ์ปฌ๋ ์
์ฌ์ฉ์ ์์ด์ ํธ๋ ์ข ๋ฃ๊ฐ ์คํฌ๋ฆฝํธ๋ก ๊ด์ฐฐ๋ ์ ์๋ ๊ฒฝ์ฐ ์งํ ์ค์ธ fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
"์คํฌ๋ฆฝํธ๋ก ๊ด์ฐฐ ๊ฐ๋ฅ"ํ๋ค๋ ๊ฒ์ fetch()์ ์ธ์์ ๋ฐํ๊ฐ์ ํตํด ๊ด์ฐฐํ ์ ์๋ค๋
์๋ฏธ์
๋๋ค. ์๋ฒ์์ ์ฌ์ด๋ ์ฑ๋ ํต์ ๊ณผ ๊ฐ์ ๋ค๋ฅธ ๋ฐฉ์์ ํฌํจ๋์ง ์์ต๋๋ค.
์๋ฒ๊ฐ ๊ฐ๋น์ง ์ปฌ๋ ์
์ ๊ด์ฐฐํ ์ ์๋ ์ฌ๋ก๋ WebSocket
๋ฐ XMLHttpRequest
๊ฐ์ฒด์์ ์ด๋ฏธ ์กด์ฌํฉ๋๋ค.
์ฌ์ฉ์ ์์ด์ ํธ๋ ์ข ๋ฃ๊ฐ ๊ด์ฐฐ๋ ์ ์์ผ๋ฏ๋ก fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
fetch( "https://www.example.com/" )
์ฌ์ฉ์ ์์ด์ ํธ๋ ์ข ๋ฃ๊ฐ promise๋ฅผ ํตํด ๊ด์ฐฐ๋ ์ ์์ผ๋ฏ๋ก fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
window. promise = fetch( "https://www.example.com/" )
์ฐ๊ด๋ body๊ฐ ๊ด์ฐฐ๋ ์ ์์ผ๋ฏ๋ก ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
window. promise = fetch( "https://www.example.com/" ). then( res => res. headers)
์ข ๋ฃ๊ฐ ๊ด์ฐฐ๋ ์ ์์ผ๋ฏ๋ก ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
fetch( "https://www.example.com/" ). then( res => res. body. getReader(). closed)
promise ๊ฐ์ฒด์ ํธ๋ค๋ฌ๋ฅผ ๋ฑ๋กํ์ฌ ์ข ๋ฃ๋ฅผ ๊ด์ฐฐํ ์ ์์ผ๋ฏ๋ก ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
window. promise = fetch( "https://www.example.com/" )
. then( res => res. body. getReader(). closed)
ํธ๋ค๋ฌ ๋ฑ๋ก์ ํตํด ์ข ๋ฃ๊ฐ ๊ด์ฐฐ๋ ์ ์์ผ๋ฏ๋ก ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ fetch๋ฅผ ์ข ๋ฃํ ์ ์์ต๋๋ค.
fetch( "https://www.example.com/" )
. then( res => {
res. body. getReader(). closed. then(() => console. log( "stream closed!" ))
})
(์์ ๋น๊ด์ฐฐ์ฑ ์์๋ body.getReader()
๋ฑ ๋ด์ฅ ์์ฑ๊ณผ ํจ์๊ฐ ๋ฎ์ด์จ์ง์ง ์์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.)
6. data: URL
data: URL์ ๋ํ ์ค๋ช
์ RFC 2397์ ์ฐธ๊ณ ํ์ญ์์ค. ์ด ์ ์ ๋ฐฐํฌ๋ ์ปจํ
์ธ ์์ ํธํ์ ์ํด ํด๋น RFC์ ํ์ค ์ฒ๋ฆฌ ์๊ตฌ์ฌํญ์ ๋์ฒดํฉ๋๋ค. [RFC2397]
data: URL
๊ตฌ์กฐ์ฒด๋ ๊ตฌ์กฐ์ฒด์ด๋ฉฐ,
MIME ํ์
(MIME type)๊ณผ
๋ณธ๋ฌธ (๋ฐ์ดํธ ์ํ์ค)๋ฅผ ํฌํจํฉ๋๋ค.
data:
URL ์ฒ๋ฆฌ๊ธฐ๋ URL
dataURL์ ๋ฐ์ ์๋ ์ ์ฐจ๋ฅผ ์คํํฉ๋๋ค:
-
input์ URL serializer๋ฅผ dataURL์ ๋ํด exclude fragment ์ต์ ์ true๋ก ํ์ฌ ์คํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
input์์ ๋งจ ์์ "
data:"๋ฅผ ์ ๊ฑฐํฉ๋๋ค. -
position์ input์ ์์ ์์น๋ก ์ง์ ํฉ๋๋ค.
-
mimeType์, U+002C(,)์ด ์๋ ์ฝ๋ํฌ์ธํธ ์ํ์ค๋ฅผ ์์งํ์ฌ position ๊ธฐ์ค์ผ๋ก ์ป์ต๋๋ค.
-
์ ํ/ํํ ASCII ๊ณต๋ฐฑ์ mimeType์์ ์ ๊ฑฐํฉ๋๋ค.
์ด๊ฒ์ U+0020(SPACE) ์ฝ๋ํฌ์ธํธ๋ง ์ ๊ฑฐํฉ๋๋ค.
-
position์ด input์ ๋์ ์ง๋ ์์น๋ผ๋ฉด, ์คํจ๋ฅผ ๋ฐํํฉ๋๋ค.
-
position์ 1๋งํผ ์ฆ๊ฐ์ํต๋๋ค.
-
encodedBody๋ฅผ input์ ๋๋จธ์ง๋ก ๋ก๋๋ค.
-
body๋ฅผ percent-decoding์ encodedBody์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
mimeType์ด U+003B(;)๋ก ๋๋๊ณ , ๊ทธ ๋ค์ 0๊ฐ ์ด์์ U+0020(SPACE), ๊ทธ ๋ค์ "
base64"์ ASCII ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ์ผ์นํ๋ค๋ฉด:-
stringBody๋ฅผ isomorphic decode๋ฅผ body์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
body๋ฅผ forgiving-base64 decode๋ฅผ stringBody์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ๊ฐฑ์ ํฉ๋๋ค.
-
body๊ฐ ์คํจ๋ผ๋ฉด ์คํจ๋ฅผ ๋ฐํํฉ๋๋ค.
-
mimeType์ ๋ง์ง๋ง 6 ์ฝ๋ํฌ์ธํธ๋ฅผ ์ ๊ฑฐํฉ๋๋ค.
-
ํํ U+0020(SPACE) ์ฝ๋ํฌ์ธํธ๋ฅผ mimeType์์ ์ ๊ฑฐํฉ๋๋ค.
-
mimeType์ ๋ง์ง๋ง U+003B(;)๋ ์ ๊ฑฐํฉ๋๋ค.
-
-
mimeType์ด "
;"๋ก ์์ํ๋ฉด, mimeType ์์ "text/plain"์ ๋ถ์ ๋๋ค. -
mimeTypeRecord๋ฅผ MIME ํ์ ํ์ฑ์ mimeType์ ๋ํด ์ํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
mimeTypeRecord๊ฐ ์คํจ๋ผ๋ฉด, mimeTypeRecord๋ฅผ
text/plain;charset=US-ASCII๋ก ๋ก๋๋ค. -
์๋ ํ๋๋ก ์
data:URL ๊ตฌ์กฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค: MIME ํ์ ์ mimeTypeRecord, ๋ณธ๋ฌธ์ body์ ๋๋ค.
๋ฐฐ๊ฒฝ ์ฝ๊ธฐ
์ด ์น์ ๊ณผ ํ์ ์น์ ๋ค์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
HTTP ํค๋ ๋ ์ด์ด ๊ตฌ๋ถ
fetch ๊ด์ ์์ API ๋ ์ด์ด(HTML์ img, CSS์ background-image), ์ด๊ธฐ fetch ๋ ์ด์ด, ์๋น์ค ์์ปค ๋ ์ด์ด,
๋คํธ์ํฌ & ์บ์ ๋ ์ด์ด๊ฐ ์์ต๋๋ค. `Accept` ๋ฐ `Accept-Language`๋ ์ด๊ธฐ fetch ๋ ์ด์ด(์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ์
์์ด์ ํธ์ ์ํด)์์ ์ค์ ๋ฉ๋๋ค. ๋๋ถ๋ถ์ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ ์ดํ๋ ๋ค๋ฅธ ํค๋๋ค, ์๋ฅผ ๋ค์ด `Accept-Encoding`, `Host`,
`Referer`๋ ๋คํธ์ํฌ & ์บ์ ๋ ์ด์ด์์ ์ค์ ๋ฉ๋๋ค. ๊ฐ๋ฐ์๋ API ๋ ์ด์ด ๋๋ ์๋น์ค ์์ปค ๋ ์ด์ด(์ผ๋ฐ์ ์ผ๋ก Request ๊ฐ์ฒด๋ฅผ ํตํด)์์
ํค๋๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค. ๊ฐ๋ฐ์๋ ๊ธ์ง๋ ์์ฒญ ํค๋์ ๊ฑฐ์ ์ ๊ทผํ ์ ์์ผ๋, `Accept`๋ ์ ์ดํ ์ ์๊ณ ,
`Referer`๋ ์ ํํ๊ฑฐ๋ ์๋ตํ ์ ์๋ ์๋จ์ด ์์ต๋๋ค.
์์์ HTTP ๋ฆฌ๋ค์ด๋ ํธ ์ฒ๋ฆฌ
๋ฆฌ๋ค์ด๋ ํธ(์ฆ, response์ status ๋๋ internal response์(์๋ ๊ฒฝ์ฐ) status๊ฐ ๋ฆฌ๋ค์ด๋ ํธ ์ํ์ธ ๊ฒฝ์ฐ)๋ API์ ๋ ธ์ถ๋์ง ์๋๋ค. ๋ฆฌ๋ค์ด๋ ํธ๋ฅผ ๋ ธ์ถํ๋ฉด ๊ต์ฐจ ์ฌ์ดํธ ์คํฌ๋ฆฝํ ๊ณต๊ฒฉ์ผ๋ก๋ ์ป์ ์ ์๋ ์ ๋ณด๋ฅผ ๋์คํ ์ ์๋ค.
https://example.org/auth๋ก fetchํ ๋ HttpOnly๋ก
ํ์๋ Cookie๊ฐ ํฌํจ๋๋ฉด https://other-origin.invalid/4af955781ea1c84a3b11๋ก ๋ฆฌ๋ค์ด๋ ํธ๋ ์ ์์ต๋๋ค.
์ด ์๋ก์ด URL์๋ ๋น๋ฐ์ด ํฌํจ๋์ด ์์ต๋๋ค. ๋ฆฌ๋ค์ด๋ ํธ๋ฅผ ๋
ธ์ถํ๋ฉด ํด๋น ๋น๋ฐ์ด ๊ต์ฐจ ์ฌ์ดํธ ์คํฌ๋ฆฝํ
๊ณต๊ฒฉ์ ํตํด ์ป์ด์ง ์ ์์ต๋๋ค.
๊ธฐ๋ณธ ์์ CORS ํ๋กํ ์ฝ ์ค์
IP ์ธ์ฆ ๋๋ ๋ฐฉํ๋ฒฝ์ ํตํด ๋ฐ์ดํฐ๊ฐ ๋ณดํธ๋๋ ๋ฆฌ์์ค(์์ง๋ ๊ฝค ํํจ)์ ๊ฒฝ์ฐ CORS ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ ๊ฒ์ ์์ ํ์ง ์์ต๋๋ค. (์ด ๋๋ฌธ์ CORS ํ๋กํ ์ฝ์ด ๋ง๋ค์ด์ก์ต๋๋ค.)
๊ทธ๋ฌ๋, ๋ค์ ํค๋๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ์์ ํฉ๋๋ค:
Access-Control-Allow-Origin: *
๋ฆฌ์์ค๊ฐ ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ฟ ํค๋ HTTP ์ธ์ฆ์ ๋ฐ๋ผ ๋
ธ์ถํ๋ค ํด๋, ์ ํค๋๋ฅผ ์ฌ์ฉํ๋ฉด ๊ทธ ์ ๋ณด๋ฅผ ๋
ธ์ถํ์ง ์์ต๋๋ค. API(XMLHttpRequest
๋ฑ)์ ๋ง์ฐฌ๊ฐ์ง๋ก curl, wget์๋ ๋์ผํ๊ฒ ๊ณต์ ๋ฉ๋๋ค.
์ฆ, curl์ด๋ wget์ผ๋ก ์น์ ์ฐ๊ฒฐ๋ ์์์ ์ฅ์น์์ ๋ฆฌ์์ค์ ์ ๊ทผํ ์ ์๋ค๋ฉด ์ ํค๋๋ฅผ ํฌํจํ์ง ์์์ผ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ์ ๊ทผ ๊ฐ๋ฅํ๋ค๋ฉด ํฌํจํด๋ ๊ด์ฐฎ์ต๋๋ค.
CORS ํ๋กํ ์ฝ๊ณผ HTTP ์บ์
CORS ํ๋กํ ์ฝ ์๊ตฌ์ฌํญ์ด
`Access-Control-Allow-Origin`์
* ๋๋ ์ ์ ์ธ
origin์ผ๋ก ์ค์ ํ๋ ๊ฒ๋ณด๋ค ๋ ๋ณต์กํ๋ฉด, `Vary`๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค.
[HTML] [HTTP] [HTTP-CACHING]
Vary: Origin
ํนํ, `Vary`๊ฐ ์ฌ์ฉ๋์ง ์๊ณ ์๋ฒ๊ฐ ํน์
๋ฆฌ์์ค์ ๋ํด CORS
์์ฒญ์ ๋ํ ์๋ต์์๋ง `Access-Control-Allow-Origin`์
๋ณด๋ด๋๋ก ๊ตฌ์ฑ๋ ๊ฒฝ์ฐ ์ด๋ค ์ผ์ด ๋ฐ์ํ๋์ง ์๊ฐํด ๋ณด๋ผ. ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ๊ทธ
๋ฆฌ์์ค์ ๋ํ non-CORS ์์ฒญ์
์๋ต์ ๋ฐ์ผ๋ฉด(์๋ฅผ ๋ค์ด ๋ด๋น๊ฒ์ด์
์์ฒญ์ ๊ฒฐ๊ณผ๋ก), ๊ทธ ์๋ต์๋ `Access-Control-Allow-Origin`์ด
์๊ณ ์ฌ์ฉ์ ์์ด์ ํธ๋ ๊ทธ ์๋ต์ ์บ์ํ๋ค. ๊ทธ๋ฌ๋ฉด ์ดํ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ๊ทธ ๋ฆฌ์์ค์ ๋ํ
CORS ์์ฒญ์ ๋ง์ฃผ์น๋ฉด,
์ด์ non-CORS ์์ฒญ์์ ์จ
๊ทธ ์บ์๋ ์๋ต์ ์ฌ์ฉํ๊ฒ ๋๋ฉฐ, ๊ฑฐ๊ธฐ์๋ `Access-Control-Allow-Origin`์ด ์๋ค.
ํ์ง๋ง ์์์ ์ค๋ช
ํ ๋์ผํ ์๋๋ฆฌ์ค์์ `Vary: Origin`์ด ์ฌ์ฉ๋๋ฉด, ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ
`Access-Control-Allow-Origin`์
ํฌํจํ๋ ์๋ต์ fetchํ๊ฒ ํ๋ฉฐ,
`Access-Control-Allow-Origin`์ด ์๋
์ด์ non-CORS
์์ฒญ์ ์บ์๋ ์๋ต์ ์ฌ์ฉํ๋ ๋์ ๊ทธ๋ ๊ฒ ํ๋ค.
๊ทธ๋ฌ๋ `Access-Control-Allow-Origin`์ด
ํน์ ๋ฆฌ์์ค์ ๋ํด * ๋๋ ์ ์ ์ธ origin์ผ๋ก ์ค์ ๋์ด ์๋ค๋ฉด, ๊ทธ ๋ฆฌ์์ค์ ๋ํ ์๋ต์์
non-CORS
์์ฒญ๋ฟ ์๋๋ผ CORS
์์ฒญ์ ๋ํด์๋ ํญ์ `Access-Control-Allow-Origin`์ ๋ณด๋ด๋๋ก
์๋ฒ๋ฅผ ๊ตฌ์ฑํ๊ณ , `Vary`๋ ์ฌ์ฉํ์ง ๋ง๋ผ.
์น์์ผ(WebSockets)
์ฐ๊ฒฐ์ ์ค์ ํ๋ ๊ณผ์ ์์ WebSocket
๊ฐ์ฒด๋ ํน๋ณํ ์ข
๋ฅ์
fetch๋ฅผ ์์ํ๋ค(์ฌ๊ธฐ์ request์ mode๊ฐ
"websocket"์). ์ด๋ฅผ ํตํด ๋ง์ fetch ์ ์ฑ
๊ฒฐ์ (์: HTTP Strict Transport Security (HSTS))์ ๊ณต์ ํ
์ ์๋ค. ๊ถ๊ทน์ ์ผ๋ก fetch๋ WebSockets์ ํธ์ถ๋์ด ์ ์ฉ ์ฐ๊ฒฐ์ ํ๋ํ๊ฒ ๋๋ค. [WEBSOCKETS]
[HSTS]
๊ณผ๊ฑฐ์๋ Fetch์์ WebSocket ์ฐ๊ฒฐ ํ๋ํ๊ธฐ์ WebSocket ์ฐ๊ฒฐ ์ค์ ํ๊ธฐ๋ฅผ ์ง์ ์ ์ํ์ผ๋, ํ์ฌ๋ ๋ ๋ค WebSockets์์ ์ ์๋๋ค. [WEBSOCKETS]
๋ค๋ฅธ ํ์ค์์ fetch ์ฌ์ฉํ๊ธฐ
๋ณธ์ง์ ์ผ๋ก fetch๋ request์ response์ ๊ตํ์ด๋ค. ์ค์ ๋ก๋ ํ์ค์์ ์ฌ๋ฐ๋ฅด๊ฒ ๋์ ํ๊ณ ์ฌ์ฉํ๊ธฐ์ ๋ค์ ๋ณต์กํ ๋ฉ์ปค๋์ฆ์ด๋ค. ์ด ์ ์์๋ ์ด์ ๋ํ ์กฐ์ธ์ ์ ๊ณตํ๋ค.
ํญ์ ๋๋ฉ์ธ ์ ๋ฌธ๊ฐ์ ๋ฆฌ๋ทฐ๋ฅผ ์์ฒญํ์ธ์.
์์ ์งํ ์ค์ ๋๋ค.
์์ฒญ ์ค์ ํ๊ธฐ
fetch์ ์ฒซ ๋ฒ์งธ ๋จ๊ณ๋ request๋ฅผ ์์ฑํ๊ณ , ๊ทธ ํญ๋ชฉ๋ค(items)์ ์ฑ์๋ฃ๋ ๊ฒ์ ๋๋ค.
์์ฒญ์ URL๊ณผ method๋ฅผ
HTTP์์ ์ ์ํ ๋๋ก
์ค์ ํ๋ ๊ฒ๋ถํฐ ์์ํ๋ค. `POST` ๋๋ `PUT` ์์ฒญ์
body๊ฐ ํ์ํ๋ฉด, ์์ฒญ์
body๋ฅผ ๋ฐ์ดํธ ์ํ์ค๋ก ์ค์ ํ๊ฑฐ๋,
๊ทธ stream์ด
์ง์ ๋ง๋ ReadableStream์ธ
์ body๋ก ์ค์ ํ๋ค.
[HTTP]
์์ฒญ์ destination์
destination table์ ์ง์นจ์ ์ฌ์ฉํ์ฌ ์ ํํ๋ค. Destinations๋
Content Security Policy์ ์ํฅ์ ์ฃผ๋ฉฐ
`Sec-Fetch-Dest`
ํค๋์ ๊ฐ์ ๋ค๋ฅธ ์ํฅ๋ ์์ผ๋ฏ๋ก, ๋จ์ํ ์ ๋ณด ์ ๊ณต์ฉ ๋ฉํ๋ฐ์ดํฐ๋ณด๋ค ํจ์ฌ ๋ ์ค์ํ๋ค. ์ ๊ธฐ๋ฅ์
destination์ด ํ์ํ์ง๋ง ๊ทธ๊ฒ์ด destination table์ ์๋ค๋ฉด,
๋
ผ์๋ฅผ ์ํด
์ด์๋ฅผ
์ ์ถํ๋ผ. [CSP]
์์ฒญ์ client๋ฅผ
์์
์ค์ธ
ํ๊ฒฝ ์ค์ ๊ฐ์ฒด๋ก ์ค์ ํ๋ค.
์น์ ๋
ธ์ถ๋๋ API๋ ์ผ๋ฐ์ ์ผ๋ก Web IDL๋ก ์ ์๋๋ฉฐ, ์ฌ๊ธฐ์ interface๋ฅผ
๊ตฌํํ๋ ๋ชจ๋ ๊ฐ์ฒด์๋ ์ฌ์ฉํ ์ ์๋
relevant settings object๊ฐ ์๋ค. ์๋ฅผ ๋ค์ด,
์์ฒญ์ด
์์์ ์ฐ๊ด๋์ด ์๋ค๋ฉด, ๊ทธ ์์ฒญ์ client๋ฅผ ์์์
node document์ relevant settings object๋ก ์ค์ ํ๊ฒ ๋๋ค. JavaScript, HTML, CSS ๋๋
๋ค๋ฅธ
Document
ํ์ ๋ฆฌ์์ค์ ์ํด ์ง์ ์น์ ๋
ธ์ถ๋๋ ๋ชจ๋ ๊ธฐ๋ฅ์๋
client๊ฐ ์์ด์ผ
ํ๋ค.
fetching์ด
์ง์ ์น์ ๋
ธ์ถ๋์ง ์๋๋ค๋ฉด, ์๋ฅผ ๋ค์ด ํ์ฌ Window
๋๋ Worker์
์์กดํ์ง ์๊ณ ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์ ์ก๋๋ค๋ฉด,
์์ฒญ์
client๋ฅผ
null๋ก ๋๊ณ , ๋์ ์์ฒญ์ origin,
policy container, service-workers
mode, ๊ทธ๋ฆฌ๊ณ
referrer๋ฅผ ์ ์ ํ ๊ฐ์ผ๋ก ์ค์ ํ๋ค. ์๋ฅผ ๋ค์ด
๋ฏธ๋ฆฌ ํ๊ฒฝ ์ค์ ๊ฐ์ฒด์์ ๋ณต์ฌํ ์ ์๋ค. ์ด๋ฌํ ๋ ๊ณ ๊ธ ์ฌ๋ก์์๋
fetch๊ฐ Content Security Policy์
referrer policy๋ฅผ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ๋์ง์ ๊ดํ
์ธ๋ถ ์ฌํญ์ ๋ช
ํํ ํด์ผ ํ๋ค. ๋ํ ์ฝ๋ฐฑ
(fetch ํธ์ถ ๋ฐ ์๋ต ์ฒ๋ฆฌ ์ฐธ์กฐ)์ด parallel queue์ ๊ฒ์๋๋ฏ๋ก, ๋์์ฑ๋ ์ฒ๋ฆฌํด์ผ ํ๋ค. [REFERRER] [CSP]
๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค๋ฅผ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง ๊น์ด ์๊ฐํด์ผ ํ๋ค. ์ผ๋ถ ๊ธฐ๋ฅ์
same origin์์๋ง ๋์ํ ์ ์์ผ๋ฉฐ, ์ด ๊ฒฝ์ฐ ์์ฒญ์ mode๋ฅผ
"same-origin"์ผ๋ก ์ค์ ํ๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด, ์๋ก ์น์ ๋
ธ์ถ๋๋ ๊ธฐ๋ฅ์ ๊ฑฐ์ ํญ์ ๊ทธ
mode๋ฅผ
"cors"๋ก ์ค์ ํด์ผ ํ๋ค. ๊ธฐ๋ฅ์ด ์น์ ๋
ธ์ถ๋์ง ์๊ฑฐ๋,
CORS ์์ด ๊ต์ฐจ ์ถ์ฒ ๋ฆฌ์์ค๋ฅผ fetchํด์ผ ํ๋ ๋ค๋ฅธ ์ด์ ๊ฐ ์๋ค๊ณ ์๊ฐํ๋ค๋ฉด,
๋
ผ์๋ฅผ ์ํด
์ด์๋ฅผ
์ ์ถํ๋ผ.
๊ต์ฐจ ์ถ์ฒ ์์ฒญ์ ๊ฒฝ์ฐ, ์๊ฒฉ ์ฆ๋ช
์
์์ฒญ์ ํฌํจํ ์ง ์ฌ๋ถ๋ ๊ฒฐ์ ํ๋ฉฐ, ํฌํจํด์ผ ํ๋ค๋ฉด ์์ฒญ์ credentials
mode๋ฅผ
"include"๋ก ์ค์ ํ๋ค.
fetch๊ฐ Resource Timing์ ๋ณด๊ณ ๋์ด์ผ ํ๋์ง, ๊ทธ๋ฆฌ๊ณ ์ด๋ค initiator type์ผ๋ก ๋ณด๊ณ ๋์ด์ผ ํ๋์ง ํ์ ํ๋ค. initiator type์ ์์ฒญ์ ์ ๋ฌํ๋ฉด, fetch๊ฐ ์๋ฃ๋๊ณ ์๋ต์ด ์์ ํ ๋ค์ด๋ก๋๋ ๋ค Resource Timing์ ๋ํ ๋ณด๊ณ ๊ฐ ์๋์ผ๋ก ์ํ๋๋ค. [RESOURCE-TIMING]
์์ฒญ์ ์ถ๊ฐ HTTP ํค๋๊ฐ ํ์ํ๋ค๋ฉด, ๊ทธ header list๋ฅผ
ํด๋น ํค๋๋ค์ ํฌํจํ๋ header
list๋ก
์ค์ ํ๋ค. ์: ยซ (`My-Header-Name`,
`My-Header-Value`) ยป. ์ฌ์ฉ์ ์ง์ ํค๋๋ฅผ ๋ณด๋ด๋ ๊ฒ์
CORS-preflight
fetch๊ฐ ํ์ํด์ง๋ ๊ฒ๊ณผ ๊ฐ์ ์ํฅ์ ์ค ์ ์์ผ๋ฏ๋ก ์ฃผ์ํด์ ์ฒ๋ฆฌํ๋ผ.
๊ธฐ๋ณธ ์บ์ฑ ๋ฉ์ปค๋์ฆ์ ์ฌ์ ์ํ๊ณ ์ถ๋ค๋ฉด, ์๋ฅผ ๋ค์ด ์ด
์์ฒญ์ ๋ํ ์บ์ฑ์ ๋นํ์ฑํํ๋ ค๋ฉด,
์์ฒญ์ cache mode๋ฅผ
"default"๊ฐ ์๋ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
์์ฒญ์ด ๋ฆฌ๋๋ ์
์ ์ง์ํ๊ฒ ํ ์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ค. ์ํ์ง ์๋๋ค๋ฉด, ๊ทธ
redirect mode๋ฅผ "error"๋ก ์ค์ ํ๋ค.
์์ฒญ์ ๋๋จธ์ง ๋งค๊ฐ๋ณ์๋ค์ ์ดํด๋ณด๊ณ ๋ค๋ฅธ ๊ด๋ จ ์ฌํญ์ด ์๋์ง ํ์ธํ๋ค. ๋๋จธ์ง ๋งค๊ฐ๋ณ์๋ค์ ๋ ์์ฃผ ์ฌ์ฉ๋๋ฉฐ, ์ฃผ๋ก ํน์ํ ๋ชฉ์ ์ ์ํด ์ฌ์ฉ๋๊ณ , ์ด ํ์ค์ ยง 2.2.5 Requests ์ ์์ ์์ธํ ๋ฌธ์ํ๋์ด ์๋ค.
fetch ํธ์ถ ๋ฐ ์๋ต ์ฒ๋ฆฌ
์์ฒญ ์ธ์๋ fetch ์์ ์ ์ฌ๋ฌ ์ ํ์ ์ธ์๋ฅผ ๋ฐ๋๋ค. ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ ์ธ์์ ๊ฒฝ์ฐ: ๊ทธ ์๊ณ ๋ฆฌ์ฆ์ task์์ ํธ์ถ๋๋ค(๋๋ parallel queue์์ ํธ์ถ๋๋ค. useParallelQueue๊ฐ true์ธ ๊ฒฝ์ฐ).
์์ฒญ์ด ์ค์ ๋๋ฉด, fetch์ ์ด๋ค ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ฌํ ์ง ๊ฒฐ์ ํ๊ธฐ ์ํด, ์๋ต์ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ๊ณ ์ถ์์ง, ํนํ ์ด๋ค ๋จ๊ณ์์ ์ฝ๋ฐฑ์ ๋ฐ๊ณ ์ถ์์ง๋ฅผ ๊ฒฐ์ ํ๋ค:
- ์๋ฃ ์
-
์ด๋ ๋๋ถ๋ถ์ ํธ์ถ์๊ฐ ์๋ต์ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ด๋ค. ์๋ฅผ ๋ค์ด scripts์ style resources๊ฐ ๊ทธ๋ ๋ค. ์๋ต์ body๋ ์ ์ฒด๊ฐ ๋ฐ์ดํธ ์ํ์ค๋ก ์ฝํ ๋ค, ํธ์ถ์๊ฐ ์ฒ๋ฆฌํ๋ค.
์๋ฃ ์ ์๋ต์ ์ฒ๋ฆฌํ๋ ค๋ฉด, ์๊ณ ๋ฆฌ์ฆ์ fetch์ processResponseConsumeBody ์ธ์๋ก ์ ๋ฌํ๋ค. ์ฃผ์ด์ง ์๊ณ ๋ฆฌ์ฆ์๋ ์๋ต๊ณผ ์์ ํ ์ฝํ body (์๋ต์ ๋ด๋ถ ์๋ต์ ๊ฒ)๋ฅผ ๋ํ๋ด๋ ์ธ์๊ฐ ์ ๋ฌ๋๋ค. ๋ ๋ฒ์งธ ์ธ์์ ๊ฐ์ ๋ค์ ์๋ฏธ๋ฅผ ๊ฐ์ง๋ค:
- null
- ์๋ต์ body๊ฐ null์ด๋ค. ์ด๋ ์๋ต์ด network error์ด๊ฑฐ๋ null body status๋ฅผ ๊ฐ์ง๊ธฐ ๋๋ฌธ์ด๋ค.
- failure
- ์๋ต์ body ๋ด์ฉ์ ์์ ํ ์ฝ์ผ๋ ค๋ ์๋๊ฐ ์คํจํ๋ค. ์๋ฅผ ๋ค์ด I/O ์ค๋ฅ ๋๋ฌธ์ผ ์ ์๋ค.
- ๋ฐ์ดํธ ์ํ์ค
-
์๋ต์ ๋ด๋ถ ์๋ต์ body ๋ด์ฉ์ ์์ ํ ์ฝ๊ธฐ๊ฐ ์ฑ๊ณตํ๋ค.
์ ์ฒด ๋ด์ฉ์ ํฌํจํ๋ ๋ฐ์ดํธ ์ํ์ค๋ ์์ฒญ์ mode๊ฐ "
no-cors"์ธ ๊ฒฝ์ฐ์๋ ์ ๋ฌ๋๋ค. ๊ทธ๋ฌํ ์ฝํ ์ธ ๋ ์์ฒญํ๋ origin์์ ์ ๊ทผํ ์ ์์ด์ผ ํ๋ฏ๋ก, ํธ์ถ์๋ ์ด๋ฅผ ์ฒ๋ฆฌํ ๋ ์ฃผ์ํด์ผ ํ๋ค. ์๋ฅผ ๋ค์ด, ํธ์ถ์๋ "no-cors" ์๋ต์ ๋ด์ฉ์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง ์ฝํ ์ธ ๋ฅผ ์ฌ์ฉ์์๊ฒ ์ง์ ํ์ํ ์ ์์ง๋ง, ๊ทธ ์ด๋ฏธ์ง ์ฝํ ์ธ ๋ ์๋ฒ ๋ฉ ๋ฌธ์์ ์คํฌ๋ฆฝํธ์ ์ง์ ๋ ธ์ถ๋์ด์๋ ์ ๋๋ค.
-
request๋ฅผ ์์ฒญ์ผ๋ก ๋๋ฉฐ, ๊ทธ URL์
https://stuff.example.com/์ด๊ณ client๋ this์ relevant settings object์ด๋ค. -
request๋ฅผ Fetchํ๋, processResponseConsumeBody๋ฅผ ์๋ต response์ null, failure, ๋๋ ๋ฐ์ดํธ ์ํ์ค contents๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ๋๋ก ์ค์ ํ๋ค:
-
contents๊ฐ null ๋๋ failure์ด๋ฉด, ์ฌ์ฉ์์๊ฒ ์ค๋ฅ๋ฅผ ํ์ํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, response์ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ๊ณ ๋ คํ์ฌ contents๋ฅผ ํ์ฑํ๊ณ , ๊ทธ์ ๋ํด ์์ฒด ์์ ์ ์ํํ๋ค.
-
- ํค๋ ๋จผ์ , ๊ทธ๋ค์ ์ฒญํฌ ๋จ์๋ก
-
์ผ๋ถ ๊ฒฝ์ฐ, ์๋ฅผ ๋ค์ด ๋น๋์ค๋ฅผ ์ฌ์ํ๊ฑฐ๋ ์ด๋ฏธ์ง๋ฅผ ์ ์ง์ ์ผ๋ก ๋ก๋ํ ๋, ํธ์ถ์๋ ์๋ต์ ์คํธ๋ฆฌ๋ฐํ๊ณ ํ ๋ฒ์ ํ๋์ ์ฒญํฌ์ฉ ์ฒ๋ฆฌํ๊ณ ์ถ์ ์ ์๋ค. ์๋ต์ ํค๋๊ฐ ์ฒ๋ฆฌ๋ ๋ค fetch ํธ์ถ์์๊ฒ ๋๊ฒจ์ง๊ณ , ํธ์ถ์๋ ๊ทธ ์ง์ ๋ถํฐ ๊ณ์ํ๋ค.
์๋ต์ ์ฒญํฌ ๋จ์๋ก ์ฒ๋ฆฌํ๋ ค๋ฉด, ์๊ณ ๋ฆฌ์ฆ์ fetch์ processResponse ์ธ์๋ก ์ ๋ฌํ๋ค. ์ฃผ์ด์ง ์๊ณ ๋ฆฌ์ฆ์๋ ์๋ต์ ํค๋๊ฐ ์์ ๋์์ ๋ ์๋ต์ด ์ ๋ฌ๋๋ฉฐ, ๋๋จธ์ง ์๋ต์ ๋ค์ด๋ก๋ํ๊ธฐ ์ํด ์๋ต์ body์ stream์ ์ฝ์ ์ฑ ์์ด ์๋ค. ํธ์๋ฅผ ์ํด processResponseEndOfBody ์ธ์์๋ ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ฌํ ์ ์์ผ๋ฉฐ, ์ด๋ ์๋ต๊ณผ ๊ทธ body๋ฅผ ์์ ํ ์ฝ๋ ๊ฒ์ ๋๋์ ๋ ํ ๋ฒ ํธ์ถ๋๋ค. processResponseConsumeBody์ ๋ฌ๋ฆฌ, processResponse ๋๋ processResponseEndOfBody ์ธ์๋ฅผ ์ ๋ฌํด๋ ์๋ต์ด ์์ ํ ์ฝํ๋ค๋ ๋ณด์ฅ์ ์์ผ๋ฉฐ, ํธ์ถ์๋ ์ด๋ฅผ ์ง์ ์ฝ์ ์ฑ ์์ด ์๋ค๋ ์ ์ ์ ์ํ๋ผ.
processResponse ์ธ์๋ ์๋ต์ header list์ status๋ฅผ body๋ฅผ ์ ํ ์ฒ๋ฆฌํ์ง ์๊ณ ๋ค๋ฃจ๋ ๋ฐ์๋ ์ ์ฉํ๋ค. ์ด๋ ์๋ฅผ ๋ค์ด ok status๋ฅผ ๊ฐ์ง ์๋ ์๋ต์ ์ฒ๋ฆฌํ ๋ ์ฌ์ฉ๋๋ค.
-
request๋ฅผ ์์ฒญ์ผ๋ก ๋๋ฉฐ, ๊ทธ URL์
https://stream.example.com/์ด๊ณ client๋ this์ relevant settings object์ด๋ค. -
request๋ฅผ Fetchํ๋, processResponse๋ฅผ ์๋ต response๊ฐ ์ฃผ์ด์ก์ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ๋๋ก ์ค์ ํ๋ค:
-
response๊ฐ network error์ด๋ฉด, ์ฌ์ฉ์์๊ฒ ์ค๋ฅ๋ฅผ ํ์ํ๋ค.
-
๊ทธ๋ ์ง ์๊ณ , response์ status๊ฐ ok status๊ฐ ์๋๋ฉด, ์ฌ์ฉ์์๊ฒ ์ด๋ค fallback ๊ฐ์ ํ์ํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, reader๋ฅผ ์ป๊ณ , ์ด๋ response์ body์ stream์ ๋ํ ๊ฒ์ด๋ฉฐ, response์ headers list์์ MIME type์ ์ถ์ถํ์ฌ ์๋ณํ MIME type์ ์ ์ ํ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ๋ค.
-
-
- ์๋ต ๋ฌด์
-
์ผ๋ถ ๊ฒฝ์ฐ์๋ ์๋ต์ด ์ ํ ํ์ํ์ง ์๋ค. ์๋ฅผ ๋ค์ด
navigator.sendBeacon()์ ๊ฒฝ์ฐ๊ฐ ๊ทธ๋ ๋ค. ์๋ต์ ์ฒ๋ฆฌํ๊ณ ์ฝ๋ฐฑ์ fetch์ ์ ๋ฌํ๋ ๊ฒ์ ์ ํ ์ฌํญ์ด๋ฏ๋ก, ์ฝ๋ฐฑ์ ์๋ตํ๋ฉด ์๋ต์ ๊ธฐ๋ํ์ง ์๊ณ fetchํ๊ฒ ๋๋ค. ์ด๋ฌํ ๊ฒฝ์ฐ์๋ ์๋ต์ body์ stream์ด ํ๊ธฐ๋๋ฉฐ, ํธ์ถ์๋ ์ฝํ ์ธ ๋ฅผ ๋ถํ์ํ๊ฒ ๋ค์ด๋ก๋ํ๋ ๊ฒ์ ๋ํด ๊ฑฑ์ ํ ํ์๊ฐ ์๋ค.Fetchํ ์์ฒญ์ ๊ทธ URL์ด
https://fire-and-forget.example.com/, method๊ฐ `POST`์ด๊ณ , client๊ฐ this์ relevant settings object์ธ ๊ฒ์ด๋ค.
์๋ต์ ์ฒ๋ฆฌํ๋ ์ฝ๋ฐฑ ์ธ์๋, fetch๋ ๊ณ ๊ธ ์ฌ๋ก๋ฅผ ์ํ ์ถ๊ฐ ์ฝ๋ฐฑ์ ๋ฐ๋๋ค. processEarlyHintsResponse๋ ํนํ ์๋ต ์ค status๊ฐ 103์ธ ๊ฒ์ ์ํด ์๋๋ ๊ฒ์ด๋ฉฐ, ํ์ฌ๋ ๋ด๋น๊ฒ์ด์ ์์๋ง ์ฒ๋ฆฌ๋๋ค. processRequestBodyChunkLength์ processRequestEndOfBody๋ ํธ์ถ์์๊ฒ request body ์ ๋ก๋ ์งํ ์ํฉ์ ์๋ฆฐ๋ค.
fetch ์์ ์ ํธ์ถ๋ ๋์ผํ ์ค๋ ๋์์ ์์ํ ๋ค, ๋ด๋ถ ์์ ์ ๋ณ๋ ฌ๋ก ์คํํ๊ธฐ ์ํด ๋ถ๋ฆฌ๋๋ค๋ ์ ์ ์ ์ํ๋ผ. ์์ ์ธ๊ธํ ์ฝ๋ฐฑ์ ์ฃผ์ด์ง event loop์ ๊ฒ์๋๋ฉฐ, ๊ธฐ๋ณธ์ ์ผ๋ก ์ด๋ client์ ์ ์ญ ๊ฐ์ฒด์ด๋ค. ์๋ต์ ๋ณ๋ ฌ๋ก ์ฒ๋ฆฌํ๊ณ ๋ฉ์ธ ์ค๋ ๋์์ ์ํธ์์ฉ์ ์ง์ ๋ค๋ฃจ๋ ค๋ฉด, fetchํ๋ useParallelQueue๋ฅผ true๋ก ์ค์ ํ๋ค.
์งํ ์ค์ธ fetch ์กฐ์ํ๊ธฐ
์ด๋ฏธ ์์๋ fetch ์ฐ์ฐ์ ์กฐ์ํ๋ ค๋ฉด, fetch controller๋ฅผ ์ฌ์ฉํ๋ค. fetch controller๋ fetch ํธ์ถ ์ ๋ฐํ๋๋ค. ์๋ฅผ ๋ค์ด, ์ฌ์ฉ์์ ๋์์ด๋ ํ์ด์ง ๋ก์ง์ ๋ฐ๋ผ abort๋ฅผ, ๋ธ๋ผ์ฐ์ ๋ด๋ถ ์ฌ์ ์ ๋ฐ๋ผ terminate๋ฅผ ์คํํ ์ ์๋ค.
์ข
๋ฃ ๋ฐ ์ค๋จ ์ธ์๋, ํธ์ถ์๋ ํ์ด๋ฐ ๋ณด๊ณ (initiator type์ ์ ๋ฌํ์ง ์์ ๊ฒฝ์ฐ)๋ ์ ์ฒด ํ์ด๋ฐ ์ ๋ณด ์ถ์ถ๋ ํ ์ ์๋ค(์ด ๊ธฐ๋ฅ์
๋ค๋น๊ฒ์ด์
์์๋ง ์ฌ์ฉ๋จ). fetch
controller๋ ๋ํ request์ redirect mode๊ฐ
"manual"์ผ ๋ ๋ค์ ์๋ ๋ฆฌ๋ค์ด๋ ํธ ์ฒ๋ฆฌ์๋ ์ฌ์ฉ๋๋ค.
๊ฐ์ฌ์ ๊ธ
๊ฐ์ฌํฉ๋๋ค: Adam Barth, Adam Lavin, Alan Jeffrey, Alexey Proskuryakov, Andreas Kling, Andrรฉs Gutiรฉrrez, Andrew Sutherland, Andrew Williams, รngel Gonzรกlez, Anssi Kostiainen, Arkadiusz Michalski, Arne Johannessen, Artem Skoretskiy, Arthur Barstow, Arthur Sonzogni, Asanka Herath, Axel Rauschmayer, Ben Kelly, Benjamin Gruenbaum, Benjamin Hawkes-Lewis, Benjamin VanderSloot, Bert Bos, Bjรถrn Hรถhrmann, Boris Zbarsky, Brad Hill, Brad Porter, Bryan Smith, Caitlin Potter, Cameron McCormack, Carlo Cannas, ็ฝไธ็ฅ (Cheng-You Bai), Chirag S Kumar, Chris Needham, Chris Rebert, Clement Pellerin, Collin Jackson, Daniel Robertson, Daniel Veditz, Dave Tapuska, David Benjamin, David Hรฅsรคther, David Orchard, Dean Jackson, Devdatta Akhawe, Domenic Denicola, Dominic Farolino, Dominique Hazaรซl-Massieux, Doug Turner, Douglas Creager, Eero Hรคkkinen, Ehsan Akhgari, Emily Stark, Eric Lawrence, Eric Orth, Farel Hanafi, Feng Yu, Franรงois Marier, Frank Ellerman, Frederick Hirsch, Frederik Braun, Gary Blackwood, Gavin Carothers, Glenn Maynard, Graham Klyne, Gregory Terzian, Guohui Deng(้ๅฝ่พ), Hal Lockhart, Hallvord R. M. Steen, Harris Hancock, Henri Sivonen, Henry Story, Hiroshige Hayashizaki, Honza Bambas, Ian Hickson, Ilya Grigorik, isonmad, Jake Archibald, James Graham, Jamie Mansfield, Janusz Majnert, Jeena Lee, Jeff Carpenter, Jeff Hodges, Jeffrey Yasskin, Jensen Chappell, Jeremy Roman, Jesse M. Heines, Jianjun Chen, Jinho Bang, Jochen Eisinger, John Wilander, Jonas Sicking, Jonathan Kingston, Jonathan Watt, ์ต์ข ์ฐฌ (Jongchan Choi), Jordan Stephens, Jรถrn Zaefferer, Joseph Pecoraro, Josh Matthews, jub0bs, Julian Krispel-Samsel, Julian Reschke, ์ก์ ๊ธฐ (Jungkee Song), Jussi Kalliokoski, Jxck, Kagami Sascha Rosylight, Keita Suzuki, Keith Yeung, Kenji Baheux, Lachlan Hunt, Larry Masinter, Liam Brummitt, Linus Groh, Louis Ryan, Luca Casonato, Lucas Gonze, ลukasz Anforowicz, ๅๅบท่ฑช (Kang-Hao Lu), Maciej Stachowiak, Malisa, Manfred Stock, Manish Goregaokar, Marc Silbey, Marcos Caceres, Marijn Kruisselbrink, Mark Nottingham, Mark S. Miller, Martin Dรผrst, Martin OโNeal, Martin Thomson, Matt Andrews, Matt Falkenhagen, Matt Menke, Matt Oshry, Matt Seddon, Matt Womer, Mhano Harkness, Michael Ficarra, Michael Kohler, Michaelโข Smith, Mike Pennisi, Mike West, Mohamed Zergaoui, Mohammed Zubair Ahmed, Moritz Kneilmann, Ms2ger, Nico Schlรถmer, Nicolรกs Peรฑa Moreno, Nidhi Jaju, Nikhil Marathe, Nikki Bee, Nikunj Mehta, Noam Rosenthal, Odin Hรธrthe Omdal, Olli Pettay, Ondลej ลฝรกra, O. Opsec, Patrick Meenan, Perry Jiang, Philip Jรคgenstedt, R. Auburn, Raphael Kubo da Costa, Robert Linder, Rondinelly, Rory Hewitt, Ross A. Baker, Ryan Sleevi, Sam Atkins, Samy Kamkar, Sรฉbastien Cevey, Sendil Kumar N, Shao-xuan Kang, Sharath Udupa, Shivakumar Jagalur Matt, Shivani Sharma, Sigbjรธrn Finne, Simon Pieters, Simon Sapin, Simon Wรผlker, Srirama Chandra Sekhar Mogali, Stephan Paul, Steven Salat, Sunava Dutta, Surya Ismail, Tab Atkins-Bittner, Takashi Toyoshima, ๅ้ๅๅฒ (Takeshi Yoshino), Thomas Roessler, Thomas Steiner, Thomas Wisniewski, Tiancheng "Timothy" Gu, Tobie Langel, Tom Schuster, Tomรกs Aparicio, triple-underscore, ไฟๅๆฏ (Tsuyoshi Horo), Tyler Close, Ujjwal Sharma, Vignesh Shanmugam, Vladimir Dzhuvinov, Wayne Carr, Xabier Rodrรญguez, Yehuda Katz, Yoav Weiss, Yoshisato Yanagisawa, Youenn Fablet, Yoichi Osato, ํ้่ฃ (Yutaka Hirano), ๊ทธ๋ฆฌ๊ณ Zhenbin Xu ๋ชจ๋์๊ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
์ด ํ์ค์ Anne van Kesteren (Apple, annevk@annevk.nl)๊ฐ ์์ฑํ์ต๋๋ค.
์ง์ ์ฌ์ฐ๊ถ
Copyright ยฉ WHATWG (Apple, Google, Mozilla, Microsoft). ์ด ๋ฌธ์๋ ํฌ๋ฆฌ์์ดํฐ๋ธ ์ปค๋จผ์ฆ ์ ์์ํ์ 4.0 ๊ตญ์ ๋ผ์ด์ ์ค๋ก ์ ๊ณต๋ฉ๋๋ค. ์ผ๋ถ๊ฐ ์์ค ์ฝ๋์ ํฌํจ๋๋ ๊ฒฝ์ฐ, ํด๋น ์์ค ์ฝ๋ ๋ถ๋ถ์ BSD 3-Clause License๋ก ์ ๊ณต๋ฉ๋๋ค.
์ด ๋ฌธ์๋ ํํ ํ์ค์ ๋๋ค. ํนํ ๊ฒํ ๋ฒ์ ์ ๊ด์ฌ ์์ผ์ ๋ถ๋ค์ ํํ ํ์ค ๊ฒํ ์ด์์ ์ฐธ์กฐํ์ธ์.