{"id":890,"date":"2026-05-20T09:52:25","date_gmt":"2026-05-20T01:52:25","guid":{"rendered":"https:\/\/junai.ai\/blog\/nodejs-http-server-raw-12\/"},"modified":"2026-05-20T09:52:25","modified_gmt":"2026-05-20T01:52:25","slug":"nodejs-http-server-raw-12","status":"publish","type":"post","link":"https:\/\/junai.ai\/blog\/nodejs-http-server-raw-12\/","title":{"rendered":"HTTP \uc11c\ubc84 \uc9c1\uc811 \ub9cc\ub4e4\uae30 \u2014 http \ubaa8\ub4c8 \uae30\ucd08"},"content":{"rendered":"\n<!-- WordPress REST API \ubc1c\ud589\uc6a9 HTML (\uc790\ub3d9 \uc0dd\uc131) -->\n<!-- WP-FEATURED-MEDIA-ID: 836 -->\n<div style=\"max-width:800px;margin:0 auto;\">\n<style>\n:root {--color-primary:#059669;--color-accent:#10b981;--color-bg:#fafbfc;--color-bg-card:#fff;--color-text:#1a202c;--color-text-muted:#64748b;--hero-start:#064e3b;--hero-end:#059669;}\n*{box-sizing:border-box;}\n.container{max-width:760px;margin:0 auto;padding:0 24px 80px;}\n.hero{background:linear-gradient(135deg,var(--hero-start) 0%,var(--hero-end) 100%);color:#fff;padding:80px 24px 60px;text-align:center;}\n.hero .eyebrow{display:inline-block;font-size:14px;color:#6ee7b7;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:14px;}\n.hero h1{font-size:36px;margin:0 0 16px;line-height:1.3;font-weight:800;}\n.hero p{color:#d1fae5;font-size:18px;max-width:640px;margin:0 auto;line-height:1.6;}\n.hero img{width:100%;max-width:640px;height:auto;margin:32px auto 0;border-radius:10px;display:block;}\narticle{padding-top:48px;}\narticle h2{font-size:26px;margin:56px 0 20px;padding-left:14px;border-left:5px solid var(--color-accent);line-height:1.4;}\narticle h3{font-size:19px;margin:32px 0 12px;color:var(--color-primary);}\narticle p{margin:16px 0;}\narticle strong{color:var(--color-primary);font-weight:700;}\narticle code{background:#d1fae5;padding:2px 8px;border-radius:4px;font-family:'SF Mono',Menlo,Consolas,monospace;font-size:14px;color:#065f46;}\n.databox{background:#d1fae5;border-left:4px solid var(--color-accent);padding:16px 20px;margin:24px 0;border-radius:0 8px 8px 0;font-size:15.5px;}\n.databox strong{color:var(--color-primary);}\n.warnbox{background:linear-gradient(135deg,#fef3c7 0%,#fde68a 100%);padding:16px 20px;margin:24px 0;border-radius:8px;font-size:15.5px;}\n.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:22px 0;}\ntable{width:100%;border-collapse:collapse;font-size:15px;background:var(--color-bg-card);}\nth,td{padding:11px 12px;text-align:left;border-bottom:1px solid #e2e8f0;vertical-align:top;}\nth{background:#f1f5f9;font-weight:700;color:#0f172a;}\ntd:first-child,th:first-child{font-weight:700;}\n@media (max-width:560px){.tablewrap table,.tablewrap thead,.tablewrap tbody,.tablewrap tr,.tablewrap th,.tablewrap td{display:block;width:auto;}.tablewrap thead{display:none;}.tablewrap tr{margin:0 0 14px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden;}.tablewrap td{border:none;border-bottom:1px solid #f1f5f9;padding:9px 14px;}.tablewrap td:first-child{background:#f1f5f9;font-weight:800;font-size:15.5px;}.tablewrap td:last-child{border-bottom:none;}.tablewrap td[data-label]::before{content:attr(data-label) \" \u2014 \";font-weight:700;color:var(--color-primary);}}\n.code-block{background:#0f172a;color:#e2e8f0;padding:16px 20px;border-radius:8px;font-family:'SF Mono',Menlo,Consolas,monospace;font-size:14px;line-height:1.6;margin:20px 0;overflow-x:auto;white-space:pre;}\n.cta{background:linear-gradient(135deg,#059669 0%,#10b981 100%);color:#fff;padding:28px 24px;border-radius:12px;margin:48px 0 0;text-align:center;}\n.cta h3{color:#fff;margin:0 0 8px;font-size:20px;}\n.cta p{color:#d1fae5;margin:0;font-size:15.5px;}\n.footer-nav{margin-top:32px;padding-top:20px;border-top:1px solid #e2e8f0;font-size:14px;color:var(--color-text-muted);}\n.footer-nav a{color:var(--color-primary);text-decoration:none;}\n@media (max-width:480px){.hero h1{font-size:26px;}.hero p{font-size:16px;}article h2{font-size:21px;}article h3{font-size:17px;}body{font-size:16px;}}\n<\/style>\n<section class=\"hero\">\n  <span class=\"eyebrow\">Node.js \uad50\uc7ac \u00b7 12\ud3b8 \u00b7 raw http<\/span>\n  <h1>HTTP \uc11c\ubc84 \uc9c1\uc811 \ub9cc\ub4e4\uae30 \u2014 http \ubaa8\ub4c8 \uae30\ucd08<\/h1>\n  <p>Express \uac00 \ubb34\uc5c7\uc744 \uac10\uc2f8\uace0 \uc788\ub294\uc9c0, \ud55c \ubc88 \uc9c1\uc811 \ub9cc\ub4e4\uc5b4\ubcf4\uba74 \uc548\ub2e4.<\/p>\n  <img decoding=\"async\" src=\"https:\/\/junai.ai\/blog\/wp-content\/uploads\/2026\/05\/hero-5-69.jpg\" alt=\"raw http \uc11c\ubc84\uac00 \uc694\uccad\uacfc \uc751\ub2f5\uc744 \ucc98\ub9ac\ud558\ub294 \ucee8\uc149 \uc544\uc774\uc18c\uba54\ud2b8\ub9ad \uc77c\ub7ec\uc2a4\ud2b8\">\n<\/section>\n\n<div class=\"container\">\n<article>\n\n<p>13\ud3b8\ubd80\ud130 Express \ub85c \ub4e4\uc5b4\uac00\uc9c0\ub9cc, \uadf8 \uc804\uc5d0 <strong>Node \ub0b4\uc7a5 <code>http<\/code> \ubaa8\ub4c8\ub9cc\uc73c\ub85c<\/strong> \uc11c\ubc84\ub97c \ub9cc\ub4e4\uc5b4 \ubcf8\ub2e4. \uc774\uc720\ub294 \ub458 \u2014 \u2460 Express \uac00 \uacb0\uad6d \ubb34\uc5c7\uc744 \uc790\ub3d9\ud654\ud574\uc8fc\ub294\uc9c0 \uc774\ud574, \u2461 \uc791\uc740 \ub9c8\uc774\ud06c\ub85c\uc11c\ube44\uc2a4\u00b7CLI \ud5ec\uc2a4\uccb4\ud06c \ub4f1 \ub77c\uc774\ube0c\ub7ec\ub9ac \uc5c6\uc774 \ud55c \ud30c\uc77c\ub85c \ub05d\ub0b4\uace0 \uc2f6\uc744 \ub54c \uc2e4\uc6a9\uc801.<\/p>\n\n<p>20\uc904\uc774\uba74 HTTP \uc11c\ubc84 \ud55c \ub300 \uc644\uc131. \uadf8 \ub4a4\ub85c \ub354 \ud544\uc694\ud55c \uac8c \ubcf4\uc774\uba74 \uadf8\uac8c Express \uc758 \uc5ed\ud560.<\/p>\n\n<h2>1. \uac00\uc7a5 \ub2e8\uc21c\ud55c \uc11c\ubc84 \u2014 10\uc904<\/h2>\n\n<div class=\"code-block\">\/\/ server.js\nimport http from &#8216;node:http&#8217;;\n\nconst server = http.createServer((req, res) =&gt; {\n  res.writeHead(200, { &#8216;Content-Type&#8217;: &#8216;text\/plain; charset=utf-8&#8217; });\n  res.end(&#8216;\uc548\ub155, Node \uc11c\ubc84!&#8217;);\n});\n\nserver.listen(3000, () =&gt; {\n  console.log(&#8216;http:\/\/localhost:3000&#8217;);\n});<\/div>\n\n<p><code>node server.js<\/code> \uc2e4\ud589 \ud6c4 \ube0c\ub77c\uc6b0\uc800\uc5d0\uc11c <code>localhost:3000<\/code> \u2014 &#8220;\uc548\ub155, Node \uc11c\ubc84!&#8221; \uac00 \ub72c\ub2e4. \ub05d.<\/p>\n\n<p>\ud575\uc2ec\uc740 <code>createServer<\/code> \uc758 \ucf5c\ubc31 <code>(req, res) =&gt; {...}<\/code>. \uc694\uccad\uc774 \uc62c \ub54c\ub9c8\ub2e4 \ud638\ucd9c\ub418\uace0 \ub450 \uac1c\ub97c \ubc1b\ub294\ub2e4. <strong><code>req<\/code>(IncomingMessage)<\/strong> \ub294 \ub4e4\uc5b4\uc628 \uc694\uccad, <strong><code>res<\/code>(ServerResponse)<\/strong> \ub294 \ubcf4\ub0bc \uc751\ub2f5. Express \uc758 <code>req<\/code>\u00b7<code>res<\/code> \ub3c4 \uacb0\uad6d \uc774\uac78 \uac10\uc2fc \uac83.<\/p>\n\n<h2>2. req \u2014 \ub4e4\uc5b4\uc628 \uc694\uccad \uc77d\uae30<\/h2>\n\n<p><code>req<\/code> \uac1d\uccb4\uc5d0\uc11c \uc790\uc8fc \uc4f0\ub294 4\uac00\uc9c0.<\/p>\n\n<div class=\"code-block\">const server = http.createServer((req, res) =&gt; {\n  console.log(req.method);    \/\/ &#8216;GET&#8217; | &#8216;POST&#8217; | &#8230;\n  console.log(req.url);       \/\/ &#8216;\/blog\/hello?lang=ko&#8217;\n  console.log(req.headers);   \/\/ { host, &#8216;user-agent&#8217;, cookie, &#8230; }\n  console.log(req.httpVersion); \/\/ &#8216;1.1&#8217;\n  \/\/ &#8230;\n});<\/div>\n\n<p>\uc8fc\uc758 \u2014 <code>req.url<\/code> \uc740 <strong>\uacbd\ub85c+\ucffc\ub9ac<\/strong>\uac00 \ud569\uccd0\uc9c4 raw \ubb38\uc790\uc5f4\uc774\ub2e4. \ubd84\ub9ac\ud558\ub824\uba74 <code>URL<\/code> \uac1d\uccb4 \uc0ac\uc6a9.<\/p>\n\n<div class=\"code-block\">const url = new URL(req.url, `http:\/\/${req.headers.host}`);\nconsole.log(url.pathname);          \/\/ &#8216;\/blog\/hello&#8217;\nconsole.log(url.searchParams.get(&#8216;lang&#8217;)); \/\/ &#8216;ko&#8217;<\/div>\n\n<div class=\"databox\">\n<strong>\uc65c URL \uc778\uc790\uc5d0 host \uac00 \ud544\uc694?<\/strong> \u2014 <code>req.url<\/code> \uc740 \ubcf4\ud1b5 \uc808\ub300 \uacbd\ub85c\uac00 \uc544\ub2c8\ub77c path \ubd80\ud130 \uc2dc\uc791 (<code>\/foo<\/code>). <code>URL<\/code> \uc0dd\uc131\uc790\ub294 \uc808\ub300 URL \uc744 \uc6d0\ud574\uc11c host \ub97c \ub450 \ubc88\uc9f8 \uc778\uc790\ub85c \ubca0\uc774\uc2a4 \uc81c\uacf5. \ud45c\uc900 \ubcf4\uc77c\ub7ec\ud50c\ub808\uc774\ud2b8 \ud55c \uc904.\n<\/div>\n\n<h2>3. res \u2014 \uc751\ub2f5 \ubcf4\ub0b4\uae30<\/h2>\n\n<p>\uc751\ub2f5\uc740 3\ub2e8\uacc4. \ud5e4\ub354 \u2192 \ubcf8\ubb38 \u2192 \ub05d.<\/p>\n\n<div class=\"code-block\">\/\/ \u2460 \ud5e4\ub354\nres.writeHead(200, {\n  &#8216;Content-Type&#8217;: &#8216;application\/json; charset=utf-8&#8217;,\n  &#8216;Cache-Control&#8217;: &#8216;no-store&#8217;,\n});\n\n\/\/ \u2461 \ubcf8\ubb38 (\uc5ec\ub7ec \ubc88 write \uac00\ub2a5)\nres.write(&#8216;{&#8220;hello&#8221;:&#8217;);\nres.write(&#8216;&#8221;world&#8221;}&#8217;);\n\n\/\/ \u2462 \ub05d (\ub9c8\uc9c0\ub9c9 \uc778\uc790\uc5d0 \ucd94\uac00 \ub370\uc774\ud130\ub3c4 \uac00\ub2a5)\nres.end();\n\/\/ \ub610\ub294 \ud55c \ubc88\uc5d0:\nres.end(&#8216;{&#8220;hello&#8221;:&#8221;world&#8221;}&#8217;);<\/div>\n\n<p>\uc77c\uc0c1\uc5d0\uc120 \uac70\uc758 <code>res.writeHead<\/code> + <code>res.end(\ubcf8\ubb38)<\/code> \ub450 \uc904\ub85c \ub05d. <code>write<\/code> \ub97c \uc5ec\ub7ec \ubc88 \uc4f0\ub294 \uac74 Streaming \uc751\ub2f5 (10\ud3b8 \ucc38\uc870)\uc5d0\uc11c \uc758\ubbf8\uac00 \uc788\ub2e4.<\/p>\n\n<h2>4. \ub77c\uc6b0\ud305 \u2014 \uc9c1\uc811 \ubd84\uae30<\/h2>\n\n<p>Express \uc5c6\uc774 \ub77c\uc6b0\ud305\uc740 <code>if\/switch<\/code> \ub85c \uc9c1\uc811.<\/p>\n\n<div class=\"code-block\">const server = http.createServer((req, res) =&gt; {\n  const url = new URL(req.url, `http:\/\/${req.headers.host}`);\n  const route = `${req.method} ${url.pathname}`;\n\n  switch (route) {\n    case &#8216;GET \/&#8217;:\n      res.writeHead(200, { &#8216;Content-Type&#8217;: &#8216;text\/html; charset=utf-8&#8217; });\n      res.end(&#8216;&lt;h1&gt;\ud648&lt;\/h1&gt;&#8217;);\n      break;\n\n    case &#8216;GET \/api\/health&#8217;:\n      res.writeHead(200, { &#8216;Content-Type&#8217;: &#8216;application\/json&#8217; });\n      res.end(JSON.stringify({ status: &#8216;ok&#8217;, ts: Date.now() }));\n      break;\n\n    case &#8216;POST \/api\/echo&#8217;:\n      \/\/ \ubcf8\ubb38 \ud30c\uc2f1 (\uc544\ub798 \uc139\uc158)\n      break;\n\n    default:\n      res.writeHead(404);\n      res.end(&#8216;Not Found&#8217;);\n  }\n});<\/div>\n\n<p>3~5 \ub77c\uc6b0\ud2b8\uba74 \uc774\ub807\uac8c\ub3c4 \ucda9\ubd84. \ub3d9\uc801 \uc138\uadf8\uba3c\ud2b8\u00b7\ubbf8\ub4e4\uc6e8\uc5b4\u00b7\uc5d0\ub7ec \ucc98\ub9ac\uac00 \ud544\uc694\ud574\uc9c0\uba74 \uadf8\uc81c\uc57c Express \uac00 \uac00\uce58 \uc788\ub2e4.<\/p>\n\n<h2>5. POST \ubcf8\ubb38 \ud30c\uc2f1 \u2014 chunk \ubaa8\uc73c\uae30<\/h2>\n\n<p><code>req<\/code> \ub294 \uc0ac\uc2e4 <strong>Readable Stream<\/strong>. POST \ubcf8\ubb38\uc774 \ud070 \uacbd\uc6b0 chunk \ub2e8\uc704\ub85c \ub3c4\ucc29\ud55c\ub2e4.<\/p>\n\n<div class=\"code-block\">if (route === &#8216;POST \/api\/echo&#8217;) {\n  let body = &#8221;;\n  req.on(&#8216;data&#8217;, (chunk) =&gt; {\n    body += chunk;\n  });\n  req.on(&#8216;end&#8217;, () =&gt; {\n    try {\n      const data = JSON.parse(body);\n      res.writeHead(200, { &#8216;Content-Type&#8217;: &#8216;application\/json&#8217; });\n      res.end(JSON.stringify({ received: data }));\n    } catch {\n      res.writeHead(400);\n      res.end(&#8216;Invalid JSON&#8217;);\n    }\n  });\n  return;\n}<\/div>\n\n<p>\ub610\ub294 10\ud3b8\uc758 <code>for await<\/code> \ud328\ud134\uc774 \ub354 \uae54\ub054:<\/p>\n\n<div class=\"code-block\">async function readBody(req) {\n  const chunks = [];\n  for await (const chunk of req) chunks.push(chunk);\n  return Buffer.concat(chunks).toString(&#8216;utf-8&#8217;);\n}\n\n\/\/ \ub77c\uc6b0\ud130 \uc548\uc5d0\uc11c\nconst body = await readBody(req);\nconst data = JSON.parse(body);<\/div>\n\n<div class=\"warnbox\">\n<strong>\ubcf8\ubb38 \ud06c\uae30 \uc81c\ud55c<\/strong> \u2014 raw http \ub294 \ubcf8\ubb38 \ud06c\uae30\ub97c \uc54c\uc544\uc11c \uc81c\ud55c\ud558\uc9c0 \uc54a\ub294\ub2e4. \uc545\uc758\uc801\uc73c\ub85c 1GB POST \ub97c \ubcf4\ub0b4\uba74 \uba54\ubaa8\ub9ac \ud3ed\ubc1c. \uc2e4\uc804\uc5d0\uc120 \ub204\uc801 \uae38\uc774 \uccb4\ud06c\ud574\uc11c \uc77c\uc815 \uc774\uc0c1\uc774\uba74 \uc989\uc2dc <code>res.writeHead(413); res.end()<\/code> \ub85c \ucc28\ub2e8. Express \ub3c4 <code>express.json({ limit: '100kb' })<\/code> \uac19\uc740 \uc635\uc158\uc73c\ub85c \uac19\uc740 \uc77c\uc744 \ud55c\ub2e4.\n<\/div>\n\n<p>\uc5ec\uae30\uae4c\uc9c0 \u2014 Express \uac00 \uc790\ub3d9\ud654\ud558\ub294 \uc77c\uc774 \uc815\ud655\ud788 \ubcf4\uc778\ub2e4. \ub77c\uc6b0\ud305 \ud2b8\ub9ac, \ubcf8\ubb38 \ud30c\uc2f1, \ubbf8\ub4e4\uc6e8\uc5b4 \uccb4\uc778, \uc5d0\ub7ec \uce90\uce58, 200 \uc751\ub2f5 \uc790\ub3d9 \u2014 13\ud3b8\ubd80\ud130 \uadf8\uac78 \uadf8\ub300\ub85c \ub2e4\ub8ec\ub2e4.<\/p>\n\n<h3>\uc694\uc57d \u2014 12\ud3b8 \uc88c\ud45c<\/h3>\n\n<p>\uc5ec\uae30\uae4c\uc9c0 \uc815\ub9ac. Node \ub0b4\uc7a5 <code>http<\/code> \ub9cc\uc73c\ub85c \uc11c\ubc84 \u2014 <code>createServer((req, res) =&gt; ...)<\/code> + <code>listen(port)<\/code>. <code>req<\/code> \uc5d0\uc11c method\u00b7url\u00b7headers, \ubcf8\ubb38\uc740 stream chunk \ub85c \ubaa8\uc740\ub2e4. <code>res.writeHead(status, headers)<\/code> + <code>res.end(body)<\/code> \uac00 \uc751\ub2f5 \ub05d. \ub77c\uc6b0\ud305\uc740 <code>switch<\/code> \ub85c \uc9c1\uc811, \ubcf8\ubb38 \ud06c\uae30 \uc81c\ud55c\ub3c4 \uc9c1\uc811. \uc791\uc740 \ub9c8\uc774\ud06c\ub85c\uc11c\ube44\uc2a4\u00b7\ud5ec\uc2a4\uccb4\ud06c \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uc5d4 \ucda9\ubd84. \ub2e4\uc74c \ud3b8\ubd80\ud130 <strong>Express<\/strong> \uac00 \uc774\uac78 \uc5b4\ub5bb\uac8c \ub2e8\uc21c\ud654\ud558\ub294\uc9c0 \ubcf8\ub2e4.<\/p>\n\n<div class=\"cta\">\n<h3>\ub2e4\uc74c \ud3b8 \uc608\uace0 \u2014 Express \uc785\ubb38<\/h3>\n<p>\uc124\uce58\u00b7\uae30\ubcf8 \ub77c\uc6b0\ud305\u00b7\uc751\ub2f5 \ubcf4\ub0b4\uae30. 13\ud3b8.<\/p>\n<\/div>\n\n<div class=\"footer-nav\">\n\uc2dc\ub9ac\uc988 \u00b7 <a href=\"https:\/\/junai.ai\/blog\/category\/nodejs\/\">\uc27d\uac8c \ubc30\uc6b0\ub294 Node.js<\/a> \u00b7 \uc774\uc804: <a href=\"https:\/\/junai.ai\/blog\/nodejs-buffer-11\/\">Ch.11 Buffer<\/a>\n<\/div>\n\n<\/article>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Express \uc5c6\uc774 Node http \ubaa8\ub4c8\ub85c \uc11c\ubc84 \u2014 createServer\u00b7req\u00b7res\u00b7\ub77c\uc6b0\ud305\u00b7\ubc14\ub514 \ud30c\uc2f1. \uad50\uc7ac 12\ud3b8.<\/p>\n","protected":false},"author":1,"featured_media":836,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-890","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nodejs"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/posts\/890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/comments?post=890"}],"version-history":[{"count":0,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/posts\/890\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/media\/836"}],"wp:attachment":[{"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/media?parent=890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/categories?post=890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/junai.ai\/blog\/wp-json\/wp\/v2\/tags?post=890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}