{
	"version": 3,
	"sources": [
		"C:\\dev\\streamline-streams\\src\\streams._js"
	],
	"names": [
		"constr",
		"writable",
		"props",
		"forEach",
		"name",
		"desc",
		"get",
		"emitter",
		"set",
		"val",
		"prototype",
		"undefined",
		"Object",
		"defineProperty",
		"methods",
		"apply",
		"arguments",
		"events",
		"concat",
		"closed",
		"self",
		"autoClosed",
		"fn",
		"call",
		"on",
		"_onClose",
		"trackClose",
		"close",
		"callback",
		"end",
		"destroySoon",
		"err",
		"doesNotEmitClose",
		"emit",
		"unwrap",
		"removeAllListeners",
		"options",
		"chunk",
		"_error",
		"_chunks",
		"push",
		"_current",
		"length",
		"_high",
		"_paused",
		"_done",
		"pause",
		"chunks",
		"total",
		"_encoding",
		"join",
		"result",
		"Buffer",
		"reduce",
		"copy",
		"Wrapper",
		"_eos",
		"ez",
		"_low",
		"Math",
		"max",
		"lowMark",
		"highMark",
		"_onData",
		"Error",
		"trackData",
		"readChunk",
		"splice",
		"resume",
		"e",
		"setEncoding",
		"enc",
		"read",
		"len",
		"withTimeout",
		"Infinity",
		"slice",
		"unread",
		"timeout",
		"_read",
		"readAll",
		"available",
		"count",
		"_onDrain",
		"_drain",
		"write",
		"data",
		"message",
		"encoding",
		"headers",
		"comps",
		"split",
		"ctype",
		"i",
		"pair",
		"trim",
		"toLowerCase",
		"indexOf",
		"_getEncodingDefault",
		"detectEncoding",
		"_getEncodingStrict",
		"req",
		"ReadableStream",
		"_request",
		"_getEncoding",
		"resp",
		"WritableStream",
		"_response",
		"createServer",
		"secure",
		"require",
		"listen",
		"args",
		"cb",
		"Array",
		"reply",
		"requestListener",
		"_fixHttpServerOptions",
		"request",
		"response",
		"flows",
		"withContext",
		"HttpServerRequest",
		"HttpServerResponse",
		"writeHead",
		"stack",
		"Server",
		"url",
		"parsed",
		"parseUrl",
		"protocol",
		"host",
		"hostname",
		"port",
		"path",
		"pathname",
		"query",
		"method",
		"module",
		"substring",
		"user",
		"token",
		"password",
		"toString",
		"Authorization",
		"proxy",
		"os",
		"force",
		"excludes",
		"isHttps",
		"substr",
		"auth",
		"proxyToken",
		"proxyAuthenticator",
		"authenticate",
		"proxyAuthenticate",
		"_onResponse",
		"HttpClientResponse",
		"trackResponse",
		"_init",
		"proxyConnect",
		"proxyOpt",
		"res",
		"socket",
		"head",
		"agent",
		"net",
		"_connection",
		"createConnection",
		"_onConnect",
		"trackConnect",
		"connect",
		"NetStream",
		"serverOptions",
		"connectionListener",
		"streamOptions",
		"connection",
		"parse",
		"globals",
		"exports",
		"create",
		"wrapEvents",
		"wrapProperties",
		"wrapChainMethods",
		"wrapMethods",
		"createHttpServer",
		"HttpServer",
		"wrapOptionalMethods",
		"checkStatus",
		"statuses",
		"statusCode",
		"HttpClientRequest",
		"setTimeout",
		"ms",
		"httpRequest",
		"_fixHttpClientOptions",
		"keys",
		"key",
		"tcpClient",
		"NetClient",
		"socketClient",
		"createNetServer",
		"NetServer",
		"using",
		"constructor",
		"stream",
		"usingReadable",
		"usingWritable",
		"pump",
		"inStream",
		"outStream"
	],
	"mappings": ";;;;;;;;6CA4BwBA,M,EAAQC,Q,EAAUC,K;AACzCA,OAAMC,OAAN,CAAc,UAASC,IAAT;AACb,MAAIC,OAAO,EAAX;AACAA,OAAKC,GAAL,GAAW;AACV,UAAO,KAAKC,OAAL,CAAaH,IAAb,CAAP;AADU,GAAX;AAGA,MAAIH,QAAJ,EAAcI,KAAKG,GAAL,GAAW,UAASC,GAAT;AACxB,QAAKF,OAAL,CAAaH,IAAb,IAAqBK,GAArB;AADwB,GAAX;AAGdT,SAAOU,SAAP,CAAiBN,IAAjB,MAA2BO,SAA3B,IAAwCC,OAAOC,cAAP,CAAsBb,OAAOU,SAA7B,EAAwCN,IAAxC,EAA8CC,IAA9C,CAAxC;AARa,EAAd;;;uCAYoBL,M,EAAQc,O;AAC5BA,SAAQX,OAAR,CAAgB,UAASC,IAAT;AACfJ,SAAOU,SAAP,CAAiBN,IAAjB,IAAyB;AACxB,UAAO,KAAKG,OAAL,CAA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EAA6C6B,OAA7C,EAAsDd,EAAtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YACQ,0CAAQqL,KAAR,2BAAmB,IAAnB,QAA4BxB,QAAQ7E,cAApC,EAAoD/F,OAApD,EAA6D6B,OAA7D,EAAsEd,EAAtE,EADR;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAIA;AACA;AACA6J,QAAQ4B,aAAR,+EAAoCxM,OAApC,EAA6C6B,OAA7C,EAAsDd,EAAtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YACQ,0CAAQqL,KAAR,2BAAmB,IAAnB,QAA4BxB,QAAQzE,cAApC,EAAoDnG,OAApD,EAA6D6B,OAA7D,EAAsEd,EAAtE,EADR;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAIA;AACA;AACA;AACA6J,QAAQ6B,IAAR,gFAA2BC,QAA3B,EAAqCC,SAArC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAEe,2EAFf;;AAAA;AAAA,WAEQ5H,IAFR;AAAA;AAAA;AAAA;;AAAA;AAAA,YAEiC,6EAAmBA,IAAnB,EAFjC;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
	"file": "streams._js",
	"sourcesContent": [
		"/**\r\n * Copyright (c) 2011 Bruno Jouhier <bruno.jouhier@sage.com>\r\n * MIT License\r\n */\r\n\"use strict\";\r\n\r\n/// !doc\r\n/// \r\n/// # Wrappers for node.js streams\r\n/// \r\n/// These wrappers implement a _pull style_ API. \r\n/// For readable streams, instead of having the stream _push_ the data to its consumer by emitting `data` and `end` events, \r\n/// the wrapper lets the consumer _pull_ the data from the stream by calling asynchronous `read` methods.\r\n/// The wrapper takes care of the low level `pause`/`resume` logic.\r\n/// \r\n/// Similarly, for writable streams, the wrapper provides a simple asynchronous `write` method and takes\r\n/// care of the low level `drain` logic.\r\n/// \r\n/// For more information on this design,\r\n/// see [this blog post](http://bjouhier.wordpress.com/2011/04/25/asynchronous-episode-3-adventures-in-event-land/)\r\n/// \r\n/// For a simple example of this API in action, \r\n/// see the [google client example](../../../examples/streams/googleClient._js)\r\nvar parseUrl = require(\"url\").parse;\r\nvar globals = require('streamline-runtime').globals;\r\nvar flows = require('streamline-runtime').flows;\r\nvar os = require(\"os\");\r\n\r\nfunction wrapProperties(constr, writable, props) {\r\n\tprops.forEach(function(name) {\r\n\t\tvar desc = {};\r\n\t\tdesc.get = function() {\r\n\t\t\treturn this.emitter[name];\r\n\t\t};\r\n\t\tif (writable) desc.set = function(val) {\r\n\t\t\tthis.emitter[name] = val;\r\n\t\t};\r\n\t\tconstr.prototype[name] === undefined && Object.defineProperty(constr.prototype, name, desc);\r\n\t});\r\n}\r\n\r\nfunction wrapMethods(constr, methods) {\r\n\tmethods.forEach(function(name) {\r\n\t\tconstr.prototype[name] = function() {\r\n\t\t\treturn this.emitter[name].apply(this.emitter, arguments);\r\n\t\t};\r\n\t});\r\n}\r\n\r\nfunction wrapOptionalMethods(constr, methods) {\r\n\tmethods.forEach(function(name) {\r\n\t\tconstr.prototype[name] = function() {\r\n\t\t\treturn this.emitter[name] && this.emitter[name].apply(this.emitter, arguments);\r\n\t\t};\r\n\t});\r\n}\r\n\r\nfunction wrapChainMethods(constr, methods) {\r\n\tmethods.forEach(function(name) {\r\n\t\tconstr.prototype[name] = function() {\r\n\t\t\tthis.emitter[name].apply(this.emitter, arguments);\r\n\t\t\treturn this;\r\n\t\t};\r\n\t});\r\n}\r\n\r\nfunction wrapEvents(constr, events) {\r\n\tconstr.prototype.events = (constr.prototype.events || []).concat(events);\r\n}\r\n\r\n/// \r\n/// ## Wrapper\r\n/// \r\n/// Base wrapper for all objects that emit an `end` or `close` event.  \r\n/// All stream wrappers derive from this wrapper.\r\n/// \r\n/// * `wrapper = new streams.Wrapper(stream)`  \r\n///   creates a wrapper.\r\n\r\nfunction Wrapper(emitter) {\r\n\tvar self = this;\r\n\tvar closed = false;\r\n\temitter.on('close', function() {\r\n\t\t_onClose && _onClose();\r\n\t});\r\n\r\n\t// hook for subclasses\r\n\tself.autoClosed = [];\r\n\r\n\tfunction trackClose() {\r\n\t\tclosed = true;\r\n\t\tself.autoClosed.forEach(function(fn) {\r\n\t\t\tfn.call(self);\r\n\t\t});\r\n\t}\r\n\tvar _onClose = trackClose;\r\n\r\n\tself.close = function(callback) {\r\n\t\t\tif (closed) return callback();\r\n\t\t\tvar close = emitter.end || emitter.close || emitter.destroySoon;\r\n\t\t\tif (typeof close !== \"function\") return callback();\r\n\t\t\t_onClose = function(err) {\r\n\t\t\t\tclosed = true;\r\n\t\t\t\t_onClose = null;\r\n\t\t\t\tcallback(err);\r\n\t\t\t\tcallback = null;\r\n\t\t\t};\r\n\t\t\tif (self.doesNotEmitClose) {\r\n\t\t\t\temitter.emit(\"close\");\r\n\t\t\t}\r\n\t\t\tclose.call(emitter);\r\n\t\t};\r\n\t/// * `emitter = wrapper.emitter`  \r\n\t///    returns the underlying emitter. The emitter stream can be used to attach additional observers.\r\n\tself.emitter === undefined && Object.defineProperty(self, \"emitter\", {\r\n\t\tget: function() {\r\n\t\t\treturn emitter;\r\n\t\t}\r\n\t});\r\n\t/// * `closed = wrapper.closed`   \r\n\t///    returns true if the `close` event has been received.\r\n\tself.closed === undefined && Object.defineProperty(self, \"closed\", {\r\n\t\tget: function() {\r\n\t\t\treturn closed;\r\n\t\t}\r\n\t});\r\n\t/// * `emitter = wrapper.unwrap()`  \r\n\t///    unwraps and returns the underlying emitter.  \r\n\t///    The wrapper should not be used after this call.\r\n\tself.unwrap = function() {\r\n\t\temitter.removeAllListeners();\r\n\t\tclosed = true;\r\n\t\treturn emitter;\r\n\t};\r\n}\r\n\r\n/// \r\n/// ## ReadableStream\r\n/// \r\n/// All readable stream wrappers derive from this wrapper. \r\n/// \r\n/// * `stream = new streams.ReadableStream(stream[, options])`  \r\n///   creates a readable stream wrapper.\r\n\r\nfunction ReadableStream(emitter, options) {\r\n\tvar self = this;\r\n\tWrapper.call(self, emitter);\r\n\toptions = options || {};\r\n\tvar _eos = options.ez ? undefined : null;\r\n\tvar _low = Math.max(options.lowMark || 0, 0);\r\n\tvar _high = Math.max(options.highMark || 0, _low);\r\n\tvar _paused = false;\r\n\tvar _current = 0;\r\n\tvar _chunks = [];\r\n\tvar _error;\r\n\tvar _done = false;\r\n\tvar _encoding;\r\n\r\n\temitter.on('error', function(err) {\r\n\t\t_onData(err);\r\n\t});\r\n\temitter.on('data', function(chunk) {\r\n\t\t_onData(null, chunk);\r\n\t});\r\n\temitter.on('end', function() {\r\n\t\t_onData(null, null);\r\n\t});\r\n\r\n\tself.autoClosed.push(function() {\r\n\t\t!_done && _onData(new Error(\"stream was closed unexpectedly\"));\r\n\t});\r\n\r\n\tfunction trackData(err, chunk) {\r\n\t\tif (err) _error = err;\r\n\t\telse if (chunk) {\r\n\t\t\t_chunks.push(chunk);\r\n\t\t\t_current += chunk.length;\r\n\t\t\tif (_current > _high && !_paused && !_done && !_error && !self.closed) {\r\n\t\t\t\temitter.pause();\r\n\t\t\t\t_paused = true;\r\n\t\t\t}\r\n\t\t} else _done = true;\r\n\t};\r\n\r\n\tvar _onData = trackData;\r\n\r\n\tvar readChunk = function(callback) {\r\n\t\tif (_chunks.length > 0) {\r\n\t\t\tvar chunk = _chunks.splice(0, 1)[0];\r\n\t\t\t_current -= chunk.length;\r\n\t\t\tif (_current <= _low && _paused && !_done && !_error && !self.closed) {\r\n\t\t\t\temitter.resume();\r\n\t\t\t\t_paused = false;\r\n\t\t\t}\r\n\t\t\treturn callback(null, chunk);\r\n\t\t} else if (_done) {\r\n\t\t\tif (_paused) { // resume it for keep-alive\r\n\t\t\t\ttry {\r\n\t\t\t\t\t!self.closed && emitter.resume();\r\n\t\t\t\t\t_paused = false;\r\n\t\t\t\t} catch (e) { // socket may be closed\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn callback(null, null);\r\n\t\t} else if (_error) { // should we resume if paused?\r\n\t\t\treturn callback(_error);\r\n\t\t} else _onData = function(err, chunk) {\r\n\t\t\tif (err) _error = err;\r\n\t\t\telse if (!chunk) _done = true;\r\n\t\t\t_onData = trackData; // restore it\r\n\t\t\tcallback(err, chunk);\r\n\t\t\tcallback = null;\r\n\t\t};\r\n\t};\r\n\r\n\tfunction concat(chunks, total) {\r\n\t\tif (_encoding) return chunks.join('');\r\n\t\tif (chunks.length == 1) return chunks[0];\r\n\t\tvar result = new Buffer(total);\r\n\t\tchunks.reduce(function(val, chunk) {\r\n\t\t\tchunk.copy(result, val);\r\n\t\t\treturn val + chunk.length;\r\n\t\t}, 0);\r\n\t\treturn result;\r\n\t}\r\n\t/// * `stream.setEncoding(enc)`  \r\n\t///   sets the encoding.\r\n\t///   returns `this` for chaining.\r\n\tself.setEncoding = function(enc) {\r\n\t\t_encoding = enc;\r\n\t\tif (enc) emitter.setEncoding(enc);\r\n\t\treturn self;\r\n\t};\r\n\t/// * `data = stream.read(_[, len])`  \r\n\t///   reads asynchronously from the stream and returns a `string` or a `Buffer` depending on the encoding.  \r\n\t///   If a `len` argument is passed, the `read` call returns when `len` characters or bytes \r\n\t///   (depending on encoding) have been read, or when the underlying stream has emitted its `end` event \r\n\t///   (so it may return less than `len` bytes or chars).\r\n\t///   Reads till the end if `len` is negative.  \r\n\t///   Without `len`, the read calls returns the data chunks as they have been emitted by the underlying stream.  \r\n\t///   Once the end of stream has been reached, the `read` call returns `null`.\r\n\tself.read = function(_, len, withTimeout) {\r\n\t\tfunction _read(_) {\r\n\t\t\tif (self.closed && !_chunks.length) return _eos;\r\n\t\t\tif (len == null) return readChunk(_) || _eos;\r\n\t\t\tif (len < 0) len = Infinity;\r\n\t\t\tif (len == 0) return _encoding ? \"\" : new Buffer(0);\r\n\t\t\tvar chunks = [],\r\n\t\t\t\ttotal = 0;\r\n\t\t\twhile (total < len) {\r\n\t\t\t\tvar chunk = readChunk(_);\r\n\t\t\t\tif (!chunk) return chunks.length == 0 ? _eos : concat(chunks, total);\r\n\t\t\t\tif (total + chunk.length <= len) {\r\n\t\t\t\t\tchunks.push(chunk);\r\n\t\t\t\t\ttotal += chunk.length;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tchunks.push(chunk.slice(0, len - total));\r\n\t\t\t\t\tself.unread(chunk.slice(len - total));\r\n\t\t\t\t\ttotal = len;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\treturn concat(chunks, total);\r\n\t\t}\r\n\t\treturn withTimeout && options.timeout ? flows.callWithTimeout(_, _read, options.timeout) : _read(_);\r\n\t};\r\n\t/// * `data = stream.readAll(_)`  \r\n\t///   reads till the end of stream.  \r\n\t///   Equivalent to `stream.read(_, -1)`.\r\n\tself.readAll = function(_) {\r\n\t\tvar result = self.read(_, -1);\r\n\t\treturn result === undefined ? null : result;\r\n\t};\r\n\t/// * `stream.unread(chunk)`  \r\n\t///   pushes the chunk back to the stream.  \r\n\t///   returns `this` for chaining.\r\n\tself.unread = function(chunk) {\r\n\t\tif (chunk) {\r\n\t\t\t_chunks.splice(0, 0, chunk);\r\n\t\t\t_current += chunk.length;\r\n\t\t}\r\n\t\treturn self;\r\n\t};\r\n\r\n\t/// * `len = stream.available()`  \r\n\t///   returns the number of bytes/chars that have been received and not read yet.\r\n\tself.available = function() {\r\n\t\treturn _chunks.reduce(function(count, chunk) {\r\n\t\t\treturn count + chunk.length;\r\n\t\t}, 0);\r\n\t};\r\n}\r\n\r\nexports.ReadableStream = ReadableStream;\r\nReadableStream.prototype = Object.create(Wrapper.prototype);\r\nwrapEvents(ReadableStream, [\"error\", \"data\", \"end\", \"close\"]);\r\n\r\n/// \r\n/// ## WritableStream\r\n/// \r\n/// All writable stream wrappers derive from this wrapper. \r\n/// \r\n/// * `stream = new streams.WritableStream(stream[, options])`  \r\n///   creates a writable stream wrapper.\r\n\r\nfunction WritableStream(emitter, options) {\r\n\tvar self = this;\r\n\tWrapper.call(self, emitter);\r\n\toptions = options || {};\r\n\tvar _error;\r\n\tvar _onDrain;\r\n\r\n\temitter.on('error', function(err) {\r\n\t\tif (_onDrain) _onDrain(err);\r\n\t\telse _error = err;\r\n\t});\r\n\temitter.on('drain', function() {\r\n\t\t_onDrain && _onDrain();\r\n\t});\r\n\r\n\tself.autoClosed.push(function() {\r\n\t\tvar err = new Error(\"stream was closed unexpectedly\");\r\n\t\tif (_onDrain) _onDrain(err);\r\n\t\telse _error = err;\r\n\t});\r\n\r\n\tvar _drain = function(callback) {\r\n\t\t_onDrain = function(err) {\r\n\t\t\t_onDrain = null;\r\n\t\t\tcallback(err);\r\n\t\t\tcallback = null;\r\n\t\t};\r\n\t};\r\n\r\n\t/// * `stream.write(_, data[, enc])`  \r\n\t///   Writes the data.  \r\n\t///   This operation is asynchronous because it _drains_ the stream if necessary.  \r\n\t///   Returns `this` for chaining.\r\n\tself.write = function(_, data, enc) {\r\n\t\tif (_error) throw new Error(_error.message);\r\n\t\t// data == null means end\r\n\t\tif (data != null) {\r\n\t\t\t// if data is empty do nothing but it's not to be interpreted as end\r\n\t\t\tif (!data.length) return self;\r\n\t\t\t//\r\n\t\t\tif (!emitter.write(data, enc || options.encoding)) _drain(_);\r\n\t\t} else {\r\n\t\t\temitter.end();\r\n\t\t}\r\n\t\treturn self;\r\n\t};\r\n\t/// * `stream.end()`  \r\n\t///   signals the end of the send operation.  \r\n\t///   Returns `this` for chaining.\r\n\tself.end = function(data, enc) {\r\n\t\tif (_error) throw new Error(_error.message);\r\n\t\tif (data !== undefined) {\r\n\t\t\temitter.end(data, enc || options.encoding);\r\n\t\t} else {\r\n\t\t\temitter.end();\r\n\t\t}\r\n\t\treturn self;\r\n\t};\r\n}\r\n\r\nexports.WritableStream = WritableStream;\r\nWritableStream.prototype = Object.create(Wrapper.prototype);\r\nwrapEvents(WritableStream, [\"drain\", \"close\"]);\r\n\r\nfunction _getEncodingDefault(headers) {\r\n\tvar comps = (headers['content-type'] || 'text/plain').split(';');\r\n\tvar ctype = comps[0];\r\n\tfor (var i = 1; i < comps.length; i++) {\r\n\t\tvar pair = comps[i].split('=');\r\n\t\tif (pair.length == 2 && pair[0].trim() == 'charset') {\r\n\t\t\tvar enc = pair[1].trim();\r\n\t\t\treturn (enc.toLowerCase() === \"iso-8859-1\") ? \"binary\" : enc;\r\n\t\t}\r\n\t}\r\n\tif (ctype.indexOf('text') >= 0 || ctype.indexOf('json') >= 0) return \"utf8\";\r\n\treturn null;\r\n}\r\n\r\nfunction _getEncodingStrict(headers) {\r\n\t// As per RFC-2616-7.2.1, if media type is unknown we should treat it\r\n\t// as \"application/octet-stream\" (may optionally try to determine it by\r\n\t// looking into content body - we don't)\r\n\tif (!headers['content-type'] || headers['content-encoding']) return null;\r\n\r\n\tvar comps = headers['content-type'].split(';');\r\n\tvar ctype = comps[0];\r\n\tfor (var i = 1; i < comps.length; i++) {\r\n\t\tvar pair = comps[i].split('=');\r\n\t\tif (pair.length === 2 && pair[0].trim() === 'charset') {\r\n\t\t\t// List of charsets: http://www.iana.org/assignments/character-sets/character-sets.xml\r\n\t\t\t// Node Buffer supported encodings: http://nodejs.org/api/buffer.html#buffer_buffer\r\n\t\t\tswitch (pair[1].trim().toLowerCase()) {\r\n\t\t\t\tcase 'utf8':\r\n\t\t\t\t\t// Fallthrough\r\n\t\t\t\tcase 'utf-8':\r\n\t\t\t\t\treturn 'utf8';\r\n\t\t\t\tcase 'utf16le':\r\n\t\t\t\t\t// Fallthrough\r\n\t\t\t\tcase 'utf-16le':\r\n\t\t\t\t\treturn 'utf16le';\r\n\t\t\t\tcase 'us-ascii':\r\n\t\t\t\t\treturn 'ascii';\r\n\t\t\t}\r\n\t\t\treturn null; // we do not understand this charset - do *not* encode\r\n\t\t}\r\n\t}\r\n\treturn null;\r\n}\r\n\r\nfunction _getEncoding(headers, options) {\r\n\tif (!options) return _getEncodingDefault(headers);\r\n\tif (typeof options.detectEncoding === \"function\") return options.detectEncoding(headers);\r\n\tswitch (options.detectEncoding) {\r\n\t\tcase 'strict':\r\n\t\t\treturn _getEncodingStrict(headers);\r\n\t\tcase 'disable':\r\n\t\t\treturn null;\r\n\t\tdefault:\r\n\t\t\treturn _getEncodingDefault(headers);\r\n\t}\r\n}\r\n\r\n/// \r\n/// ## HttpServerRequest\r\n/// \r\n/// This is a wrapper around node's `http.ServerRequest`:\r\n/// This stream is readable (see `ReadableStream` above).\r\n/// \r\n/// * `request = new streams.HttpServerRequest(req[, options])`  \r\n///    returns a wrapper around `req`, an `http.ServerRequest` object.   \r\n///    The `options` parameter can be used to pass `lowMark` and `highMark` values, or\r\n///    to control encoding detection (see section below).\r\n\r\nfunction HttpServerRequest(req, options) {\r\n\tvar self = this;\r\n\tReadableStream.call(self, req, options);\r\n\tself._request = req;\r\n\tself.setEncoding(_getEncoding(req.headers, options));\r\n}\r\n\r\nexports.HttpServerRequest = HttpServerRequest;\r\nHttpServerRequest.prototype = Object.create(ReadableStream.prototype);\r\nHttpServerRequest.prototype.doesNotEmitClose = true;\r\n\r\n/// * `method = request.method` \r\n/// * `url = request.url` \r\n/// * `headers = request.headers` \r\n/// * `trailers = request.trailers` \r\n/// * `httpVersion = request.httpVersion` \r\n/// * `connection = request.connection` \r\n/// * `socket = request.socket`  \r\n///   (same as `http.ServerRequest`)\r\n// TODO: all properties may not be writable - check\r\nwrapProperties(HttpServerRequest, true, [\"method\", \"url\", \"headers\", \"trailers\", \"httpVersion\", \"connection\", \"socket\", \"client\"]);\r\n\r\n/// \r\n/// ## HttpServerResponse\r\n/// \r\n/// This is a wrapper around node's `http.ServerResponse`.  \r\n/// This stream is writable (see `WritableStream` above).\r\n/// \r\n/// * `response = new streams.HttpServerResponse(resp[, options])`  \r\n///   returns a wrapper around `resp`, an `http.ServerResponse` object.\r\n\r\nfunction HttpServerResponse(resp, options) {\r\n\tvar self = this;\r\n\tWritableStream.call(self, resp, options);\r\n\tself._response = resp;\r\n}\r\n\r\nexports.HttpServerResponse = HttpServerResponse;\r\nHttpServerResponse.prototype = Object.create(WritableStream.prototype);\r\nHttpServerResponse.prototype.doesNotEmitClose = true;\r\n\r\n/// * `response.writeContinue()` \r\n/// * `response.writeHead(head)` \r\n/// * `response.setHeader(name, value)` \r\n/// * `value = response.getHeader(head)` \r\n/// * `response.removeHeader(name)` \r\n/// * `response.addTrailers(trailers)` \r\n/// * `response.statusCode = value`  \r\n///   (same as `http.ServerResponse`)\r\nwrapChainMethods(HttpServerResponse, [\"writeContinue\", \"writeHead\", \"setHeader\", \"removeHeader\", \"addTrailers\"]);\r\nwrapMethods(HttpServerResponse, [\"getHeader\"]);\r\nwrapProperties(HttpServerResponse, true, [\"statusCode\"]);\r\n\r\nfunction _fixHttpServerOptions(options) {\r\n\toptions = options || {};\r\n\toptions.createServer = function(callback) {\r\n\t\treturn options.secure ? require(\"https\").createServer(options, callback) : require(\"http\").createServer(callback);\r\n\t};\r\n\treturn options;\r\n}\r\n\r\n// Abstract class shared by HttpServer and NetServer\r\nfunction Server(emitter) {\r\n\tvar self = this;\r\n\tWrapper.call(self, emitter);\r\n\r\n\tself.listen = function(callback, args) {\r\n\t\tif (self.closed) throw new Error(\"cannot listen: server is closed\");\r\n\t\targs = Array.prototype.slice.call(arguments, 1);\r\n\t\t\tfunction reply(err, result) {\r\n\t\t\t\tvar cb = callback;\r\n\t\t\t\tcallback = null;\r\n\t\t\t\tcb && cb(err, result);\r\n\t\t\t}\r\n\t\t\targs.push(function() {\r\n\t\t\t\treply(null, self);\r\n\t\t\t});\r\n\r\n\t\t\tself.autoClosed.push(function() {\r\n\t\t\t\treply(new Error(\"server was closed unexpectedly\"));\r\n\t\t\t});\r\n\t\t\temitter.on('error', reply);\r\n\t\t\temitter.listen.apply(emitter, args);\r\n\t};\r\n}\r\nServer.prototype = Object.create(Wrapper.prototype);\r\n\r\n/// \r\n/// ## HttpServer\r\n/// \r\n/// This is a wrapper around node's `http.Server` object:\r\n/// \r\n/// * `server = streams.createHttpServer(requestListener[, options])`    \r\n///   creates the wrapper.  \r\n///   `requestListener` is called as `requestListener(request, response, _)` \r\n///   where `request` and `response` are wrappers around `http.ServerRequest` and `http.ServerResponse`.  \r\n///   A fresh empty global context is set before every call to `requestListener`. See [streamline/lib/globals](../../globals.md).\r\n/// * `server.listen(_, port[, host])`\r\n/// * `server.listen(_, path)`  \r\n///   (same as `http.Server`)\r\n\r\nexports.createHttpServer = function(requestListener, options) {\r\n\treturn new HttpServer(requestListener, options);\r\n};\r\n\r\nfunction HttpServer(requestListener, options) {\r\n\tvar self = this;\r\n\toptions = _fixHttpServerOptions(options);\r\n\tvar emitter = options.createServer(function(request, response) {\r\n\t\tflows.withContext(function() {\r\n\t\t\trequestListener(new HttpServerRequest(request, options), new HttpServerResponse(response, options), function(err) {\r\n\t\t\t\tif (err) {\r\n\t\t\t\t\tresponse.writeHead(500, {\r\n\t\t\t\t\t\t\"Content-Type\": \"text/plain\"\r\n\t\t\t\t\t});\r\n\t\t\t\t\tresponse.end(err.message + \"\\n\" + err.stack);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t})();\r\n\t});\r\n\tServer.call(self, emitter);\r\n}\r\n\r\nHttpServer.prototype = Object.create(Server.prototype);\r\n// node.js version lower than 0.11.2 do not inmplement a https.Server.setTimeout method.\r\n// As a consequence we need to protect the call in the wrapper\r\nwrapOptionalMethods(HttpServer, [\"setTimeout\"]);\r\n\r\n// deprecated API - use createHttpServer instead\r\nexports.HttpServer = HttpServer;\r\n\r\n/// \r\n/// ## HttpClientResponse\r\n/// \r\n/// This is a wrapper around node's `http.ClientResponse`\r\n/// \r\n/// This stream is readable (see `ReadableStream` above).\r\n/// \r\n/// * `response = new HttpClientResponse(resp, options)`  \r\n///   wraps a node response object.  \r\n///   `options.detectEncoding` and be used to control encoding detection (see section below).\r\n/// * `response = request.response(_)`  \r\n///    returns the response stream.\r\n\r\nfunction HttpClientResponse(resp, options) {\r\n\tvar self = this;\r\n\tReadableStream.call(self, resp, options);\r\n\tself._response = resp;\r\n\tself.setEncoding(_getEncoding(resp.headers, options));\r\n}\r\n\r\nHttpClientResponse.prototype = Object.create(ReadableStream.prototype);\r\n\r\n/// * `status = response.statusCode`  \r\n///    returns the HTTP status code.\r\n/// * `version = response.httpVersion`  \r\n///    returns the HTTP version.\r\n/// * `headers = response.headers`  \r\n///    returns the HTTP response headers.\r\n/// * `trailers = response.trailers`  \r\n///    returns the HTTP response trailers.\r\nwrapProperties(HttpClientResponse, false, [\"statusCode\", \"httpVersion\", \"headers\", \"trailers\"]);\r\n\r\n/// * `response.checkStatus(statuses)`  \r\n///    throws an error if the status is not in the `statuses` array.  \r\n///    If only one status is expected, it may be passed directly as an integer rather than as an array.  \r\n///    Returns `this` for chaining.\r\nHttpClientResponse.prototype.checkStatus = function(statuses) {\r\n\tif (typeof statuses === 'number') statuses = [statuses];\r\n\tif (statuses.indexOf(this.statusCode) < 0) throw new Error(\"invalid status: \" + this.statusCode);\r\n\treturn this;\r\n};\r\n\r\nfunction _fixHttpClientOptions(options) {\r\n\tif (!options) throw new Error(\"request error: no options\");\r\n\tif (typeof options === \"string\") options = {\r\n\t\turl: options\r\n\t};\r\n\tif (options.url) {\r\n\t\tvar parsed = parseUrl(options.url);\r\n\t\toptions.protocol = parsed.protocol;\r\n\t\toptions.host = parsed.hostname;\r\n\t\toptions.port = parsed.port;\r\n\t\toptions.path = parsed.pathname + (parsed.query ? \"?\" + parsed.query : \"\");\r\n\t}\r\n\toptions.protocol = options.protocol || \"http:\";\r\n\toptions.port = options.port || (options.protocol === \"https:\" ? 443 : 80);\r\n\toptions.path = options.path || \"/\";\r\n\tif (!options.host) throw new Error(\"request error: no host\");\r\n\toptions.method = options.method || \"GET\";\r\n\toptions.headers = options.headers || {};\r\n\toptions.module = require(options.protocol.substring(0, options.protocol.length - 1));\r\n\tif (options.user != null) {\r\n\t\t// assumes basic auth for now\r\n\t\tvar token = options.user + \":\" + (options.password || \"\");\r\n\t\ttoken = new Buffer(token, \"utf8\").toString(\"base64\");\r\n\t\toptions.headers.Authorization = \"Basic \" + token;\r\n\t}\r\n\r\n\tif (options.proxy) {\r\n\t\t// Do not use proxy for local requests\r\n\t\tif (options.host !== os.hostname()) {\r\n\t\t\tif (typeof options.proxy === \"string\") {\r\n\t\t\t\toptions.proxy = parseUrl(options.proxy);\r\n\t\t\t\toptions.proxy.host = options.proxy.hostname;\r\n\t\t\t}\r\n\t\t\t// Check excludes\r\n\t\t\tif (!options.proxy.force && options.proxy.excludes && options.proxy.excludes.indexOf(options.host.toLowerCase()) !== -1) {\r\n\t\t\t\t// Do nothing\r\n\t\t\t} else {\r\n\t\t\t\toptions.proxy.port = options.proxy.port || options.port;\r\n\t\t\t\tif (!options.proxy.host) throw new Error(\"proxy configuration error: no host\");\r\n\t\t\t\tif (!options.proxy.port) throw new Error(\"proxy configuration error: no port\");\r\n\t\t\t\toptions.proxy.protocol = options.proxy.protocol || \"http:\";\r\n\t\t\t\t// https requests will be handled with CONNECT method\r\n\t\t\t\toptions.isHttps = options.protocol.substr(0, 5) === \"https\";\r\n\t\t\t\tif (options.isHttps) {\r\n\t\t\t\t\toptions.proxy.module = require(options.proxy.protocol.substring(0, options.proxy.protocol.length - 1));\r\n\t\t\t\t\toptions.proxy.headers = options.proxy.headers || {};\r\n\t\t\t\t\toptions.proxy.headers.host = options.host;\r\n\t\t\t\t} else {\r\n\t\t\t\t\toptions.path = options.protocol + \"//\" + options.host + \":\" + options.port + options.path;\r\n\t\t\t\t\toptions.host = options.proxy.host;\r\n\t\t\t\t\toptions.port = options.proxy.port;\r\n\t\t\t\t\toptions.headers.host = options.host;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (options.proxy.auth) {\r\n\t\t\t\t\tif (options.proxy.auth.toLowerCase() === \"basic\") {\r\n\t\t\t\t\t\tif (!options.proxy.user) throw new Error(\"request error: no proxy user\");\r\n\t\t\t\t\t\tvar proxyToken = options.proxy.user + \":\" + (options.proxy.password || \"\");\r\n\t\t\t\t\t\tproxyToken = new Buffer(proxyToken, \"utf8\").toString(\"base64\");\r\n\t\t\t\t\t\toptions.headers[\"Proxy-Authorization\"] = \"Basic \" + proxyToken;\r\n\t\t\t\t\t} else if (options.proxy.auth.toLowerCase() === \"ntlm\") {\r\n\r\n\t\t\t\t\t\tvar proxyAuthenticator = options.proxy.proxyAuthenticator;\r\n\t\t\t\t\t\tif (!proxyAuthenticator) throw new Error(\"Proxy Authenticator module required\");\r\n\t\t\t\t\t\tif (!proxyAuthenticator.authenticate) throw new Error(\"NTLM Engine module MUST provide 'authenticate' function\");\r\n\t\t\t\t\t\toptions.proxyAuthenticate = proxyAuthenticator.authenticate;\r\n\t\t\t\t\t} else if (options.proxy.auth.toLowerCase() === \"digest\") {\r\n\t\t\t\t\t\tthrow new Error(\"Proxy Digest authentication not yet implemented\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn options;\r\n}\r\n\r\n/// \r\n/// ## HttpClientRequest\r\n/// \r\n/// This is a wrapper around node's `http.ClientRequest`.\r\n/// \r\n/// This stream is writable (see `WritableStream` above).\r\n/// \r\n/// * `request = streams.httpRequest(options)`  \r\n///    creates the wrapper.  \r\n///    The options are the following:\r\n///    * `method`: the HTTP method, `'GET'` by default.\r\n///    * `headers`: the HTTP headers.\r\n///    * `url`: the requested URL (with query string if necessary).\r\n///    * `proxy.url`: the proxy URL.\r\n///    * `lowMark` and `highMark`: low and high water mark values for buffering (in bytes or characters depending\r\n///      on encoding).  \r\n///      Note that these values are only hints as the data is received in chunks.\r\n\r\nfunction HttpClientRequest(options) {\r\n\tvar self = this;\r\n\t//options = _fixHttpClientOptions(options);\r\n\tfunction _init() {\r\n\t\tvar _request = options.module.request(options, function(resp) {\r\n\t\t\t_onResponse(null, resp && new HttpClientResponse(resp, options));\r\n\t\t});\r\n\t\tWritableStream.call(self, _request, options);\r\n\t\tvar _response;\r\n\t\tvar _error;\r\n\t\tvar _done = false;\r\n\r\n\t\t_request.on('error', function(err) {\r\n\t\t\t!_done && _onResponse(err);\r\n\t\t});\r\n\r\n\t\tself.autoClosed.push(function() {\r\n\t\t\t!_done && _onResponse(new Error(\"stream was closed unexpectedly\"));\r\n\t\t});\r\n\r\n\t\tfunction trackResponse(err, resp) {\r\n\t\t\t_done = true;\r\n\t\t\t_error = err;\r\n\t\t\t_response = resp;\r\n\t\t}\r\n\r\n\t\tvar _onResponse = trackResponse;\r\n\t\t/// * `response = request.response(_)`  \r\n\t\t///    returns the response. \r\n\t\tself.response = function(callback) {\r\n\t\t\t\tif (_done) return callback(_error, _response);\r\n\t\t\t\telse _onResponse = function(err, resp) {\r\n\t\t\t\t\t_done = true;\r\n\t\t\t\t\tcallback(err, resp);\r\n\t\t\t\t\tcallback = null;\r\n\t\t\t\t};\r\n\t\t\t};\r\n\t}\r\n\r\n\tif (!options.proxyAuthenticate && !options.isHttps) _init();\r\n\r\n\tself.proxyConnect = function(_) {\r\n\t\tif (options.isHttps) {\r\n\t\t\t// TODO: Don't authenticate with ntlm, nodejs raises \"Parse error\" in return of connect with 407 -> HPE_INVALID_CONSTANT\r\n\t\t\treturn (function(callback) {\r\n\t\t\t\tvar proxyOpt = {\r\n\t\t\t\t\t\thost: options.proxy.host,\r\n\t\t\t\t\t\tport: options.proxy.port,\r\n\t\t\t\t\t\tmethod: 'CONNECT',\r\n\t\t\t\t\t\tpath: options.host + \":\" + options.port,\r\n\t\t\t\t\t\theaders: options.proxy.headers\r\n\t\t\t\t\t};\r\n\t\t\t\t// open proxy socket\r\n\t\t\t\toptions.proxy.module.request(proxyOpt).on('connect', function(res, socket, head) {\r\n\t\t\t\t\toptions.socket = socket;\r\n\t\t\t\t\toptions.agent = false;\r\n\t\t\t\t\t//\r\n\t\t\t\t\t_init();\r\n\t\t\t\t\tcallback(null, self);\r\n\t\t\t\t\tcallback = null;\r\n\t\t\t\t}).on('error', function(err) {\r\n\t\t\t\t\tcallback(err);\r\n\t\t\t\t\tcallback = null;\r\n\t\t\t\t}).end();\r\n\t\t\t\treturn self;\r\n\t\t\t})(_);\r\n\t\t} else //\r\n\t\t\tif (options.proxyAuthenticate) {\r\n\t\t\t\toptions.proxyAuthenticate(_, options);\r\n\t\t\t\t_init();\r\n\t\t\t}\r\n\t\treturn self;\r\n\t};\r\n}\r\n\r\nHttpClientRequest.prototype = Object.create(WritableStream.prototype);\r\n\r\n/// * `request.abort()`  \r\n///    aborts the request. \r\nwrapChainMethods(HttpClientRequest, [\"abort\"]);\r\nHttpClientRequest.prototype.setTimeout = function(ms) {\r\n\tvar self = this;\r\n\tthis.emitter.setTimeout(ms, function() {\r\n\t\tself.emitter.emit('error', 'timeout');\r\n\t});\r\n\treturn this;\r\n}\r\n\r\nexports.httpRequest = function(options) {\r\n\toptions = _fixHttpClientOptions(options);\r\n\treturn new HttpClientRequest(options);\r\n};\r\n\r\n/// \r\n/// ## NetStream\r\n/// \r\n/// This is a wrapper around streams returned by TCP and socket clients:\r\n/// \r\n/// These streams are both readable and writable (see `ReadableStream` and `WritableStream` above).\r\n/// \r\n/// * `stream = new streams.NetStream(stream[, options])`  \r\n///    creates a network stream wrapper.\r\n\r\nfunction NetStream(emitter, options) {\r\n\tvar self = this;\r\n\tReadableStream.call(self, emitter, options.read || options);\r\n\tWritableStream.call(self, emitter, options.write || options);\r\n}\r\nNetStream.prototype = Object.create(ReadableStream.prototype);\r\nObject.keys(WritableStream.prototype).forEach(function(key) {\r\n\tNetStream.prototype[key] = WritableStream.prototype[key];\r\n});\r\n\r\nwrapChainMethods(NetStream, [\"setTimeout\", \"setNoDelay\", \"setKeepAlive\", \"ref\", \"unref\", \"destroy\"]);\r\nwrapMethods(NetStream, [\"address\"]);\r\nwrapProperties(NetStream, false, [\"localAddress\", \"localPort\", \"remoteAddress\", \"remotePort\"]);\r\n\r\nexports.NetStream = NetStream;\r\n\r\nvar net; // lazy require\r\n/// \r\n/// ## TCP and Socket clients\r\n/// \r\n/// These are wrappers around node's `net.createConnection`:\r\n/// \r\n/// * `client = streams.tcpClient(port, host[, options])`  \r\n///    returns a TCP connection client.\r\n/// * `client = streams.socketClient(path[, options])`  \r\n///    returns a socket client.  \r\n///    The `options` parameter of the constructor provide options for the stream (`lowMark` and `highMark`). \r\n///    If you want different options for `read` and `write` operations, you can specify them by creating `options.read` and `options.write` sub-objects inside `options`.\r\nexports.tcpClient = function(port, host, options) {\r\n\thost = host || \"localhost\";\r\n\toptions = options || {};\r\n\treturn new NetClient(options, port, host);\r\n};\r\nexports.socketClient = function(path, options) {\r\n\toptions = options || {};\r\n\treturn new NetClient(options, path);\r\n};\r\n\r\nfunction NetClient(options, args) {\r\n\tvar self = this;\r\n\targs = Array.prototype.slice.call(arguments, 1);\r\n\tnet = net || require(\"net\");\r\n\tvar _connection = net.createConnection.apply(net, args);\r\n\tvar _error;\r\n\tvar _done = false;\r\n\r\n\t_connection.on('error', function(err) {\r\n\t\t!_done && _onConnect(err);\r\n\t});\r\n\r\n\t_connection.on('connect', function() {\r\n\t\t_onConnect(null);\r\n\t});\r\n\r\n\tfunction trackConnect(err) {\r\n\t\t_done = true;\r\n\t\t_error = err;\r\n\t};\r\n\r\n\tvar _onConnect = trackConnect;\r\n\r\n\t/// * `stream = client.connect(_)`  \r\n\t///    connects the client and returns a network stream.\r\n\tself.connect = function(callback) {\r\n\t\t\tif (_done) return callback(_error, new NetStream(_connection, options));\r\n\t\t\telse _onConnect = function(err) {\r\n\t\t\t\t_done = true;\r\n\t\t\t\tcallback(err, new NetStream(_connection, options));\r\n\t\t\t\tcallback = null;\r\n\t\t\t};\r\n\t\t};\r\n}\r\n\r\n/// \r\n/// ## NetServer\r\n/// \r\n/// This is a wrapper around node's `net.Server` object:\r\n/// \r\n/// * `server = streams.createNetServer([serverOptions,] connectionListener [, streamOptions])`    \r\n///   creates the wrapper.  \r\n///   `connectionListener` is called as `connectionListener(stream, _)` \r\n///   where `stream` is a `NetStream` wrapper around the native connection.  \r\n///   A fresh empty global context is set before every call to `connectionListener`. See [streamline/lib/globals](../../globals.md).\r\n/// * `server.listen(_, port[, host])`  \r\n/// * `server.listen(_, path)`  \r\n///   (same as `net.Server`)\r\n\r\nexports.createNetServer = function(serverOptions, connectionListener, streamOptions) {\r\n\treturn new NetServer(serverOptions, connectionListener, streamOptions);\r\n};\r\n\r\nfunction NetServer(serverOptions, connectionListener, streamOptions) {\r\n\tvar self = this;\r\n\tif (typeof(serverOptions) === 'function') {\r\n\t\tstreamOptions = connectionListener;\r\n\t\tconnectionListener = serverOptions;\r\n\t\tserverOptions = {};\r\n\t}\r\n\tnet = net || require(\"net\");\r\n\tvar emitter = net.createServer(serverOptions, function(connection) {\r\n\t\tflows.withContext(function() {\r\n\t\t\tconnectionListener(new NetStream(connection, streamOptions || {}), function(err) {\r\n\t\t\t\tif (err) throw err;\r\n\t\t\t});\r\n\t\t})();\r\n\t});\r\n\tServer.call(self, emitter);\r\n}\r\nNetServer.prototype = Object.create(Server.prototype);\r\n\r\n/// \r\n/// ## try/finally wrappers and pump\r\n/// \r\n/// * `result = streams.using(_, constructor, stream[, options], fn)`  \r\n///    wraps `stream` with an instance of `constructor`;\r\n///    passes the wrapper to `fn(_, wrapper)` and closes the stream after `fn` returns.  \r\n///    `fn` is called inside a `try/finally` block to guarantee that the stream is closed in all cases.  \r\n///    Returns the value returned by `fn`.\r\nexports.using = function(_, constructor, emitter, options, fn) {\r\n\tif (!fn && typeof options === 'function') fn = options, options = null;\r\n\tvar stream = new constructor(emitter, options);\r\n\ttry {\r\n\t\treturn fn.call(this, _, stream);\r\n\t} finally {\r\n\t\tstream.close(_);\r\n\t}\r\n};\r\n\r\n/// * `result = streams.usingReadable(_, stream[, options], fn)`  \r\n///    shortcut for `streams.using(_, streams.ReadableStream, stream, options, fn)` \r\nexports.usingReadable = function(_, emitter, options, fn) {\r\n\treturn exports.using.call(this, _, exports.ReadableStream, emitter, options, fn);\r\n};\r\n\r\n/// * `result = streams.usingWritable(_, stream[, options], fn)`  \r\n///    shortcut for `streams.using(_, streams.WritableStream, stream, options, fn)` \r\nexports.usingWritable = function(_, emitter, options, fn) {\r\n\treturn exports.using.call(this, _, exports.WritableStream, emitter, options, fn);\r\n};\r\n\r\n/// * `streams.pump(_, inStream, outStream)`  \r\n///    Pumps from `inStream` to `outStream`.  \r\n///    Does not close the streams at the end.\r\nexports.pump = function(_, inStream, outStream) {\r\n\tvar data;\r\n\twhile (data = inStream.read(_)) outStream.write(_, data);\r\n};\r\n/// \r\n/// ## Encoding detection\r\n/// \r\n/// The `options.detectEncoding` option controls how the encoding is sent by the\r\n/// `HttpServerRequest` and `HttpClientResponse` constructors.  \r\n/// This option can take the following values:\r\n/// \r\n/// * `strict`: the RFC-2616-7.2.1 rules are applied.\r\n/// * `default`: the default algorithm used by streamline v0.4 is used. \r\n///    This algorithm is more lenient and sets the encoding to `utf8` when text content is detected, even\r\n///    if there is no charset indication.\r\n/// * `disable`: null is always returned and the stream is always handled in binary mode (buffers rather than strings).\r\n/// * a function. This is a hook for custom encoding detection. \r\n///   The function is called as `fn(headers)` and returns the encoding.\r\n/// \r\n"
	]
}