%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : C:/Windows/SystemApps/Microsoft.Windows.Cortana_cw5n1h2txyewy/dss_service/node_modules/send/lib/
Upload File :
Create Path :
Current File : C:/Windows/SystemApps/Microsoft.Windows.Cortana_cw5n1h2txyewy/dss_service/node_modules/send/lib/send.js

/*!
Copyright (c) Microsoft Corporation.  All rights reserved.  
This file is based on or incorporates material from the projects listed below (collectively, Third Party Code). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. 
Send v0.5.0
Copyright (c) 2012 TJ Holowaychuck  <vision-media.ca>
MIT License 
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function send(n,t,i){return new SendStream(n,t,i)}function SendStream(n,t,i){var r=this;i=i||{};this.req=n;this.path=t;this.options=i;this.etag("etag"in i?i.etag:!0);this.maxage(i.maxage);this.hidden(i.hidden);this.index("index"in i?i.index:"index.html");(i.root||i.from)&&this.root(i.root||i.from)}var debug=require("debug")("send"),escapeHtml=require("escape-html"),parseRange=require("range-parser"),Stream=require("stream"),mime=require("mime"),fresh=require("fresh"),path=require("path"),http=require("http"),onFinished=require("finished"),fs=require("fs"),basename=path.basename,normalize=path.normalize,join=path.join,utils=require("./utils"),EventEmitter=require("events").EventEmitter,ms=require("ms"),upPathRegexp=/(?:^|[\\\/])\.\.(?:[\\\/]|$)/,listenerCount;exports=module.exports=send;exports.mime=mime;listenerCount=EventEmitter.listenerCount||function(n,t){return n.listeners(t).length};SendStream.prototype.__proto__=Stream.prototype;SendStream.prototype.etag=function(n){return n=Boolean(n),debug("etag %s",n),this._etag=n,this};SendStream.prototype.hidden=function(n){return n=Boolean(n),debug("hidden %s",n),this._hidden=n,this};SendStream.prototype.index=function(n){var t=n?Array.isArray(n)?n:[n]:[];return debug("index %o",n),this._index=t,this};SendStream.prototype.root=SendStream.prototype.from=function(n){return n=String(n),this._root=normalize(n),this};SendStream.prototype.maxage=function(n){return n=typeof n=="string"?ms(n):Number(n),isNaN(n)&&(n=0),Infinity==n&&(n=31536e6),debug("max-age %d",n),this._maxage=n,this};SendStream.prototype.error=function(n,t){var i=this.res,r=http.STATUS_CODES[n];if(t=t||new Error(r),t.status=n,listenerCount(this,"error")!==0)return this.emit("error",t);i._headers=undefined;i.statusCode=t.status;i.end(r)};SendStream.prototype.isMalicious=function(){return!this._root&&~this.path.indexOf("..")&&upPathRegexp.test(this.path)};SendStream.prototype.hasTrailingSlash=function(){return"/"==this.path[this.path.length-1]};SendStream.prototype.hasLeadingDot=function(){return"."==basename(this.path)[0]};SendStream.prototype.isConditionalGET=function(){return this.req.headers["if-none-match"]||this.req.headers["if-modified-since"]};SendStream.prototype.removeContentHeaderFields=function(){var n=this.res;Object.keys(n._headers).forEach(function(t){0==t.indexOf("content")&&n.removeHeader(t)})};SendStream.prototype.notModified=function(){var n=this.res;debug("not modified");this.removeContentHeaderFields();n.statusCode=304;n.end()};SendStream.prototype.headersAlreadySent=function(){var n=new Error("Can't set headers after they are sent.");debug("headers already sent");this.error(500,n)};SendStream.prototype.isCachable=function(){var n=this.res;return n.statusCode>=200&&n.statusCode<300||304==n.statusCode};SendStream.prototype.onStatError=function(n){if(~["ENOENT","ENAMETOOLONG","ENOTDIR"].indexOf(n.code))return this.error(404,n);this.error(500,n)};SendStream.prototype.isFresh=function(){return fresh(this.req.headers,this.res._headers)};SendStream.prototype.isRangeFresh=function(){var n=this.req.headers["if-range"];return n?~n.indexOf('"')?~n.indexOf(this.res._headers.etag):Date.parse(this.res._headers["last-modified"])<=Date.parse(n):!0};SendStream.prototype.redirect=function(n){if(listenerCount(this,"directory")!==0)return this.emit("directory");if(this.hasTrailingSlash())return this.error(403);var t=this.res;n+="/";t.statusCode=301;t.setHeader("Content-Type","text/html; charset=utf-8");t.setHeader("Location",n);t.end('Redirecting to <a href="'+escapeHtml(n)+'">'+escapeHtml(n)+"<\/a>\n")};SendStream.prototype.pipe=function(n){var i=this,u=arguments,t=this.path,r=this._root;return(this.res=n,t=utils.decode(t),-1==t)?this.error(400):~t.indexOf('\0')?this.error(400):(r&&(t=normalize(join(this._root,t))),this.isMalicious())?this.error(403):r&&0!=t.indexOf(r)?this.error(403):!this._hidden&&this.hasLeadingDot()?this.error(404):this._index.length&&this.hasTrailingSlash()?(this.sendIndex(t),n):(debug('stat "%s"',t),fs.stat(t,function(n,r){if(n)return i.onStatError(n);if(r.isDirectory())return i.redirect(i.path);i.emit("file",t,r);i.send(t,r)}),n)};SendStream.prototype.send=function(n,t){var r=this.options,u=t.size,f=this.res,s=this.req,i=s.headers.range,e=r.start||0,o;if(f._header)return this.headersAlreadySent();if(this.setHeader(n,t),this.type(n),this.isConditionalGET()&&this.isCachable()&&this.isFresh())return this.notModified();if(u=Math.max(0,u-e),r.end!==undefined&&(o=r.end-e+1,u>o&&(u=o)),i){if(i=parseRange(u,i),this.isRangeFresh()||(debug("range stale"),i=-2),-1==i)return debug("range unsatisfiable"),f.setHeader("Content-Range","bytes */"+t.size),this.error(416);-2!=i&&i.length===1&&(debug("range %j",i),r.start=e+i[0].start,r.end=e+i[0].end,f.statusCode=206,f.setHeader("Content-Range","bytes "+i[0].start+"-"+i[0].end+"/"+u),u=r.end-r.start+1)}if(f.setHeader("Content-Length",u),"HEAD"==s.method)return f.end();this.stream(n,r)};SendStream.prototype.sendIndex=function(n){function i(u){if(++r>=t._index.length)return u?t.onStatError(u):t.error(404);var f=n+t._index[r];debug('stat "%s"',f);fs.stat(f,function(n,r){if(n)return i(n);if(r.isDirectory())return i();t.emit("file",f,r);t.send(f,r)})}var r=-1,t=this;this.hasTrailingSlash()||(n+="/");i()};SendStream.prototype.stream=function(n,t){var r=!1,f=this,u=this.res,e=this.req,i=fs.createReadStream(n,t);this.emit("stream",i);i.pipe(u);onFinished(u,function(){r=!0;i.destroy()});i.on("error",function(n){if(!r){if(r=!0,i.destroy(),u._header){console.error(n.stack);e.destroy();return}f.onStatError(n)}});i.on("end",function(){f.emit("end")})};SendStream.prototype.type=function(n){var r=this.res,t,i;r.getHeader("Content-Type")||(t=mime.lookup(n),i=mime.charsets.lookup(t),debug("content-type %s",t),r.setHeader("Content-Type",t+(i?"; charset="+i:"")))};SendStream.prototype.setHeader=function(n,t){var i=this.res,r;this.emit("headers",i,n,t);i.getHeader("Accept-Ranges")||i.setHeader("Accept-Ranges","bytes");i.getHeader("Date")||i.setHeader("Date",(new Date).toUTCString());i.getHeader("Cache-Control")||i.setHeader("Cache-Control","public, max-age="+Math.floor(this._maxage/1e3));i.getHeader("Last-Modified")||i.setHeader("Last-Modified",t.mtime.toUTCString());this._etag&&!i.getHeader("ETag")&&(r=utils.etag(n,t),debug("etag %s",r),i.setHeader("ETag",r))}

Zerion Mini Shell 1.0