Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
http_basics
Search
Yosuke Furukawa
PRO
February 21, 2017
Programming
1k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
http_basics
Node girls で話したhttp basics の話です
Yosuke Furukawa
PRO
February 21, 2017
More Decks by Yosuke Furukawa
See All by Yosuke Furukawa
Webの地図
yosuke_furukawa
PRO
6
4.1k
XHTMLが残したもの
yosuke_furukawa
PRO
2
680
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
400
デザインシステムが必須の時代に
yosuke_furukawa
PRO
2
280
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
10
5.3k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
4.8k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
360
Removing Corepack
yosuke_furukawa
PRO
9
2k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
3.2k
Other Decks in Programming
See All in Programming
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
220
Family mrubyの進捗
kishima
1
110
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
660
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
130
What We Talk About When We Talk About XP
m_seki
2
490
信頼性の目標を誰も求めてない
shubox
0
500
不幸な GC
chencmd
0
900
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
520
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
140
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
App Intentsのビルドプロセスを支える技術
kntkymt
0
230
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
For a Future-Friendly Web
brad_frost
183
10k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
520
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
Music & Morning Musume
bryan
47
7.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Transcript
HTTP Basics node_girls @ ੨ࢁ G’s Cafe
Twitter: @yosuke_furukawa ϦΫϧʔτςΫϊϩδʔζॴଐ γχΞιϑτΣΞΤϯδχΞ
HTTP Basics
લͷ NodeSchool ͰݴΘΕͨ ͜ͱ
͕͍͜͜͠Node.js /PEFKTͬͯॻ͍ͯΔͱOHJOYͷઃఆॻ͍ͯΔ Έ͍ͨͳؾʹͳΔΜͰ͢ΑͶʔ
yes !!! love http layer !!!! const http = require('http');
const server = http.createServer((req, res) => { res.writeHead(200); res.end('Hello World'); }); server.listen(3000, () => { console.log('listening'); });
ٯʹݴ͏ͱ /PEFKTͬͯॻ͍ͯΔͱOHJOYͷઃఆॻ͍ͯΔ Έ͍ͨͳؾʹͳΔΜͰ͢ΑͶʔ )551ͷϨΠϠΛֶͿνϟϯεʂʂʂʂ
Node HTTP Basics
ͦͦ HTTP ͱ?? GET /hello.txt HTTP/1.1 User-Agent: curl/7.16.3 Host: www.example.com
Accept-Language: en, mi HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Accept-Ranges: bytes Content-Length: 51 Vary: Accept-Encoding Content-Type: text/plain Hello World! My payload includes a trailing CRLF. 3FRVFTU 3FTQPOTF
ͦͦ HTTP ͱ?? GET /hello.txt HTTP/1.1 User-Agent: curl/7.16.3 Host: www.example.com
Accept-Language: en, mi HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Accept-Ranges: bytes Content-Length: 51 Vary: Accept-Encoding Content-Type: text/plain Hello World! My payload includes a trailing CRLF. 3FRVFTU 3FTQPOTF 3FRVFTU-JOF શͯͷݩɺϝιουɺύεɺϓϩτ ίϧόʔδϣϯͰهड़ 3FRVFTU)FBEFS ϦΫΤετʹର͢Δϝλใ
ͦͦ HTTP ͱ?? GET /hello.txt HTTP/1.1 User-Agent: curl/7.16.3 Host: www.example.com
Accept-Language: en, mi HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Accept-Ranges: bytes Content-Length: 51 Vary: Accept-Encoding Content-Type: text/plain Hello World! My payload includes a trailing CRLF. 3FRVFTU 3FTQPOTF 3FTQPOTF-JOF ϓϩτίϧόʔδϣϯͱTUBUVTDPEF 3FTQPOTF)FBEFS ϨεϙϯεͷϝλใɺαΠζΒ ίϯςϯτλΠϓΒɻ 3FTQPOTF#PEZ Ϩεϙϯεͷຊମɺ͜͜ʹ)5.- +40/ͳͲ͕Δ
HTTP TCP ͷ্ʹ͋ΔΞϓϦ έʔγϣϯϨΠϠͷϓϩτίϧ http://www.linuxacademy.ne.jp/lablog/infrastructure/155/
͡Ό͋TCPͷϨΠϠͰHTTP ࡞ͬͯΈͨΒ͏গ͠ཧղ͕ ਂ·ΔͷͰʁ
TCPͷϞδϡʔϧnetΛ͏ const net = require('net'); const CRLF = '\r\n'; const
server = net.createServer((connection) => { console.log('connect!!'); connection.write('HTTP/1.1 200 OK' + CRLF); connection.write('Set-Cookie: test=123' + CRLF); connection.write(CRLF); connection.write('Hello world'); connection.end(); }); server.listen(3000, () => { console.log('listen on 3000'); });
ϒϥβͰݟͯΈΔ
Ͱ͖ͨ
Response header Λฦͯ͠ΈΔ const net = require('net'); const CRLF =
'\r\n'; const server = net.createServer((connection) => { console.log('connect!!'); connection.write('HTTP/1.1 200 OK' + CRLF); connection.write('Set-Cookie: test=123' + CRLF); connection.write(CRLF); connection.write('Hello world'); connection.end(); }); server.listen(3000, () => { console.log('listen on 3000'); });
ϒϥβͰݟͯΈΔ
Ͱ͖ͨ
TCPͷϞδϡʔϧnetΛ͏ const net = require('net'); const CRLF = '\r\n'; const
server = net.createServer((connection) => { console.log('connect!!'); connection.write('HTTP/1.1 200 OK' + CRLF); connection.write('Set-Cookie: test=123' + CRLF); connection.write(CRLF); connection.write('Hello world'); connection.end(); }); server.listen(3000, () => { console.log('listen on 3000'); }); 3FTQPOTF-JOF ϓϩτίϧόʔδϣϯͱTUBUVTDPEF 3FTQPOTF)FBEFS SFTQPOTFͷϝλใ 3FTQPOTF#PEZ SFTQPOTFͷ༰
ϚδϨε͢Δͱ
ͦΜͳ͜ͱ͠ͳ͍ Use express !!!! const app = express(); app.use('/static', express.static());
app.use('/foo', (req, res, next) => { res.send('foo'); }); app.use('/bar', (req, res, next) => { res.send('foo'); });
ͨͩHTTP͕Ͳ͏ͳͬͯΔ͔Λ ͓ͬͯ͘͜ͱॏཁ GET /hello.txt HTTP/1.1 User-Agent: curl/7.16.3 Host: www.example.com Accept-Language:
en, mi HTTP/1.1 200 OK Date: Mon, 27 Jul 2009 12:28:53 GMT Server: Apache Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT ETag: "34aa387-d-1568eb00" Accept-Ranges: bytes Content-Length: 51 Vary: Accept-Encoding Content-Type: text/plain Hello World! My payload includes a trailing CRLF.
ΞϓϦέʔγϣϯϨΠϠͰࣄ ͍ͯ͠ΔͱΕ͕ͪ
தͰಈ͍ͯΔ͕Θ͔Δͱɺ ͜͏͍͏͜ͱ͕Ͱ͖Δ DEMO
HTTPϨΠϠͷಈ͖webͷ ಈ͖ͦͷͷɺڵຯΛ࣋ͱ͏ɺ ωοτϫʔΫϨΠϠʹɻ
Thank you.
ൃച