Created
August 19, 2015 16:15
-
-
Save CoDEmanX/41ae8879afecb9a13a98 to your computer and use it in GitHub Desktop.
NodeJS: parse HTTP header string
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"); | |
var net = require("net"); | |
var server = http.createServer(function (req, res) { | |
console.dir(req.headers); | |
console.dir(req.url); | |
server.close(); | |
}); | |
server.listen(8080); | |
var client = net.connect(8080, "localhost", function(){ | |
client.write("POST /index.html HTTP/1.1\n" + | |
"Host: www.example.org\n" + | |
"User-Agent: Mozilla/4.0\n" + | |
"Accept: image/gif, image/jpeg, */*\n" + | |
"Connection: close\n\n" | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment