Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Web技術の基本 3回目 / Introduction to Web technologies...
Search
muttan
January 05, 2018
Technology
0
240
Web技術の基本 3回目 / Introduction to Web technologies 3rd class
muttan
January 05, 2018
Tweet
Share
More Decks by muttan
See All by muttan
さわやか待ち時間LINE botを作った話 / Sawayaka LINE bot
bath_poo_
0
100
コンテナ開発入門 1回目/Introduction to Container Development 1
bath_poo_
0
140
ISUCONってなんだ / What is ISUCON
bath_poo_
0
320
Web技術の基本 8回目 / Introduction to Web technologies 8th class
bath_poo_
0
170
Web技術の基本 7回目 / Introduction to Web technologies 7th class
bath_poo_
0
150
Web技術の基本 6回目 / Introduction to Web technologies 6th class
bath_poo_
1
240
Web技術の基本 5回目 / Introduction to Web technologies 5th class
bath_poo_
0
120
Web技術の基本 4回目 / Introduction to Web technologies 4th class
bath_poo_
0
200
Web技術の基本 2回目 / Introduction to Web technologies 2nd class
bath_poo_
0
240
Other Decks in Technology
See All in Technology
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!事例のご紹介+座学②
siyuanzh09
0
110
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
240
AWS re:Invent 2024 recap in 20min / JAWSUG 千葉 2025.1.14
shimy
1
100
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
290
Alignment and Autonomy in Cybozu - 300人の開発組織でアラインメントと自律性を両立させるアジャイルな組織運営 / RSGT2025
ama_ch
1
2.4k
デジタルアイデンティティ技術 認可・ID連携・認証 応用 / 20250114-OIDF-J-EduWG-TechSWG
oidfj
2
700
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
6
55k
JuliaTokaiとJuliaLangJaの紹介 for NGK2025S
antimon2
1
130
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
1
16k
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!座学①
siyuanzh09
0
110
【Oracle Cloud ウェビナー】2025年のセキュリティ脅威を読み解く:リスクに備えるためのレジリエンスとデータ保護
oracle4engineer
PRO
1
100
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Agile that works and the tools we love
rasmusluckow
328
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing for Performance
lara
604
68k
BBQ
matthewcrist
85
9.4k
Statistics for Hackers
jakevdp
797
220k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Bash Introduction
62gerente
610
210k
The Invisible Side of Design
smashingmag
299
50k
Docker and Python
trallard
43
3.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Transcript
Webٕज़ͷجຊ 3ճ Keisuke KAMIYA
ࠓճͷςʔϚ
HTTPͰΓऔΓ͢ΔΈ - લઓ -
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2.0ͷΓͱΓ
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
HTTPϝοηʔδ • HTTP(Hyper Text Transfer Protocol) ϋΠύʔςΩετͷΓऔΓΛඪ४Խͨ͠ͷ ‣ ొ1990 όʔδϣϯ
ొ ؆୯ͳઆ໌ )551 ࣌(&5͔͠ແ͔ͬͨ )551 1045ͳͲ (&5Ҏ֎ͷϝιου͕ొ )551 ಉ͡*1ΞυϨεͰҟͳΔυϝΠϯΛ ఏڙ͢Δ)PTUϔομʔͷՃ )551 ετϦʔϜͷՃ
HTTPϝοηʔδ • HTTPͰ, Webϒϥβ(ΫϥΠΞϯτ)͕ཁٻΛૹΓ, Webαʔό(αʔό)͕ͦͷཁٻʹؔͯ͠ԠΛฦ͢ͱ͍ ͏ΓऔΓΛ܁Γฦ͍ͯ͠Δ ‣ HTTPϝοηʔδͱݺΕΔσʔλΛૹड৴͍ͯ͠Δ ཁٻ(HTTP request)
Ԡ(HTTP response) HTTPͷόʔδϣϯ, ͍ํʹ߹ΘͤΒΕΔ. (HTTP/2.0ͱHTTP/1.1 ͳΒHTTP/1.1Λ༻)
HTTPϝοηʔδ • HTTPϝοηʔδ2छྨଘࡏ͢Δ ‣ HTTPϦΫΤετ Webϒϥβ͔Βͷཁٻ ‣ HTTPϨεϙϯε WebϒϥβͷԠ HTTPϦΫΤετ
HTTPϨεϙϯε
HTTPϝοηʔδ • HTTPϝοηʔδ, ෳߦͷσʔλͰߏ͞ΕΔ ։࢝ߦʢϦΫΤετߦ εςʔλεߦʣ ϝοηʔδϔομʔ ۭߦ ϝοηʔδϘσΟ 1ߦͷΈ
ෳߦՄ 1ߦͷΈ ෳߦՄ ֤߲CR+LFͰ۠ΒΕΔ
HTTPϝοηʔδ • HTTPϝοηʔδ, ෳߦͷσʔλͰߏ͞ΕΔ ։࢝ߦ ϘσΟ https://developer.mozilla.org/ja/docs/Web/HTTP/Messages#HTTP_RequestsΑΓҾ༻ HTTPϦΫΤετͷྫ
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
HTTPϦΫΤετ/HTTPϨεϙϯε • HTTPϝοηʔδ2छྨଘࡏ͢Δ ‣ HTTPϦΫΤετ Webϒϥβ͔Βͷཁٻ ‣ HTTPϨεϙϯε WebϒϥβͷԠ HTTPϦΫΤετ
HTTPϨεϙϯε
HTTPϦΫΤετ
HTTPϦΫΤετ • HTTPϦΫΤετ 3ͭͷϝοηʔδͰߏ͞Ε͍ͯΔ 1. ϦΫΤετߦ Webαʔόʹରͯ͠ͲͷΑ͏ͳॲཧΛཁٻ͢Δ͔ 2. ϝοηʔδϔομ Webϒϥβͷछྨόʔδϣϯ,
σʔλܗࣜͳͲ 3. ϝοηʔδϘσΟ ϑΥʔϜʹೖྗ͞ΕͨσʔλͳͲͷσʔλ
HTTPϦΫΤετʢϦΫΤετߦʣ • ϦΫΤετߦ ใΛऔಘ͍ͨ͠, ใΛૹ৴͍ͨ͠ͳͲͷαʔόʹର ͯ͠ͷϦΫΤετΛهड़. ҎԼͷ3ͭΛهࡌ ‣ HTTPϝιου ‣
ϦΫΤετର ‣ HTTPόʔδϣϯ
HTTPϦΫΤετʢϦΫΤετߦʣ • HTTPϝιου ࣮ߦ͢ΔΞΫγϣϯΛද͢ಈࢺ(GET, POST, PUT, etc..) ·ͨ, ໊ࢺ(Head, Option)Λࢦఆ
ॲཧ )551ϝιου $36%ૢ࡞ ొ 1045 $3&"5& औಘ (&5 3&"% ߋ৽ 165 61%"5& আ %&-&5& %&-&5&
HTTPϦΫΤετʢϦΫΤετߦʣ • ϦΫΤετର ϦΫΤετରΛࢦఆ. ௨ৗURLͰࢦఆ͢Δ •
HTTPόʔδϣϯ HTTPͷόʔδϣϯʢͦΕͦ͏ʣ POST / HTTP 1.1 GET /background.png HTTP/1.0 HEAD /test.html?query=alibaba HTTP/1.1 OPTIONS /anypage.html HTTP/1.0 ϓϩτίϧ, ϙʔτ, υϝΠϯϦΫΤετ͔Β໌Β͔ʹ͞ΕΔ
HTTPϦΫΤετ • HTTPϦΫΤετ 3ͭͷϝοηʔδͰߏ͞Ε͍ͯΔ 1. ϦΫΤετߦ Webαʔόʹରͯ͠ͲͷΑ͏ͳॲཧΛཁٻ͢Δ͔ 2. ϝοηʔδϔομ Webϒϥβͷछྨόʔδϣϯ,
σʔλܗࣜͳͲ 3. ϝοηʔδϘσΟ ϑΥʔϜʹೖྗ͞ΕͨσʔλͳͲͷσʔλ
HTTPϦΫΤετʢϝοηʔδϔομʣ • ϝοηʔδϔομ Webϒϥβͷछྨ, σʔλλΠϓ, σʔλͷѹॖํ๏, ༻ݴޠͳͲΛ͑Δ ‣ Ұൠϔομ(General Headers)
ϝοηʔδશମʹద༻͞ΕΔ(Via, Date, ConnectionͳͲ) ‣ ϦΫΤετϔομ(Request Headers) User-Agent, Accept-Type, ࢦఆ͢ΔͱϦΫΤετΛมߋ͢Δͷ(Accept- Language), ঢ়گΛࣔ͢ͷ(Referer), ݅Λ༩͑Δͷ(If-None) ‣ ΤϯςΟςΟϔομ(Entity Headers) ϘσΟʹద༻͞ΕΔ(Content-length), ϘσΟ͕ແ͍߹ΤϯςΟςΟ ϔομՃ͞Εͳ͍
HTTPϦΫΤετʢϝοηʔδϔομʣ • Ұൠϔομ(General Headers) ໊শ ༰ $POOFDUJPO ଓঢ়ଶʹؔ͢Δ௨ʢݱࡏͷτϥ ϯβΫγϣϯ͕ऴྃͨ͋͠ͱίω ΫγϣϯΛอ࣋͢Δ͔Ͳ͏͔ʣ
%BUF )551ϝοηʔδ͕ ࡞͞Εͨ࣌ 6QHSBEF )551ͷόʔδϣϯΛΞοϓσʔτ͢ ΔΑ͏ʹཁٻ
HTTPϦΫΤετʢϝοηʔδϔομʣ • ϦΫΤετϔομ(Request Headers) ໊শ ༰ )PTU ϦΫΤετઌͷαʔό໊ 3FGFSFS લʹ๚Ε͍ͯͨ8FCϖʔδͷ63-
6TFS"HFOU 8FCϒϥβͷݻ༗ใ Host: developer.mozilla.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0 Referer: https://developer.mozilla.org/testpage.html ϦΫΤετϔομͷྫ
HTTPϦΫΤετʢϝοηʔδϔομʣ • ΤϯςΟςΟϔομϑΟʔϧυ(Entity Headers) ໊শ ༰ "MMPX ར༻Մೳͳ)551ϝιουҰཡ $POUFOU&ODPEJOH ίϯςϯπͷΤϯίʔυ
$POUFOU-BOHVBHF ίϯςϯπͷ༻ݴޠ $POUFOU-FOHUI ίϯςϯπͷ͞ $POUFOU5ZQF ίϯςϯπͷछྨʢςΩετ ը૾ʣ &YQJSFT ίϯςϯπͷ༗ޮظݶ -BTU.PEJpFE ίϯςϯπͷ࠷ऴߋ৽࣌ࠁ
HTTPϦΫΤετ • HTTPϦΫΤετ 3ͭͷϝοηʔδͰߏ͞Ε͍ͯΔ 1. ϦΫΤετߦ Webαʔόʹରͯ͠ͲͷΑ͏ͳॲཧΛཁٻ͢Δ͔ 2. ϝοηʔδϔομ Webϒϥβͷछྨόʔδϣϯ,
σʔλܗࣜͳͲ 3. ϝοηʔδϘσΟ ϑΥʔϜʹೖྗ͞ΕͨσʔλͳͲͷσʔλ
HTTPϦΫΤετʢϘσΟʣ • ϘσΟ WebαʔόʹૹΔσʔλ. ۭ(empty)ͳ߹͋Δ ‣ GETHEAD, DELETE, OPTIONSͳͲͷ߹, ௨ৗϘ
σΟۭͱͳΔ
HTTPϦΫΤετʢϘσΟʣ • େ͖͘2ͭʹྨ ‣ ୯ҰϦιʔεϘσΟ 1ͭͷϑΝΠϧͰߏ. Content-TypeͱContent- Lengthͷ2छྨͰߏ͞ΕΔ ‣ ෳϦιʔεϘσΟ
ϑΥʔϜͷ༰ʢෳͷσʔλʣΛૹΔΑ͏ͳ࣌ʹ ༻͍ΒΕΔ
HTTPϦΫΤετʢϝοηʔδϔομʣ • HTTPϔομͷྫ https://developer.mozilla.org/ja/docs/Web/HTTP/Messages#HTTP_RequestsΑΓҾ༻ ։࢝ߦ ϘσΟ ۭߦ ۭߦϔομͷऴΘΓΛΒͤΔ
HTTPϨεϙϯε
HTTPϨεϙϯε • HTTPϨεϙϯε 3ͭͷϝοηʔδͰߏ͞Ε͍ͯΔ 1. εςʔλεߦ ΫϥΠΞϯτʹॲཧ݁ՌΛΒͤΔ 2. ϝοηʔδϔομ Webϒϥβͷछྨόʔδϣϯ,
σʔλܗࣜͳͲ 3. ϝοηʔδϘσΟ HTMLը૾ͳͲͷσʔλ
HTTPϨεϙϯεʢεςʔλεߦʣ • ϦΫΤετߦ αʔόͰͷॲཧͷ݁ՌΛ͑Δ. ҎԼͷ3ͭͷใͰ ߏ͞Ε͍ͯΔ 1. ϓϩτίϧόʔδϣϯ 2. εςʔλείʔυ
3. εςʔλεจࣈྻ
HTTPϨεϙϯεʢεςʔλεߦʣ • ϓϩτίϧόʔδϣϯ ௨ৗHTTP/1.1ͱͳΔ • εςʔλείʔυ ϦΫΤετ͕ޭ͔ͨ͠Ͳ͏͔Λฦ͢ εςʔλείʔυ ҙຯ
ϦΫΤετޭ YY ϦμΠϨΫτ ېࢭ͞Ε͍ͯΔ ݟ͔ͭΒͳ͔ͬͨ
HTTPϨεϙϯεʢεςʔλεߦʣ • εςʔλεจࣈྻ εςʔλεΛද͍͢จࣈྻͰ, ਓ͕ؒHTTPϝοηʔ δΛཧղ͢ΔͷΛॿ͚Δ ‣ HTTPϨεϙϯεͷεςʔλεߦҎԼͷΑ͏ʹͳΔ )551/PU'PVOE εςʔλεߦͷྫ
HTTPϨεϙϯε • HTTPϨεϙϯε 3ͭͷϝοηʔδͰߏ͞Ε͍ͯΔ 1. εςʔλεߦ ΫϥΠΞϯτʹॲཧ݁ՌΛΒͤΔ 2. ϝοηʔδϔομ Webϒϥβͷछྨόʔδϣϯ,
σʔλܗࣜͳͲ 3. ϝοηʔδϘσΟ HTMLը૾ͳͲͷσʔλ
HTTPϨεϙϯεʢϝοηʔδϔομʣ • ϝοηʔδϔομ Webϒϥβͷछྨ, σʔλλΠϓ, σʔλͷѹॖํ๏, ༻ݴޠͳͲΛ͑Δ ‣ Ұൠϔομ(General Headers)
ϝοηʔδશମʹద༻͞ΕΔ(ViaͳͲ) ‣ ϦΫΤετϔομ(Request Headers) Vary, Accept-RangesͳͲεςʔλεߦͰΘΒͳ͍αʔόͷՃใΛ Ճ͢Δ ‣ ΤϯςΟςΟϔομ(Entity Headers) ϘσΟʹద༻͞ΕΔ(Content-length), ϘσΟ͕ແ͍߹ΤϯςΟςΟ ϔομՃ͞Εͳ͍
HTTPϨεϙϯε • HTTPϨεϙϯε 3ͭͷϝοηʔδͰߏ͞Ε͍ͯΔ 1. εςʔλεߦ ΫϥΠΞϯτʹॲཧ݁ՌΛΒͤΔ 2. ϝοηʔδϔομ Webϒϥβͷछྨόʔδϣϯ,
σʔλܗࣜͳͲ 3. ϝοηʔδϘσΟ HTMLը૾ͳͲͷσʔλ
HTTPϦΫΤετʢϘσΟʣ • ϘσΟ HTMLը૾ͳͲͷσʔλ ‣ 201204ͱ͍͏Ϩεϙϯείʔυͷ߹, ϘσΟΛ ࣋ͨͳ͍
HTTPϦΫΤετʢϘσΟʣ • େ͖͘3छྨʹྨ͞ΕΔ ‣ αΠζ͕໌͍ͯ͠Δ୯ҰϦιʔεͷϘσΟ 1ͭͷϑΝΠϧͰߏ. Content-TypeͱContent-Lengthͷ2छ ྨͰߏ͞ΕΔ ‣ αΠζ͕ෆ໌ͳ୯ҰϦιʔεͷϘσΟ
σʔλΛνϟϯΫʢմʣʹ͚ͯૹ৴. Transfer-EncodingΛ chunkedʹͯ͠ૹ৴͢Δ ‣ ෳϦιʔεͷϘσΟ ൺֱత·Ε
Webϖʔδ͕දࣔ͞ΕΔྲྀΕ • Ϩεϙϯεϔομͷྫ https://developer.mozilla.org/ja/docs/Web/HTTP/Messages#HTTP_RequestsΑΓҾ༻ ։࢝ߦ ϘσΟ ۭߦ ۭߦϔομͷऴΘΓΛΒͤΔ
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
• HTTPϦΫΤετΛ༻͍ͯ۩ମతͳཁٻ༰Λ͍͑ͯ ΔͷHTTPϝιου HTTPϝιου ϝιουͷྫ • GET ίϯςϯπΛऔಘ͍ͨ͠߹ • POST
σʔλΛWebαʔόʹૹ৴͍ͨ͠߹ ଞͷϝιουRESTͷ͋ͨΓͰ͓ͨ͠ͷͱ͔
HTTPϝιου ϝιου໊ આ໌ )&"% )551ϔομʔͷใͷΈΛऔಘ͢Δ σʔλͷߋ৽࣌σʔλαΠζͷΈ ΛΓ͍ͨ߹ʹ༻ (&5 )5.-ϑΝΠϧը૾ͱ͍ͬͨσʔλ Λऔಘ͢Δ߹ʹ༻
1045 ύεϫʔυͷΑ͏ͳσʔλΛૹ৴͢Δ ߹ʹ༻ 165 σʔλΛΞοϓϩʔυ͢ΔͨΊʹ༻ ଓઌͷσʔλΛॻ͖͑Δ VQEBUF ͢Δ͜ͱ͕Մೳ
HTTPϝιου ϝιου໊ આ໌ %&-&5& ࢦఆͨ͠σʔλΛআ͢ΔͨΊʹ༻ 165ͱڞʹ༻੍͕ݶ͞Ε͍ͯΔ߹ ͕ଟ͍ $0//&$5 8FCαʔόʹଓ͢Δ·Ͱʹผͷαʔ όΛதܧ͢Δ߹ʹ༻
015*0/4 ར༻Ͱ͖Δ)551ϝιουΛ͍߹Θ ͤΔͨΊʹར༻͢Δ 53"$& ϒϥβͱαʔόͷܦ࿏ΛνΣοΫ͢ Δ߹ʹ༻͢Δ PUT, DELETE, CONNECT, TRACEѱ༻Λ͙ͨΊ੍ݶ͞Ε͍ͯΔ͜ͱ͕ଟ͍
HTTPϝιου • GETͱPOSTզʑೃછΈͷ͋Δϝιου͕ͩ, ͲͷΑ͏ͳҧ͍ ͕͋Δͷ͔ʁ ‣ GETύϥϝʔλΛURLͷޙΖʹՃ͢Δ ‣ Կ͔ใΛಘΔ࣌ʹ͏͜ͱ͕ଟ͍ ‣
ϒοΫϚʔΫ͕Մೳ ‣ σʔλྔʹ੍ݶΞϦ ‣ POSTύϥϝʔλΛϝοηʔδϘσΟʹؚΊΔ ‣ Կ͔ใΛొ͢Δ࣌ʹ͏͜ͱ͕ଟ͍ ‣ σʔλྔ͕ଟ͍, όΠφϦσʔλΛૹΔ߹ ‣ ύεϫʔυೝূʹΘΕΔ͜ͱ͕ଟ͍ ࢀߟɿhttps://www.w3schools.com/tags/ref_httpmethods.asp
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
εςʔλείʔυ • εςʔλείʔυ HTTPϨεϙϯεʹؚ·Ε͍ͯΔ, WebαʔόͰͷॲཧ݁ ՌΛද͢3ܻͷࣈ ‣ ਖ਼ৗऴྃͨ͠߹ͷεςʔλείʔυ200 aiko.comΛݟʹߦͬͨͱ͖ͷεςʔλείʔυ (chromeͷΠϯεϖΫλେมศརͰ͢)
εςʔλείʔυ • εςʔλείʔυͷྨ ‣ 100൪ HTTPϦΫΤετΛॲཧதͰ͋Δ͜ͱΛ௨͢Δ. Webαʔό͕ σʔλड͚ೖΕՄೳ͔ͷ֬ೝͰΘΕΔ ‣ 200൪
HTTPϦΫΤετʹରͯ͠, ਖ਼ৗʹॲཧ͕ऴྃͨ͜͠ͱΛ௨͢Δ ‣ 300൪ సૹॲཧͳͲWebϒϥβଆͰՃͷॲཧ͕ඞཁͰ͋Δ͜ͱΛ ௨͢ΔʢϦμΠϨΫτͳͲʣ
εςʔλείʔυ ൪߸ εςʔλεจࣈྻ ҙຯ $POUJOVF ͦΕ·Ͱͷશͯʹ͕ͳ͍ͨΊ Ϧ ΫΤετΛܧଓͯ͠Α͍
0, ϦΫΤετ͕ਖ਼ৗʹडཧ͞Εͨ .PWFE1BSNBOFOUMZ ίϯςϯπ͕Ҡಈͨ͠ 'PVOE Ұ࣌తʹҠಈʢผͷॴͰൃݟʣ ͞Εͨ /PU.PEJpFE ϦΫΤετ͞Εͨίϯςϯπ͕ະߋ৽ Ͱ͋ΔʢΩϟογϡΛ͏ʣ
εςʔλείʔυ • εςʔλείʔυͷྨ ‣ 400൪ ΫϥΠΞϯτଆͷΤϥʔͰ͋Δ͜ͱΛ௨͢Δ. ࢦఆͨ͠Ϧ ιʔε͕ଘࡏ͠ͳ͍, ݖݶ͕ͳ͍߹ͳͲͰ400൪͕௨ ͞ΕΔ
‣ 500൪ WebαʔόͷΤϥʔΛ௨͢Δ. ߴෛՙͳঢ়ଶͰԠΛฦ͢ ͜ͱ͕Ͱ͖ͳ͍߹, Ұ࣌తʹར༻Ͱ͖ͳ͍߹ʹ500൪ ͕௨͞ΕΔ
εςʔλείʔυ ൪߸ εςʔλεจࣈྻ ҙຯ #BE3FRVFTU ෆਖ਼ͳϦΫΤετ 'PSCJEEFO ΫϥΠΞϯτʹίϯςϯπͷΞΫη
εݖ͕ͳ͍ /PU'PVOE ϦΫΤετ͞Εͨίϯςϯπ͕ະݕग़ Ͱ͋Δ *OUFSOBM4FSWFS&SSPS ϦΫΤετॲཧதʹαʔό෦ͰΤ ϥʔ͕ൃੜͨ͜͠ͱΛΒͤΔ 4FSWJDF6OBWBJMBCMF ΞΫηεूத ϝϯςφϯεͰҰ࣌ తʹར༻ෆՄೳͰ͋Δ͜ͱΛΒͤΔ
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
TCPʹΑΔσʔλ௨৴ ૹ৴ࣦഊ ࠶ૹ৴ "$,Λૹ৴ ࠶ૹ੍ޚ ॱং੍ޚ ॱং͕ ೖΕସΘΔ γʔέϯε൪߸Λجʹ σʔλΛΈཱͯ
TCP͕͍ͬͯΔ͜ͱ
TCPʹΑΔσʔλ௨৴ • HTTPͷσʔλͷΓऔΓΛߦͳ͏ͷ, TCP(Transmission Control Protocol)ͷ • TCP௨৴૬खͱͷཧతͳ௨৴࿏Ͱ͋ΔίωΫγϣϯΛཱ֬ͨ͠ ޙ, ௨৴Λ։࢝͢Δ
‣ 3ճͷΓऔΓʢ3ΣΠϋϯυγΣΠΫʣΛߦͬͯίωΫγϣϯ Λཱ֬͢Δ - ΫϥΠΞϯτ͔Βͷଓཁٻ(SYN) - ΫϥΠΞϯτͷ֬ೝԠ, αʔό͔Βͷଓཁٻ(SYN+ACK) - αʔόʹରͯ֬͠ೝԠ(ACK)
TCPʹΑΔσʔλ௨৴ • ΫϥΠΞϯτ͔Βͷଓཁٻ(SYN) ΫϥΠΞϯτ͔Βαʔόʹରͯ͠, ଓΛཁٻ͢ΔͨΊ ͷSYNύέοτΛૹΔ. ‣ TCPϔομͷதʹSYNϑϥάΛཱͯͨͷΛૹΔ
TCPʹΑΔσʔλ௨৴ • ΫϥΠΞϯτͷ֬ೝԠ&αʔό͔Βͷଓཁٻ ΫϥΠΞϯτ͔ΒͷଓཁٻΛड͚ͨαʔό, ʮଓ ཁٻͷγʔέϯε൪߸+1ʯΛACKϑϥάʹ͠, ΫϥΠΞ ϯτ֬ೝԠΛฦ͢. ͦΕͱಉ࣌ʹ, ΫϥΠΞϯτ
ଓཁٻ(SYN)Λ͓͜ͳ͏ ‣ TCPͰ, ௨৴૬ख͔Βͷ֬ೝԠΛड͚औΔ͜ͱͰ, ૹ৴ྃͨ͠ͱΈͳ͢
TCPʹΑΔσʔλ௨৴ • αʔόʹରͯ͠ͷ֬ೝԠ(ACK) αʔό͔ΒΫϥΠΞϯτͷଓཁٻʹରͯ͠, ΫϥΠ Ξϯτଆαʔό͔ΒͷSYNύέοτʹهࡌ͞Εͨγʔ έϯε൪߸+1ΛACKϑϥάͱͯ֬͠ೝԠΛߦ͏
ᶃFIN(Seq:30000) ᶄACK(Ԡ൪߸:30001) ᶆACK(Ԡ൪߸:40001) அཁٻͷૹ৴ அཁٻͷԠ அڐՄͷԠ TCPʹΑΔσʔλ௨৴ ᶃSYN(Seq:10000) ᶄSYN(Seq:20000)+ACK(Ԡ൪߸:10001) ᶅACK(Seq:20001)
ଓཁٻͷૹ৴ ଓڐՄͷԠ ଓڐՄͷԠ ଓཁٻͷૹ৴ σʔλͷૹड৴ ᶅFIN(Seq:40000) அཁٻͷૹ৴ ίωΫγϣϯͷཱ֬ ίωΫγϣϯͷஅ
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
HTTP/1.1ͷΓͱΓ • HTTP, HTTP/0.9→HTTP/1.0→HTTP/1.1→HTTP/2ͱ ਐԽ͖ͯͨ͠ ‣ ݱࡏओྲྀͳͷHTTP/1.1 όʔδϣϯ ొ ؆୯ͳઆ໌
)551 ࣌(&5͔͠ແ͔ͬͨ )551 1045ͳͲ (&5Ҏ֎ͷϝιου͕ొ )551 ಉ͡*1ΞυϨεͰҟͳΔυϝΠϯΛ ఏڙ͢Δ)PTUϔομʔͷՃ )551 ετϦʔϜͷՃ
HTTP/1.1ͷΓͱΓ • HTTP/1.11997ॳ಄ʹެ։͞Εͨ • ࠓ·Ͱʹ2վఆ͞Ε͍ͯΔ ‣ 19991݄ʹൃߦ͞ΕͨRFC2616 ‣ 20146݄ʹൃߦ͞ΕͨRFC7230 •
HTTP/1.1ͷओͳಛ࣍ͷ௨Γ ‣ HTTPΩʔϓΞϥΠϒ ‣ HTTPύΠϓϥΠϯ
HTTP/1.1ͷΓͱΓ • HTTPΩʔϓΞϥΠϒ ίωΫγϣϯΛܧଓͯ͠ར༻͢Δ͜ͱ ‣ HTTP/1.0ҎલͰ, HTTPϦΫΤετΛ͢Δͨͼʹί ωΫγϣϯཱ֬Λ͍ͯͨ͠ʢ1௨৴ͨ͠Βͦͷͨͼ ʹίωΫγϣϯΛΫϩʔζ͍ͯͨ͠ʣ ‣
ඇৗʹޮ͕ѱ͍
HTTP/1.1ͷΓͱΓ • HTTPΩʔϓΞϥΠϒ ͦͷͨΊ, HTTP/1.1Ҏ߱ͰίωΫγϣϯΛܧଓͯ͠ར༻͢Δ͜ͱ͕Մ ೳʹͳͬͨ. ίωΫγϣϯཱ֬ ϦΫΤετ Ϩεϙϯε ίωΫγϣϯஅ
ίωΫγϣϯཱ֬ ϦΫΤετ Ϩεϙϯε ίωΫγϣϯஅ ίωΫγϣϯཱ֬ ϦΫΤετ Ϩεϙϯε ϦΫΤετ Ϩεϙϯε ίωΫγϣϯஅ ඇHTTPΩʔϓΞϥΠϒ HTTPΩʔϓΞϥΠϒ
HTTP/1.1ͷΓͱΓ • HTTPύΠϓϥΠϯ ‣ HTTP, ௨ৗHTTPϨεϙϯεΛड͚औͬͨ͋ͱ࣍ͷ ϦΫΤετΛൃߦ͢Δ ‣ ωοτϫʔΫͷঢ়ଶʹΑͬͯ, ஶ͍͠Ԇ͕ൃੜ
→ HTTPϨεϙϯεΛͭ͜ͱແ͘, ෳͷHTTPϦΫ ΤετΛૹ৴͢Δ͜ͱΛՄೳʹ͢ΔػೳΛHTTPύ ΠϓϥΠϯͱ͍͏
HTTP/1.1ͷΓͱΓ • HTTPύΠϓϥΠϯ ίωΫγϣϯཱ֬ ϦΫΤετ Ϩεϙϯε ϦΫΤετ Ϩεϙϯε ίωΫγϣϯஅ ίωΫγϣϯཱ֬
ίωΫγϣϯஅ ϦΫΤετ Ϩεϙϯε ϦΫΤετ Ϩεϙϯε ϨεϙϯεΛͨͣʹ ϦΫΤετΛૹ৴͢Δ HTTP/1.0Ҏલ HTTP/1.1Ҏ߱ ࣌ؒॖ
࣍ 1. HTTPϝοηʔδ 2. HTTPϦΫΤετ/HTTPϨεϙϯε 3. HTTPϝιου 4. εςʔλείʔυ 5.
TCPʹΑΔσʔλ௨৴ 6. HTTP/1.1ͷΓͱΓ 7. HTTP/2ͷΓͱΓ
HTTP/2ͷΓͱΓ • ࣌ͱڞʹWebϖʔδෳࡶԽ͍͖ͯ͠, ը૾αΠζ εΫϦϓταΠζ͕େ͖͘ͳ͍ͬͯͬͨ • HTTP/1.1ͰύΠϓϥΠϯػೳ͕Ճ͞Ε, ଟ͘ͷσʔλ Λޮతʹసૹ͢Δ͜ͱ͕Մೳʹͳͬͨͷͷ, ύΠϓ
ϥΠϯػೳେ͖ͳΦʔόʔϔουʹͳΔ ‣ ৽ͨͳόʔδϣϯͰ͋ΔHTTP/2͕ఏҊ͞Εͨ
HTTP/2ͷΓͱΓ • HTTP/2 Googleͷ։ൃͨ͠, ௨৴ͷߴԽΛతͱ࣮ͨ͠ݧతͳ ϓϩτίϧSPDYͱ͍͏ϓϩτίϧΛϕʔεʹ࡞ͨ͠ϓ ϩτίϧ. 2015ͷ5݄ʹਖ਼ࣜͳඪ४Խ͕ͳ͞Εͨ • ࣍ͷΑ͏ͳಛ͕͋Δ
‣ ετϦʔϜʹΑΔଟॏԽ ‣ όΠφϦܗࣜͰૹΔ͜ͱͰߋͳΔ࠷దԽ͕Մೳ ‣ ϔομʔͷѹॖ ‣ αʔόϓογϡ
HTTP/2ͷΓͱΓʢετϦʔϜʹΑΔଟॏԽʣ • ετϦʔϜʹΑΔଟॏԽ ‣ HTTP/1.0Ҏલ HTTPϦΫΤετ, HTTPϨεϙϯεΛͬͨޙʹૹ৴ ՄೳͱͳΔ ‣ HTTP/1.1
ύΠϓϥΠϯʹΑΓ, ಉ࣌ʹෳͷϦΫΤετΛૹ৴͢ Δ͜ͱ͕Մೳʹͳͬͨ → ʮHTTPϦΫΤετͷॱ൪ͰϨεϙϯεΛฦ͢ʯͱ͍ ͏੍͕͍͍ͭͯͨ
HTTP/2ͷΓͱΓʢετϦʔϜʹΑΔଟॏԽʣ • Webϒϥβ͔ΒෳͷϦΫΤετ͕ඈΜͰ͖ͯ, ͋ Δ1ͭͷHTTPϨεϙϯεͷॲཧʹ͕͔͔࣌ؒΔ߹, શ ͯͷϨεϙϯελΠϜ͕૿Ճ͢Δͱ͍͏͕͋ͬͨ ‣ ͜ͷΛղܾ͢ΔͨΊ, 1ͭͷଓ্ʹετϦʔϜ
ͱݺΕΔԾతͳํγʔέϯεΛ࡞ͬͯରࡦ
HTTP/2ͷΓͱΓʢετϦʔϜʹΑΔଟॏԽʣ HTTP/2ଓʢ1ίωΫγϣϯʣ ετϦʔϜᶃ ετϦʔϜᶄ ετϦʔϜᶅ ετϦʔϜᶆ ϦΫΤετ Ϩεϙϯε ϦΫΤετ Ϩεϙϯε
ϦΫΤετ Ϩεϙϯε ϦΫΤετ Ϩεϙϯε
HTTP/2ͷΓͱΓʢετϦʔϜʹΑΔଟॏԽʣ ϦΫΤετᶃ Ϩεϙϯεᶃ Ϩεϙϯεᶄ HTTPύΠϓϥΠϯ ετϦʔϜʹΑΔଟॏԽ ࣌ؒॖ ϦΫΤετᶄ ϦΫΤετᶅ ॲཧͪ
Ϩεϙϯεᶅ ϦΫΤετᶃ ϦΫΤετᶄ ϦΫΤετᶅ Ϩεϙϯεᶃ Ϩεϙϯεᶄ Ϩεϙϯεᶅ ϦΫΤετͷॱ൪Ͱ ϨεϙϯεΛฦ͢ඞཁ͋Γ ετϦʔϜ͕ҟͳΕ Ϩεϙϯεͷॱ൪ ੍ݶ͞Εͳ͍
༻ૉࡐ, ࢀߟϦϯΫ
༻ૉࡐ, ࢀߟϦϯΫ • ͍Β͢ͱ • k-tamura/cocha-icons https://github.com/k-tamura/cocha-icons • HTTPϝοηʔδ https://developer.mozilla.org/ja/docs/Web/HTTP/
Messages • HTTP Ϩεϙϯεεςʔλείʔυ https://developer.mozilla.org/ja/docs/Web/HTTP/ Status
༻ૉࡐ, ࢀߟϦϯΫ • ʮεϦʔΣΠϋϯυγΣΠΫʯͷखॱɺΘ͔͍ͬͯ· ͔͢ʁ http://ascii.jp/elem/000/000/619/619702/ • HTTP/2ೖ https://techblog.yahoo.co.jp/infrastructure/http2/ introduction_to_http2/