private void ProcessFromFile(HttpContext context, CompositeFileMap map, out string compositeFileName, out byte[] outputBytes)
        {
            //the saved file's bytes are already compressed.
            outputBytes       = map.GetCompositeFileBytes();
            compositeFileName = map.CompositeFileName;
            CompressionType cType = (CompressionType)Enum.Parse(typeof(CompressionType), map.CompressionType);

            SetContentEncodingHeaders(context, cType);
        }
		private void ProcessFromFile(HttpContext context, CompositeFileMap map, out string compositeFileName, out byte[] outputBytes)
		{
			//the saved file's bytes are already compressed.
			outputBytes = map.GetCompositeFileBytes();
			compositeFileName = map.CompositeFileName;
			CompressionType cType = (CompressionType)Enum.Parse(typeof(CompressionType), map.CompressionType);
			SetContentEncodingHeaders(context, cType);	
		}
        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            HttpResponse         response = context.Response;
            string               fileset  = context.Server.UrlDecode(context.Request["s"]);
            ClientDependencyType type;

            try
            {
                type = (ClientDependencyType)Enum.Parse(typeof(ClientDependencyType), context.Request["t"], true);
            }
            catch
            {
                throw new ArgumentException("Could not parse the type set in the request");
            }

            if (string.IsNullOrEmpty(fileset))
            {
                throw new ArgumentException("Must specify a fileset in the request");
            }

            string compositeFileName = "";

            byte[] outputBytes = null;

            //get the map to the composite file for this file set, if it exists.
            CompositeFileMap map = CompositeFileXmlMapper.Instance.GetCompositeFile(fileset);

            if (map != null && map.HasFileBytes)
            {
                ProcessFromFile(context, map, out compositeFileName, out outputBytes);
            }
            else
            {
                bool fromFile = false;

                lock (m_Lock)
                {
                    //check again...
                    if (map == null || !map.HasFileBytes)
                    {
                        //need to do the combining, etc... and save the file map

                        //get the file list
                        string[] strFiles = DecodeFrom64(fileset).Split(';');
                        //combine files and get the definition types of them (internal vs external resources)
                        List <CompositeFileDefinition> fDefs;
                        byte[] fileBytes = CompositeFileProcessor.CombineFiles(strFiles, context, type, out fDefs);
                        //compress data
                        CompressionType cType = GetCompression(context);
                        outputBytes = CompositeFileProcessor.CompressBytes(cType, fileBytes);
                        SetContentEncodingHeaders(context, cType);
                        //save combined file
                        compositeFileName = CompositeFileProcessor.SaveCompositeFile(outputBytes, type);
                        if (!string.IsNullOrEmpty(compositeFileName))
                        {
                            //Update the XML file map
                            CompositeFileXmlMapper.Instance.CreateMap(fileset, cType.ToString(),
                                                                      fDefs
                                                                      .Where(f => f.IsLocalFile)
                                                                      .Select(x => new FileInfo(context.Server.MapPath(x.Uri))).ToList(), compositeFileName);
                        }
                    }
                    else
                    {
                        //files are there now, process from file.
                        fromFile = true;
                    }
                }

                if (fromFile)
                {
                    ProcessFromFile(context, map, out compositeFileName, out outputBytes);
                }
            }

            SetCaching(context, compositeFileName);

            context.Response.ContentType = type == ClientDependencyType.Javascript ? "text/javascript" : "text/css";
            context.Response.OutputStream.Write(outputBytes, 0, outputBytes.Length);
        }