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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
5.1k
XHTMLが残したもの
yosuke_furukawa
PRO
2
900
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
430
デザインシステムが必須の時代に
yosuke_furukawa
PRO
2
320
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
10
5.4k
Welcome JSConf.jp 2024
yosuke_furukawa
PRO
1
4.9k
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
380
Removing Corepack
yosuke_furukawa
PRO
9
2k
JavaScript Runtime とはなにか
yosuke_furukawa
PRO
15
3.2k
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
450
すこし踏み込む CancellationToken
htkym
2
1.6k
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.4k
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
FreeBSDでZabbixを動かす
kenkino
0
360
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
140
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
760
APNsからLive Activityを開始する話
yumnumm
0
150
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
350
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
280
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
150
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
WCS-LA-2024
lcolladotor
0
850
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
720
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
490
The Language of Interfaces
destraynor
162
27k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
300
How to Talk to Developers About Accessibility
jct
2
560
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
420
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.3k
The SEO identity crisis: Don't let AI make you average
varn
0
580
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.
ൃച