Request.prototype.consume = cadence(function (async) {
var location = url.parse(this._request.url)
var path = location.pathname
location.pathname = location.pathname.substring(this._connection.path.length)
location = url.format(location)
async(function () {
this._connection.multiplexer.connect(async())
}, function (socket) {
this._spigot.emptyInto(socket.basin)
this._spigot.requests.enqueue({
module: 'rendezvous',
method: 'header',
body: {
httpVersion: this._request.httpVersion,
method: this._request.method,
url: location,
headers: this._request.headers,
actualPath: path,
rawHeaders: coalesce(this._request.rawHeaders, [])
}
}, async())
}, function () {
var readable = new Staccato.Readable(this._request)
var loop = async(function () {
async(function () {
readable.read(async())
}, function (buffer) {
if (buffer == null) {
return [ loop.break ]
}
this._spigot.requests.enqueue({
module: 'rendezvous',
method: 'chunk',
body: buffer
}, async())
})
})()
}, function () {
this._spigot.requests.enqueue({
module: 'rendezvous',
method: 'trailer',
body: null
}, async())
}, function () {
this._spigot.requests.enqueue(null, async())
})
})
Rendezvous.prototype._close = cadence(function (async) {
async.forEach(function (path) {
this._connections.get(path.split('/'))[0].socket.end(async())
})(this.paths)
})
Rendezvous.prototype.close = function (callback) {
this._close(callback || abend)
}
module.exports = Rendezvous