protected override bool DoProcessRequest(HttpContext context, MediaRequest request, Sitecore.Resources.Media.Media media) { Assert.ArgumentNotNull((object)context, "context"); Assert.ArgumentNotNull((object)request, "request"); Assert.ArgumentNotNull((object)media, "media"); if (this.Modified(context, media, request.Options) == Tristate.False) { Event.RaiseEvent("media:request", new object[1] { (object)request }); this.SendMediaHeaders(media, context); context.Response.StatusCode = 304; return(true); } this.ProcessImageDimensions(request, media); MediaStream stream = media.GetStream(request.Options); if (stream == null) { return(false); } Event.RaiseEvent("media:request", new object[1] { (object)request }); if (Settings.Media.EnableRangeRetrievalRequest && Settings.Media.CachingEnabled) { using (stream) { this.SendMediaHeaders(media, context); new RangeRetrievalResponse(RangeRetrievalRequest.BuildRequest(context, media), stream).ExecuteRequest(context); return(true); } } else { this.SendMediaHeaders(media, context); this.SendStreamHeaders(stream, context); using (stream) { context.Response.AddHeader("Content-Length", stream.Stream.Length.ToString()); WebUtil.TransmitStream(stream.Stream, context.Response, Settings.Media.StreamBufferSize); } return(true); } }
protected override bool DoProcessRequest(HttpContext context, MediaRequest request, Media media) { Assert.ArgumentNotNull((object)context, nameof(context)); Assert.ArgumentNotNull((object)request, nameof(request)); Assert.ArgumentNotNull((object)media, nameof(media)); //OverRiding the Default Stream behavior to return CDN inage ProcessCdnRedirect(context, media); if (this.Modified(context, media, request.Options) == Tristate.False) { this.RaiseEvent(Helper.Constants.Properties.MediaRequest, request); this.SendMediaHeaders(media, context); context.Response.StatusCode = 304; return(true); } this.ProcessImageDimensions(request, media); MediaStream mediaStream = this.GetMediaStream(media, request); if (mediaStream == null) { return(false); } this.RaiseEvent(Helper.Constants.Properties.MediaRequest, request); if (Settings.Media.EnableRangeRetrievalRequest && Settings.Media.CachingEnabled) { using (mediaStream) { this.SendMediaHeaders(media, context); new RangeRetrievalResponse(RangeRetrievalRequest.BuildRequest(context, media), mediaStream).ExecuteRequest(context); return(true); } } else { this.SendMediaHeaders(media, context); this.SendStreamHeaders(mediaStream, context); using (mediaStream) { context.Response.AddHeader(Helper.Constants.Properties.ContentLength, mediaStream.Stream.Length.ToString()); WebUtil.TransmitStream(mediaStream.Stream, context.Response, Settings.Media.StreamBufferSize); } return(true); } }