42 lines
752 B
JavaScript
42 lines
752 B
JavaScript
var Dragonfly = global.Dragonfly;
|
|
|
|
var HTTP = function( req, res )
|
|
{
|
|
var _self = this;
|
|
var canExit = true;
|
|
|
|
// Simple HTTP Model
|
|
this.response = {
|
|
statusCode: 200
|
|
, headers: {
|
|
'Content-Type': 'text/html'
|
|
}
|
|
, 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: ''
|
|
, raw: res
|
|
};
|
|
|
|
this.request = {
|
|
uri: require('url').parse( req.url )
|
|
, isPost: ( req.method == 'POST' )
|
|
, remoteAddr: req.connection.remoteAddress
|
|
, raw: req
|
|
};
|
|
};
|
|
|
|
|
|
module.exports = HTTP;
|