public void FireAuthorizeImage(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlAuthorizationEventArgs e) { if (AuthorizeImage != null) { AuthorizeImage(sender, context, e); } }
void Pipeline_Rewrite(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlEventArgs e) { var os = provider.GetOverlays(e.VirtualPath, e.QueryString); if (os == null) { return; } long hash = 0xab224895; int offset = 0; foreach (Overlay o in os) { int ohash = o.GetDataHashCode(); string physicalPath = HostingEnvironment.MapPath(o.OverlayPath); try{ ohash ^= (int)(File.GetLastWriteTimeUtc(physicalPath).Ticks / (TimeSpan.TicksPerMillisecond * 5)); }catch {} hash ^= ohash << (offset % 50); offset += 31; } //Store a hash of all the overlays, so the disk cache updates when an overlay changes e.QueryString["customoverlay.hash"] = hash.ToString(); //And save the overlays for later RequestOverlays = os; }
public void FireImageMissing(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlEventArgs e) { if (ImageMissing != null) { ImageMissing(sender, context, e); } }
public void FireRewritingEvents(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlEventArgs e) { //TODO: this approach is non-intuitive.... //Fire first event (results will stay in e) if (Rewrite != null) { Rewrite(sender, context, e); } //Copy querystring for use in 'defaults' even NameValueCollection copy = new NameValueCollection(e.QueryString); //Copy so we can later overwrite q with the rewrite values. //Fire defaults event. if (RewriteDefaults != null) { RewriteDefaults(sender, context, e); } //Overwrite with querystring values again - this is what makes applyDefaults applyDefaults, vs. being applyOverrides. foreach (string k in copy) { if (copy[k] != null) //Don't allow null values to override defaults. Empty values can, however. { e.QueryString[k] = copy[k]; } } //Fire final event if (PostRewrite != null) { PostRewrite(sender, context, e); } }
void Pipeline_PostRewrite(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlEventArgs e) { if (IsRemotePath(e.VirtualPath)) { //Force images to be processed - don't allow them to only cache it. e.QueryString["process"] = ProcessWhen.Always.ToString().ToLowerInvariant(); } }
public void FirePreHandleImage(System.Web.IHttpModule sender, System.Web.HttpContext context, IResponseArgs e) { System.Threading.Interlocked.Increment(ref processedCount); if (PreHandleImage != null) { PreHandleImage(sender, context, e); } }
void Pipeline_PostAuthorizeRequestStart(System.Web.IHttpModule sender, System.Web.HttpContext context) { if (redirectThrough != null && c.Pipeline.ModifiedQueryString.Count > 0) { //It wasn't a cloudfront URL - it had a normal querystring context.Items[c.Pipeline.ModifiedPathKey + ".hadquery"] = true; } //Transform semicolon querystrings into the normal collection TransformCloudFrontUrl(context); }
void Pipeline_PostAuthorizeRequestStart(System.Web.IHttpModule sender, System.Web.HttpContext context) { if (HandlesRequest(context, c)) { //Communicate to the MVC plugin this request should not be affected by the UrlRoutingModule. context.Items[c.Pipeline.StopRoutingKey] = true; //Provide the request handler context.RemapHandler(new EndpointPluginPageHandler(ProcessRequest)); } }
/// <summary> /// This is where we hijack the resizing process, interrupt it, and send back the json data we created. /// </summary> /// <param name="sender"></param> /// <param name="context"></param> /// <param name="e"></param> void Pipeline_PreHandleImage(System.Web.IHttpModule sender, System.Web.HttpContext context, Caching.IResponseArgs e) { if (e.RewrittenQuerystring.Get("resizer.debug", DebugType.None) != DebugType.None) { InjectRequestMod(e as ResponseArgs); if (!Diagnostic.AllowResponse(context, this.c)) { throw GetResponseException(Diagnostic.DisabledNotice(c)); } } }
void Pipeline_RewriteDefaults(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlEventArgs e) { //Set the XXX of /remote.XXX to the real extension used by the remote file. //Allows the output extension and mime-type default to be determined correctly if (IsRemotePath(e.VirtualPath) && !string.IsNullOrEmpty(e.QueryString[Base64UrlKey])) { string ext = PathUtils.GetExtension(PathUtils.FromBase64UToString(e.QueryString[Base64UrlKey])); if (!string.IsNullOrEmpty(ext) && c.Pipeline.IsAcceptedImageType("." + ext)) { e.VirtualPath = PathUtils.SetExtension(e.VirtualPath, ext); } } }
void Pipeline_PostAuthorizeRequestStart(System.Web.IHttpModule sender, System.Web.HttpContext context) { if ((context.Request.FilePath.EndsWith("/resizer.debug", StringComparison.OrdinalIgnoreCase) || context.Request.FilePath.EndsWith("/resizer.debug.ashx", StringComparison.OrdinalIgnoreCase))) { //Communicate to the MVC plugin this request should not be affected by the UrlRoutingModule. context.Items[c.Pipeline.StopRoutingKey] = true; //Provide the request handler IHttpHandler handler = AllowResponse(context) ? (IHttpHandler) new DiagnosticPageHandler(c) : (IHttpHandler) new DiagnosticDisabledHandler(c); context.RemapHandler(handler); // The following line of code does nothing. I don't think there is any way to make this work before .NET 2.0 SP2 //context.Handler = handler; } }
void Pipeline_RewriteDefaults(System.Web.IHttpModule sender, System.Web.HttpContext context, IUrlEventArgs e) { ///Handle redirectThrough behavior if (redirectThrough != null && context.Items[c.Pipeline.ModifiedPathKey + ".hadquery"] != null) { //It had a querystring originally - which means the request didn't come from CloudFront, it came directly from the browser. Perform a redirect, rewriting the querystring appropriately string finalPath = redirectThrough + e.VirtualPath + PathUtils.BuildSemicolonQueryString(e.QueryString, true); //Redirect according to setting context.Response.Redirect(finalPath, !redirectPermanent); if (redirectPermanent) { context.Response.StatusCode = 301; context.Response.End(); } } }
public void FirePostAuthorizeRequest(System.Web.IHttpModule sender, System.Web.HttpContext httpContext) { //The one-time event if (!firstRequestFinished) { lock (firedFirstRequestSync) { if (!firedFirstRequest) { firedFirstRequest = true; if (OnFirstRequest != null) { OnFirstRequest(sender, httpContext); } firstRequestFinished = true; } } } //And the main event if (PostAuthorizeRequestStart != null) { PostAuthorizeRequestStart(sender, httpContext); } }