Long time no write, read blog today, feel the need to continue to write node. js, Finish. Originally thought of the small Cui class continue to talk about, for other reasons also delayed, see later there is no chance it. No nonsense, 123 start.
I. Exoress Request Object
For the request object has done network this piece of should be not unfamiliar, iOS, C # will have, other languages basic will have, node. JS is no exception, after all, is the HTTP protocol.
varExpress = require ('Express');varApp =Express (); App.listen (8080); app.Get('/user/:userid', Function (req, res) {//the original URL string of the requestConsole.log ("url:\t"+Req.originalurl); //the string of the protocol, such as HTTP, httpsConsole.log ("Protocol:"+Req.protocol); //the requested IP addressConsole.log ("ip:\t"+Req.ip); //The path portion of the requested URLConsole.log ("path:\t"+Req.path); //host name of the requestConsole.log ("host:\t"+req.host); //How to request get, post, etc.Console.log ("method:\t"+Req.method); //the query string portion of the requestConsole.log ("query:\t"+json.stringify (req.query)); //A Boolean value that is true when the last modification matches the current matchConsole.log ("fresh:\t"+Req.fresh); //A Boolean value that is false when the last modification matches the current matchConsole.log ("stale:\t"+Req.stale); //Boolean value, True when establishing a TLS linkConsole.log ("secure:\t"+req.secure); //a method, if the character set specified by CharSet is supported by TrueConsole.log ("utf8:\t"+ Req.acceptscharset ('UTF8')); //method to return the value of the headerConsole.log ("Connection:"+ req.Get('Connection')); //the object form of the request headerConsole.log ("Headers:"+ json.stringify (req.headers,NULL,2)); Res.send ("User Request");});
node. JS Express II