/// <summary>
        /// Main method handling requests to the specified resource.
        /// </summary>
        /// <param name="o">Current HttpApplication</param>
        /// <param name="eventArgs">Current event arguments</param>
        public void DistributionModule_OnPreRequestHandlerExecute(object o, EventArgs eventArgs)
        {
            DateTime        start       = DateTime.Now;
            HttpApplication application = (HttpApplication)o;
            HttpContext     context     = application.Context;
            HttpRequest     request     = context.Request;
            HttpResponse    response    = context.Response;
            string          urlPath     = request.Url.AbsolutePath;

            Regex binaryRegex = new Regex(ConfigurationManager.AppSettings["BinaryUrlPattern"]);

            if (!binaryRegex.IsMatch(urlPath))
            {
                LoggerService.Debug("url {0} does not match binary url pattern, ignoring it", urlPath);
                return;
            }

            if (!BinaryFileManager.ProcessRequest(request))
            {
                LoggerService.Debug("Url {0} not found. Returning 404 Not Found.", urlPath);
                //the 404 should be handled by the default handler
                return;
            }
            // if we got here, the file was successfully created on file-system
            DateTime ifModifiedSince = Convert.ToDateTime(request.Headers["If-Modified-Since"]);

            LoggerService.Debug("If-Modified-Since: " + ifModifiedSince);

            DateTime fileLastModified = File.GetLastWriteTime(request.PhysicalPath);

            LoggerService.Debug("File last modified: " + fileLastModified);

            if (fileLastModified.Subtract(ifModifiedSince).TotalSeconds < 1)
            {
                LoggerService.Debug("Sending 304 Not Modified");
                response.StatusCode      = 304;
                response.SuppressContent = true;
                application.CompleteRequest();
            }

            // Note: if the file was just created, an empty dummy might still be served by IIS
            // To make sure the right file is sent, we will transmit the file directly within the first second of the creation
            if (fileLastModified.AddSeconds(1).CompareTo(DateTime.Now) > 0)
            {
                LoggerService.Debug("file was created less than 1 second ago, transmitting content directly");
                response.Clear();
                response.TransmitFile(request.PhysicalPath);
            }
        }