{"id":503,"date":"2022-01-28T15:56:02","date_gmt":"2022-01-28T06:56:02","guid":{"rendered":"https:\/\/blog.opendocs.co.kr\/?p=503"},"modified":"2022-03-24T05:57:05","modified_gmt":"2022-03-23T20:57:05","slug":"source-nodejs-%ed%85%8c%ec%8a%a4%ed%8a%b8-%ed%81%b4%eb%9d%bc%ec%9d%b4%ec%96%b8%ed%8a%b8-http","status":"publish","type":"post","link":"https:\/\/blog.opendocs.co.kr\/?p=503","title":{"rendered":"[Source | Nodejs] \ud14c\uc2a4\ud2b8 \ud074\ub77c\uc774\uc5b8\ud2b8 &#8211; HTTP"},"content":{"rendered":"\n<p>API \ud14c\uc2a4\ud2b8\ub97c \uc704\ud55c \ud074\ub77c\uc774\uc5b8\ud2b8 \ucf54\ub4dc\ub97c \uc815\ub9ac\ud55c\ub2e4.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<pre class=\"wp-block-preformatted\">\uc791\uc131\uc77c : 2022-01-28\nnodeJs Ver : v16.13.1<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"400\" height=\"180\" src=\"https:\/\/blog.opendocs.co.kr\/wp-content\/uploads\/2021\/05\/nodejs_source.jpg\" alt=\"\" class=\"wp-image-305\" srcset=\"https:\/\/blog.opendocs.co.kr\/wp-content\/uploads\/2021\/05\/nodejs_source.jpg 400w, https:\/\/blog.opendocs.co.kr\/wp-content\/uploads\/2021\/05\/nodejs_source-300x135.jpg 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>1&gt; \ucf54\ub4dc\uc791\uc131 (client.js)<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n\/\/ For Execute Shell\n\/\/   node client.js URL-A\nconst http = require(&quot;http&quot;);\nconst name = &quot;OPENDOCS_TEST_CLIENT&quot;;\n\nif(process.argv.length &lt; 3) {\n    console.log(&quot;Error - TestCase Require.&quot;);\n}\nconst testCase = process.argv&#91;2];\nconst req = require(`.\/ClientTestCase\/${testCase}`);\n\nhttp.request(req, (res) =&gt; {\n    let bodyStr = '';\n    res.on(&quot;data&quot;, chunk =&gt; {\n        bodyStr += chunk;\n    });\n    res.on(&quot;end&quot;, () =&gt; {\n        \/\/ Request\n        console.log(`---------- Result (${name} : ${testCase}) ----------`);\n        console.log(res.headers);\n        console.log(&quot;----------------------------------------&quot;);\n        console.log(bodyStr);\n        console.log(&quot;------------------------------------------------------------\/\/\\n\\n\\n&quot;);\n    });\n}).end(req.body);\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>2&gt; \uc694\uccad\uc0d8\ud50c \uc791\uc131<\/strong> : ClientTestCase \ud3f4\ub354\uc5d0 {API\uba85}.js \ub85c \uc0dd\uc131\ud55c\ub2e4<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n\/\/ .\/ClientTestCase\/URL-A.js\n\/\/ \ud14c\uc2a4\ud2b8\uc2dc 'node client.js URL-A' \uba85\ub839\uc73c\ub85c \uc2e4\ud589\nexports.host = &quot;127.0.0.1&quot;;\nexports.port = 9090;\nexports.method = &quot;POST&quot;;\nexports.path = &quot;\/url_a&quot;;\nexports.headers = {&quot;Content-Type&quot;: &quot;application\/json&quot;, &quot;TEST&quot;: &quot;TET&quot;};\nexports.body = JSON.stringify({\n    data: &quot;hello A&quot;\n});\n\n\/\/ .\/ClientTestCase\/URL-B.js\n\/\/ \ud14c\uc2a4\ud2b8\uc2dc 'node client.js URL-B' \uba85\ub839\uc73c\ub85c \uc2e4\ud589\nexports.host = &quot;127.0.0.1&quot;;\nexports.port = 9090;\nexports.method = &quot;POST&quot;;\nexports.path = &quot;\/url_b&quot;;\nexports.headers = {&quot;Content-Type&quot;: &quot;application\/json&quot;, &quot;TEST&quot;: &quot;TET&quot;};\nexports.body = JSON.stringify({\n    data: &quot;hello B&quot;\n});\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>API \ud14c\uc2a4\ud2b8\ub97c \uc704\ud55c \ud074\ub77c\uc774\uc5b8\ud2b8 \ucf54\ub4dc\ub97c \uc815\ub9ac\ud55c\ub2e4. \uc791\uc131\uc77c : 2022-01-28 nodeJs Ver : v16.13.1 1&gt; \ucf54\ub4dc\uc791\uc131 (client.js) 2&gt; \uc694\uccad\uc0d8\ud50c \uc791\uc131 : ClientTestCase \ud3f4\ub354\uc5d0 {API\uba85}.js \ub85c \uc0dd\uc131\ud55c\ub2e4<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[152,151,153,150],"_links":{"self":[{"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/503"}],"collection":[{"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=503"}],"version-history":[{"count":2,"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/503\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/503\/revisions\/522"}],"wp:attachment":[{"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.opendocs.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}