public override void OnOperation(HttpListenerContext context, Authentication authentication) { string id = context.Request.QueryString["id"]; if (!UploadedModsManager.Instance.HasModWithIdBeenUploaded(id)) { Utils.SendErrorPage(context.Response, "No mod with the id \"" + id + "\" has been uploaded", true, HttpStatusCode.NotFound); return; } string path = UploadedModsManager.Instance.GetZippedFileForMod(id); byte[] data = File.ReadAllBytes(path); string displayName = UploadedModsManager.Instance.GetModInfoFromId(id).DisplayName + ".zip"; displayName = displayName.Replace(' ', '_'); foreach (char c in Path.GetInvalidFileNameChars()) { displayName = displayName.Replace(c, '_'); } SpecialModData specialModData = UploadedModsManager.Instance.GetSpecialModInfoFromId(id); specialModData.Downloads++; specialModData.Save(); HttpStream httpStream = new HttpStream(context.Response); httpStream.SendFile(data, displayName); httpStream.Close(); }