HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/node_modules/localtunnel/lib/HeaderHostTransformer.js
var stream = require('stream');
var util = require('util');

var Transform = stream.Transform;

var HeaderHostTransformer = function(opts) {
    if (!(this instanceof HeaderHostTransformer)) {
        return new HeaderHostTransformer(opts);
    }

    opts = opts || {}
    Transform.call(this, opts);

    var self = this;
    self.host = opts.host || 'localhost';
    self.replaced = false;
}
util.inherits(HeaderHostTransformer, Transform);

HeaderHostTransformer.prototype._transform = function (chunk, enc, cb) {
    var self = this;

    // after replacing the first instance of the Host header
    // we just become a regular passthrough
    if (!self.replaced) {
        chunk = chunk.toString();
        self.push(chunk.replace(/(\r\n[Hh]ost: )\S+/, function(match, $1) {
            self.replaced = true;
            return $1 + self.host;
        }));
    }
    else {
        self.push(chunk);
    }

    cb();
};

module.exports = HeaderHostTransformer;