public void ProcessRequest(HttpContext context) { context.User = UserService.CreateAnonymousUser(context); string[] parsed = context.Request.Path.Split(new char[] { '/' }, 3, StringSplitOptions.RemoveEmptyEntries); if (3 != parsed.Length) { Go(context, "/releases", false); return; } VersionString version; string file; try { version = new VersionString(parsed[1]); file = parsed[2].Replace("..", String.Empty); } catch { Go(context, "/releases", false); return; } // See if there is a version redirect file for the requested release. string redirect = null; try { string jsonPath = String.Format(Configuration.ReleasesDataFileFormat, version.PrefixedDashed); jsonPath = context.Server.MapPath(jsonPath); if (File.Exists(jsonPath)) { Release release = Release.Load(jsonPath); ReleaseFile releaseFile = release.Files.Where(f => f.Name.Equals(file, StringComparison.OrdinalIgnoreCase)).Single(); redirect = releaseFile.Redirect; } } catch { context.Response.StatusCode = (int)System.Net.HttpStatusCode.NotFound; return; } // If redirect was not found, assume we're looking for a file on the download server. if (String.IsNullOrEmpty(redirect)) { Visit.CreateFromHttpContext(context).Log(logger); redirect = String.Format(Configuration.DownloadServerFormat, version.Prefixed, file); } Go(context, redirect, false); }
private Status RedirectToDownload() { UserService.CreateAnonymousUser(); string[] parsed = this.DownloadPath.Split(new char[] { '/' }, 2, StringSplitOptions.RemoveEmptyEntries); if (2 != parsed.Length) { return Status.FoundAt("~/releases/"); } VersionString version; string file; try { version = new VersionString(parsed[0]); file = parsed[1].Replace("..", String.Empty); } catch { return Status.FoundAt("~/releases/"); } // See if there is a version redirect file for the requested release. string redirect = null; try { string jsonPath = String.Format(Configuration.ReleasesDataFileFormat, version.PrefixedDashed); jsonPath = this.ServerUtility.MapPath(jsonPath); if (File.Exists(jsonPath)) { Release release = Release.Load(jsonPath); ReleaseFile releaseFile = release.Files.Where(f => f.Name.Equals(file, StringComparison.OrdinalIgnoreCase)).Single(); redirect = releaseFile.Redirect; } } catch { return Status.NotFound; } // If redirect was not found, assume we're looking for a file on the download server. if (String.IsNullOrEmpty(redirect)) { Visit.CreateFromHttpContext().Log(logger); // New static.wixtoolset.org is case sensitive and all files there are lower case. redirect = String.Format(Configuration.DownloadServerFormat, version.Prefixed, file).ToLowerInvariant(); } return Status.FoundAt(redirect); }
private Status RedirectToDownload() { UserService.CreateAnonymousUser(); string[] parsed = this.DownloadPath.Split(new char[] { '/' }, 2, StringSplitOptions.RemoveEmptyEntries); if (2 != parsed.Length) { return Status.FoundAt("~/releases/"); } VersionString version; string file; try { version = new VersionString(parsed[0]); file = parsed[1].Replace("..", String.Empty); } catch { return Status.FoundAt("~/releases/"); } // See if there is a version redirect file for the requested release. string redirect = null; try { redirect = this.RedirectedRelease(version.Prefixed, file); } catch { return Status.NotFound; } // If redirect was not found, assume we're looking for a file on the download server. if (String.IsNullOrEmpty(redirect)) { Visit.CreateFromHttpContext().Log(logger); // New static.wixtoolset.org is case sensitive and all files there are lower case. redirect = String.Format(Configuration.DownloadServerFormat, version.Prefixed, file).ToLowerInvariant(); } return Status.FoundAt(redirect); }