oops
authorClaus Gittinger <cg@exept.de>
Sat, 13 Dec 2008 11:39:21 +0100
changeset 2583 c33208757c6f
parent 2582 298203fdb64d
child 2584 5b5c3dda9a4b
oops
MIMETypes.st
--- a/MIMETypes.st	Fri Dec 12 13:51:03 2008 +0100
+++ b/MIMETypes.st	Sat Dec 13 11:39:21 2008 +0100
@@ -829,10 +829,12 @@
 
     |buffer lcBuffer size idx idx2|
 
-    someData size == 0 ifTrue:[^ nil].
+    someData isEmptyOrNil ifTrue:[^ nil].
+
+    size := 2048 min:someData size.
 
     "/ read some data from the file ...
-    buffer := (someData copyTo:(2048 min:someData size)) asString.
+    buffer := (someData copyTo:size) asString.
     lcBuffer := buffer asLowercase.
 
     (idx := lcBuffer findString:'mimetype:') ~~ 0 ifTrue:[
@@ -840,7 +842,7 @@
         idx := lcBuffer indexOfNonSeparatorStartingAt:idx.
         idx2 := lcBuffer indexOfSeparatorStartingAt:idx.
         idx2 > idx ifTrue:[
-            ^ self fromString:(lcBuffer copyFrom:idx to:idx2-1)
+            ^ MIMEType fromString:(lcBuffer copyFrom:idx to:idx2-1)
         ].
     ].
 
@@ -854,7 +856,7 @@
 
         patternString := pattern asString.
         (buffer startsWith:patternString) ifTrue:[
-            ^ self fromString:what
+            ^ MIMEType fromString:what
         ]
     ].
 
@@ -880,7 +882,7 @@
 
     ) pairsDo:[:pattern :what | 
         (lcBuffer findString:pattern) ~~ 0 ifTrue:[
-            ^ self fromString:what
+            ^ MIMEType fromString:what
         ]
     ].
 
@@ -894,14 +896,14 @@
         or:[(lcBuffer continuesWith:'<h5' startingAt:idx)
         or:[(lcBuffer continuesWith:'<h6' startingAt:idx)]]]]]]])
         ifTrue:[
-            ^ self fromString:'text/html'
+            ^ MIMEType fromString:'text/html'
         ]
     ].
 
     [size ~~ 0 and:[(buffer at:size) isPrintable]] whileTrue:[size := size - 1].
 
     size == 0 ifTrue:[
-        ^ self fromString:'text/plain'
+        ^ MIMEType fromString:'text/plain'
     ].
     ^ nil
 !
@@ -1322,7 +1324,7 @@
 !MIMETypes class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.100 2008-12-12 12:51:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.101 2008-12-13 10:39:21 cg Exp $'
 ! !
 
 MIMETypes initialize!