protected override bool Process(IInteraction parameters) { IHttpInteraction httpInteraction = Closest <IHttpInteraction> .From(parameters); string contentType; if (this.ContentType.Length > 0) { contentType = this.ContentType; } else { contentType = Fallback <string> .From(parameters, "contenttype"); }; httpInteraction.SetContentType(contentType); if (this.SendLength) { long length = Fallback <long> .From(parameters, "contentlength"); httpInteraction.SetContentLength(length); } httpInteraction.PurgeBuffer(); return(WithBranch.TryProcess(parameters)); }
protected FileInfo GetFileInfo(IInteraction parameters) { string fileName; if (this.UseVariable) { string providedFilename = Fallback <string> .From(parameters, this.PathVariable); string uncorrectedFilename = providedFilename; foreach (var invalidChar in Path.GetInvalidFileNameChars()) { providedFilename = providedFilename.Replace(invalidChar, '_'); } if (providedFilename != uncorrectedFilename) { Secretary.Report(5, "Changed invalid provided filename", uncorrectedFilename, "into", providedFilename); } if (IsRelative) { fileName = string.Format( "{0}{1}{2}", this.ValidRootPath.TrimEnd('\\', '/'), Path.DirectorySeparatorChar, providedFilename ); } else { fileName = providedFilename; } } else { fileName = this.ValidRootPath; } return(new FileInfo(fileName)); }