This about your cope.

var proxyServer = http.createServer(function (req, res) {

    var start_time = new Date().getTime();

    proxy.web(req, res);

    res.on('finish', function() {
        console.log("The request was proxied in " + (new Date().getTime() - 
start_time) + "ms");
    });
});

On Saturday, January 25, 2014 5:40:09 AM UTC-8, Christoph wrote:
>
> Hi,
>
> i want to measure the amount of time, each proxy-request needs, so i tried 
> it this way:
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------
> var httpProxy = require('http-proxy');
> var http = require('http');
>
> var proxy = new httpProxy.createProxyServer({
>     target: {
>         host: 'localhost',
>         port: 80
>     }
> });
>
> var start_time = 0;
> var proxyServer = http.createServer(function (req, res) {
>
>     start_time = new Date().getTime();
>
>     proxy.web(req, res);
>
>     res.on('finish', function() {
>         console.log("The request was proxied in " + (new Date().getTime() 
> - start_time) + "ms");
>     });
> });
> proxyServer.listen(3000);
>
> ----------------------------------------------------------------------------------------------------------------------------------------
>
> but this does not work correctly, if there are parallel connections to 
> handle. start_time is over-written on each client-request and not handled 
> per request.
>
> thanks for any advice! :)
>

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to