public virtual IHttpHandler GetHandler(HttpContext context, string verb, string url, string path) { if ("GET".Equals(verb, StringComparison.OrdinalIgnoreCase) && String.IsNullOrEmpty(context.Request.PathInfo)) { // output service javascript proxy return(new ResourceHandler(context)); } // handle service requests string appUrl = context.Request.AppRelativeCurrentExecutionFilePath; IJsonServiceInfo serviceInfo = ResourceHandler.Create <IJsonServiceInfo>(appUrl); if (!context.IsDebuggingEnabled && !Settings.DisableStreamCompression) { ResourceHandler.EnableStreamCompression(context); } return(new JsonServiceHandler(serviceInfo, url)); }
void IHttpHandler.ProcessRequest(HttpContext context) { if (this.IsDebug) { context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); } else { // TODO: make this configurable (default to min-value YSlow! considers useful) // Note: Google Page Speed wants 1 month context.Response.ExpiresAbsolute = DateTime.UtcNow.AddDays(3); } string userCulture = context.Request.QueryString[ResourceHandler.GlobalizationQuery]; if (userCulture != null && userCulture.Length > 1) { try { Thread.CurrentThread.CurrentUICulture = new CultureInfo(userCulture); } catch { } try { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(userCulture); } catch { } } // get the target string targetPath = context.Request.AppRelativeCurrentExecutionFilePath; IGlobalizedBuildResult target = BuildManager.CreateInstanceFromVirtualPath(targetPath, typeof(IGlobalizedBuildResult)) as IGlobalizedBuildResult; if (target == null) { return; } IDictionary <string, object> res = this.GetResourceStrings(target.GlobalizationKeys, targetPath); if (!this.IsDebug) { // TODO: provide a mechanism for disabling compression? ResourceHandler.EnableStreamCompression(context); } HttpResponse response = context.Response; response.ContentType = ScriptResourceCodeProvider.MimeType; response.AppendHeader( "Content-Disposition", "inline;filename=" + Path.GetFileNameWithoutExtension(targetPath) + ".js"); if (this.IsDebug) { response.Write(JslintDirective); } if (res.Count < 1) { // don't output call return; } response.Write(ResStart); EcmaScriptWriter writer = new EcmaScriptWriter(response.Output); writer.Settings.PrettyPrint = this.IsDebug; writer.Write(res); response.Write(","); writer = new EcmaScriptWriter(response.Output); writer.Settings.PrettyPrint = this.IsDebug; writer.Write(Thread.CurrentThread.CurrentCulture.Name); response.Write(ResEnd); }
public static void EnableStreamCompression(HttpContext context) { ResourceHandler.EnableStreamCompression(context); }
public override IAsyncResult BeginProcessRequest(System.Web.HttpContext context, AsyncCallback callback, object state) { ResourceHandler.EnableStreamCompression(context); return(base.BeginProcessRequest(context, callback, state)); }