Commit cb195ce6 authored by Tim Neutkens's avatar Tim Neutkens

Bring file back to original

parent 1fe82751
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* Copyright(c) 2014 Jonathan Ong * Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson * Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed * MIT Licensed
*/var n=i(909);var s=i(291).Buffer;var o=i(666);var c=i(876);var t=i(937)("compression");var p=i(849);var r=i(850);var l=i(796);e.exports=compression;e.exports.filter=shouldCompress;var u=/(?:^|,)\s*?no-transform\s*?(?:,|$)/;function compression(e){var a=e||{};var i=a.filter||shouldCompress;var s=o.parse(a.threshold);if(s==null){s=1024}return function compression(e,o,c){var u=false;var m;var d=[];var x;var v=o.end;var f=o.on;var b=o.write;o.flush=function flush(){if(x){x.flush()}};o.write=function write(e,a){if(u){return false}if(!this._header){this._implicitHeader()}return x?x.write(toBuffer(e,a)):b.call(this,e,a)};o.end=function end(e,a){if(u){return false}if(!this._header){if(!this.getHeader("Content-Length")){m=chunkLength(e,a)}this._implicitHeader()}if(!x){return v.call(this,e,a)}u=true;return e?x.end(toBuffer(e,a)):x.end()};o.on=function on(e,a){if(!d||e!=="drain"){return f.call(this,e,a)}if(x){return x.on(e,a)}d.push([e,a]);return this};function nocompress(e){t("no compression: %s",e);addListeners(o,f,d);d=null}p(o,(function onResponseHeaders(){if(!i(e,o)){nocompress("filtered");return}if(!shouldTransform(e,o)){nocompress("no transform");return}r(o,"Accept-Encoding");if(Number(o.getHeader("Content-Length"))<s||m<s){nocompress("size below threshold");return}var c=o.getHeader("Content-Encoding")||"identity";if(c!=="identity"){nocompress("already encoded");return}if(e.method==="HEAD"){nocompress("HEAD request");return}var p=n(e);var u=p.encoding(["gzip","deflate","identity"]);if(u==="deflate"&&p.encoding(["gzip"])){u=p.encoding(["gzip","identity"])}if(!u||u==="identity"){nocompress("not acceptable");return}t("%s compression",u);x=u==="gzip"?l.createGzip(a):l.createDeflate(a);addListeners(x,x.on,d);o.setHeader("Content-Encoding",u);o.removeHeader("Content-Length");x.on("data",(function onStreamData(e){if(b.call(o,e)===false){x.pause()}}));x.on("end",(function onStreamEnd(){v.call(o)}));f.call(o,"drain",(function onResponseDrain(){x.resume()}))}));c()}}function addListeners(e,a,i){for(var n=0;n<i.length;n++){a.apply(e,i[n])}}function chunkLength(e,a){if(!e){return 0}return!s.isBuffer(e)?s.byteLength(e,a):e.length}function shouldCompress(e,a){var i=a.getHeader("Content-Type");console.log(e.url,i,c(i));if(i===undefined||!c(i)){t("%s not compressible",i);return false}return true}function shouldTransform(e,a){var i=a.getHeader("Cache-Control");return!i||!u.test(i)}function toBuffer(e,a){return!s.isBuffer(e)?s.from(e,a):e}},183:(e,a,i)=>{ */var n=i(909);var s=i(291).Buffer;var o=i(666);var c=i(876);var t=i(937)("compression");var p=i(849);var r=i(850);var l=i(796);e.exports=compression;e.exports.filter=shouldCompress;var u=/(?:^|,)\s*?no-transform\s*?(?:,|$)/;function compression(e){var a=e||{};var i=a.filter||shouldCompress;var s=o.parse(a.threshold);if(s==null){s=1024}return function compression(e,o,c){var u=false;var m;var d=[];var x;var v=o.end;var f=o.on;var b=o.write;o.flush=function flush(){if(x){x.flush()}};o.write=function write(e,a){if(u){return false}if(!this._header){this._implicitHeader()}return x?x.write(toBuffer(e,a)):b.call(this,e,a)};o.end=function end(e,a){if(u){return false}if(!this._header){if(!this.getHeader("Content-Length")){m=chunkLength(e,a)}this._implicitHeader()}if(!x){return v.call(this,e,a)}u=true;return e?x.end(toBuffer(e,a)):x.end()};o.on=function on(e,a){if(!d||e!=="drain"){return f.call(this,e,a)}if(x){return x.on(e,a)}d.push([e,a]);return this};function nocompress(e){t("no compression: %s",e);addListeners(o,f,d);d=null}p(o,(function onResponseHeaders(){if(!i(e,o)){nocompress("filtered");return}if(!shouldTransform(e,o)){nocompress("no transform");return}r(o,"Accept-Encoding");if(Number(o.getHeader("Content-Length"))<s||m<s){nocompress("size below threshold");return}var c=o.getHeader("Content-Encoding")||"identity";if(c!=="identity"){nocompress("already encoded");return}if(e.method==="HEAD"){nocompress("HEAD request");return}var p=n(e);var u=p.encoding(["gzip","deflate","identity"]);if(u==="deflate"&&p.encoding(["gzip"])){u=p.encoding(["gzip","identity"])}if(!u||u==="identity"){nocompress("not acceptable");return}t("%s compression",u);x=u==="gzip"?l.createGzip(a):l.createDeflate(a);addListeners(x,x.on,d);o.setHeader("Content-Encoding",u);o.removeHeader("Content-Length");x.on("data",(function onStreamData(e){if(b.call(o,e)===false){x.pause()}}));x.on("end",(function onStreamEnd(){v.call(o)}));f.call(o,"drain",(function onResponseDrain(){x.resume()}))}));c()}}function addListeners(e,a,i){for(var n=0;n<i.length;n++){a.apply(e,i[n])}}function chunkLength(e,a){if(!e){return 0}return!s.isBuffer(e)?s.byteLength(e,a):e.length}function shouldCompress(e,a){var i=a.getHeader("Content-Type");if(i===undefined||!c(i)){t("%s not compressible",i);return false}return true}function shouldTransform(e,a){var i=a.getHeader("Cache-Control");return!i||!u.test(i)}function toBuffer(e,a){return!s.isBuffer(e)?s.from(e,a):e}},183:(e,a,i)=>{
/*! /*!
* mime-db * mime-db
* Copyright(c) 2014 Jonathan Ong * Copyright(c) 2014 Jonathan Ong
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment