Hi

I'm trying to cache the responses of a server. But before I can do this I 
need the following to work

var http = require('http'),

http.createServer(function (req, res) {
  callServer(req, res);
}).listen(8000);

function callServer(req, res) {
        var body = '' ;
        var options = { host: 'localhost', port: 8080, path: req.url } ;

        var callback = function(response) {
                response.on('data', function (chunk) {
                        body += chunk;
                });

                response.on('end', function () {
                                res.writeHead(response.statusCode, 
response.headers) ;
                                res.end(body) ;
                });
        } ;
        http.request(options, callback).end();
}

This works very well for html and css, but not for images. I tried 
"res.end(body, 'binary')" without success. Furthermore, I noticed that 
body.length != response.headers['content-length']
Any suggestion how to fix this ?

Cheer

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to