Last active
January 13, 2018 05:33
-
-
Save shimataro/c57252f8459c9677ffe6926fe3e57b96 to your computer and use it in GitHub Desktop.
Node.jsの挙動確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// クライアントからの接続が切れたリクエストはどうなるのっと | |
var http = require("http"); | |
function main(host, port) | |
{ | |
http.createServer(respond).listen(port, host); | |
var url = "http://" + host + ":" + port + "/"; | |
console.log("curl " + url); | |
} | |
function respond(req, res) | |
{ | |
// 5秒後に応答 | |
setTimeout(function() | |
{ | |
res.writeHead(200, {"Content-Type": "text/plain"}); | |
res.end("hell, Word\n"); | |
}, 5000); | |
} | |
main("127.0.0.1", 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// これをテンプレとしていろいろ調べる | |
var http = require("http"); | |
function main(host, port) | |
{ | |
http.createServer(respond).listen(port, host); | |
var url = "http://" + host + ":" + port + "/"; | |
console.log("curl " + url); | |
} | |
function respond(req, res) | |
{ | |
res.writeHead(200, {"Content-Type": "text/plain"}); | |
res.end("hell, Word\n"); | |
} | |
main("127.0.0.1", 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment