Skip to content

Commit

Permalink
additional common mime-type mappings added.
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkcod committed Apr 14, 2011
1 parent ad42d1f commit 6bec0dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Source/Web/FileHttpHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using System.Web;
using System.Web;
using Concoct.IO;

namespace Concoct.Web
Expand All @@ -25,6 +24,11 @@ public void ProcessRequest(HttpContext context) {
string MimeTypeFromExtension(string extension) {
switch(extension) {
case ".css": return "text/css";
case ".gif": return "image/gif";
case ".jpg": return "image/jpeg";
case ".png": return "image/png";
case ".txt": return "text/plain";
case ".xml": return "text/xml";
default: return "application/octet-stream";
}
}
Expand Down
8 changes: 6 additions & 2 deletions Tests/Web/FileHttpHandlerSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ public class FileHttpHandlerSpec
{
[Row(".???", "application/octet-stream")
,Row(".css", "text/css")
,Row(".xml", "text/xml")
,Row(".txt", "text/plain")
,Row(".gif", "image/gif")
,Row(".png", "image/png")
,Row(".jpg", "image/jpeg")
,DisplayAs("{0} => {1}")]
public void content_type(string extension, string mimeType) {
var message = "Hello World!";
var fileInfo = new Moq.Mock<IFileInfo>();
fileInfo.Setup(x => x.Extension).Returns(extension);
fileInfo.Setup(x => x.OpenRead()).Returns(StreamWith(message));
fileInfo.Setup(x => x.OpenRead()).Returns(StreamWith("<this doesn't matter>"));

WithResponseFrom(fileInfo.Object, response => {
Verify.That(() => response.ContentType == mimeType);
Expand Down

0 comments on commit 6bec0dc

Please sign in to comment.