Пример #1
0
 public void ApplyResponseHeaders(int statusCode)
 {
     _response.StatusCode = statusCode;
     if (statusCode < 400)
     {
         // these headers are returned for 200, 206, and 304
         // they are not returned for 412 and 416
         if (!string.IsNullOrEmpty(_contentType))
         {
             _response.ContentType = _contentType;
         }
         _response.Headers.Set(Constants.LastModified, _lastModifiedString);
         _response.ETag = _etagQuoted;
     }
     if (statusCode == Constants.Status200Ok)
     {
         // this header is only returned here for 200
         // it already set to the returned range for 206
         // it is not returned for 304, 412, and 416
         _response.ContentLength = _length;
     }
     _options.OnPrepareResponse(new StaticFileResponseContext()
     {
         OwinContext = _context,
         File        = _fileInfo,
     });
 }
Пример #2
0
        public void ApplyResponseHeaders(int statusCode)
        {
            _response.StatusCode = statusCode;
            if (statusCode < 400)
            {
                // these headers are returned for 200, 206, and 304
                // they are not returned for 412 and 416
                if (!string.IsNullOrEmpty(_contentType))
                {
                    _response.ContentType = _contentType;
                }
                //////////_response.Headers.Set(Constants.LastModified, _lastModifiedString);
                //////////_response.ETag = _etagQuoted;
            }
            if (statusCode == Constants.Status200Ok)
            {
                // this header is only returned here for 200
                // it already set to the returned range for 206
                // it is not returned for 304, 412, and 416
                _response.ContentLength = _length;
            }

            Console.WriteLine("[LOG] -> " + statusCode + ": " + _response.Context.Request.Uri.ToString().Replace("http://192.168.56.101:60000/", string.Empty));

            _response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
            _response.Headers["Pragma"]        = "no-cache";
            _response.Headers["Expires"]       = "0";
            _options.OnPrepareResponse(new StaticFileResponseContext()
            {
                OwinContext = _context,
                File        = _fileInfo,
            });
        }