/// <summary> /// Returns the content to display if the URL is a directory /// </summary> /// <param name="contents">Array of directory contents</param> /// <param name="filePath">The file path of the directory</param> /// <returns></returns> public static HttpResponse ReturnDirectory(string[] contents, string filePath) { HttpResponse response = new HttpResponse(200, "OK"); response.AddProperty("Content-type", "text/html"); response.AddProperty("Server", "BestServer"); response.Content = MakeHtml(contents, filePath); return(response); }
/// <summary> /// Returns the files content if it's of valid content type /// </summary> /// <param name="fileStream">The file stream for writing and outputting the file</param> /// <param name="filePath">The path of the file</param> /// <param name="contentLength">The content legth of the file</param> /// <returns></returns> public static HttpResponse ReturnFile(FileStream fileStream, string filePath, long contentLength) { HttpResponse response = new HttpResponse(200, "OK"); response.AddProperty("Content-Type", GetContentType(filePath)); response.AddProperty("Content-Length", contentLength); response.AddProperty("Server", "BestServer."); response.ContentFile = fileStream; return(response); }