GCDWebServerGetMimeTypeForExtension() always returns a MIME type

This commit is contained in:
Pierre-Olivier Latour 2014-03-29 11:45:51 -07:00
parent eac83a4d0d
commit aa5dd8fca0
2 changed files with 2 additions and 6 deletions

View File

@ -102,7 +102,7 @@ NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension) {
}
}
}
return mimeType;
return mimeType ? mimeType : kGCDWebServerDefaultMimeType;
}
NSString* GCDWebServerUnescapeURLString(NSString* string) {

View File

@ -306,12 +306,8 @@
return nil; // TODO: Return 416 status code and "Content-Range: bytes */{file length}" header
}
}
NSString* type = GCDWebServerGetMimeTypeForExtension([path pathExtension]);
if (type == nil) {
type = kGCDWebServerDefaultMimeType;
}
if ((self = [super initWithContentType:type contentLength:(range.location != NSNotFound ? range.length : (NSUInteger)info.st_size)])) {
if ((self = [super initWithContentType:GCDWebServerGetMimeTypeForExtension([path pathExtension]) contentLength:(range.location != NSNotFound ? range.length : (NSUInteger)info.st_size)])) {
_path = [path copy];
if (range.location != NSNotFound) {
_offset = range.location;