예제 #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;
         }
         _responseHeaders.LastModified = _lastModified;
         _responseHeaders.ETag         = _etag;
         _responseHeaders.Headers[HeaderNames.AcceptRanges] = "bytes";
     }
     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()
     {
         Context = _context,
         File    = _fileInfo,
     });
 }