Created
October 4, 2017 06:23
-
-
Save numb86/e35fffc4528d89c3eb1b1d788cf24fc0 to your computer and use it in GitHub Desktop.
ローカルサーバーを立ててそこにリクエストするプログラム。
This file contains hidden or 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
const http = require('http'); | |
const req = require('request-promise'); | |
const PORT_NUMBER = 8881; | |
const server = http.createServer(); | |
server.on('request', (req, res) => { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.write('Hello World !2!'); | |
res.end(); | |
server.close(); | |
req.connection.end(); | |
req.connection.destroy(); | |
}); | |
server.listen(PORT_NUMBER); | |
req({ | |
method: 'GET', | |
url: `http://localhost:${PORT_NUMBER}`, | |
resolveWithFullResponse: true, | |
}) | |
.then(res => console.log(res.headers)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment