Using package loader

This commit is contained in:
2015-04-18 22:14:36 +08:00
parent 6bfa913c06
commit efd618845c
6 changed files with 47 additions and 9 deletions
+48
View File
@@ -0,0 +1,48 @@
var cl = global.botanLoader;
var Dragonfly = global.Dragonfly;
var Cookie = cl.load( "botanss.net.components.Cookie" );
var HTTP = function( req, res )
{
var _self = this;
var canExit = true;
// Simple HTTP Model
this.response = {
statusCode: 200
, headers: {
"Content-Type": "text/html; charset=utf-8"
, "Powered-By": "Botanical Framework (Node.js)"
}
, write: function( str ) { _self.response.content = str }
, writeLine: function( str ) { _self.response.content += str + "\n"; }
, end: function()
{
if( canExit )
{
canExit = false;
var rc = _self.response;
res.writeHead( rc.statusCode, rc.headers );
res.end( rc.content );
}
}
, content: ''
, cookie: new Cookie( "", this )
, raw: res
};
this.request = {
uri: require('url').parse( req.url )
, isPost: ( req.method == 'POST' )
, cookie: new Cookie( req.headers.cookie, this )
, remoteAddr: req.connection.remoteAddress
, raw: req
};
};
module.exports = HTTP;