Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var http = require('http');
- var url = require('url');
- function WSGI(_url) {
- this.config = url.parse(_url);
- this._handleHTTP = function(env, callback) {
- var site = http.createClient(this.config.port || 80, this.config.hostname);
- var request = site.request('GET', this.config.pathname);
- request.end();
- request.on('response', function(response) {
- response.setEncoding('utf8');
- response.on('data', function(chunk) {
- callback(response, chunk);
- });
- });
- }
- this.request = function(env, callback) {
- switch(this.config.protocol) {
- case 'http:':
- this._handleHTTP(env, callback);
- break;
- case 'file:':
- // NIY
- break;
- }
- }
- }
- exports.WSGI = WSGI;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement