Skip to content

Performance is inferior to Firefox's nsITraceableChannel #39

@rpelizzi

Description

@rpelizzi

I am developing a Firefox addon which rewrites incoming traffic using nsITraceableChannel, and I tried to decouple it from Firefox and put the logic into a separate HTTP proxy using this package. I knew doing MITM with HTTPS would use a little more resources due to SSL/gzip decoding/encoding, but the proxy is much slower, to the point that I can't even use it for testing. And it doesn't even seem like the proxy is hitting the CPU too hard, it's just slow! Is the slower performance normal, or do I definitely have some sort of bug that severely degrades performance? I am caching requests with the following helper function, based on the examples in tests/:

ctx.cacheAndModify = function(f) {
  var data = "";
  ctx.onResponseData(function(ctx, chunk, cb) {
    data += chunk.toString();
    return cb(null, null);
  });
  ctx.onResponseEnd(function(ctx, cb) {
    var opts = ctx.proxyToServerRequestOptions;
    var url = (ctx.isSSL ? "https" : "http") + "://" + opts.host +
      (opts.port === 443 || opts.port === 80 ? "" : ":" + opts.port) +
      opts.path;
    ctx.proxyToClientResponse.write(new Buffer(f(data, url)));
    return cb();
  });
};

so then I can just use ctx.cacheAndModify(handler) in onResponse. I also use Proxy.gunzip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions