]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOSimpleHTTPParser.m
define some default defaults for the simple http parser (when the Defaults.plist...
[sope] / sope-appserver / NGObjWeb / WOSimpleHTTPParser.m
index 1336f2d963237d082851059d491953d2fd5ad681..595a8ecdf47ae813e5d0043e76892dc1ccb1cff3 100644 (file)
@@ -29,8 +29,8 @@
 static Class NSStringClass  = Nil;
 static BOOL  debugOn        = NO;
 static BOOL  heavyDebugOn   = NO;
-static int   fileIOBoundary = 16384;
-static int   maxUploadSize  = 256 * 1024; /* 256MB */
+static int   fileIOBoundary = 0;
+static int   maxUploadSize  = 0;
 
 + (int)version {
   return 1;
@@ -42,7 +42,12 @@ static int   maxUploadSize  = 256 * 1024; /* 256MB */
   heavyDebugOn   = [ud boolForKey:@"WOSimpleHTTPParserHeavyDebugEnabled"];
   fileIOBoundary = [ud integerForKey:@"WOSimpleHTTPParserFileIOBoundary"];
   maxUploadSize  = [ud integerForKey:@"WOSimpleHTTPParserMaxUploadSizeInKB"];
-
+  
+  if (maxUploadSize == 0)
+    maxUploadSize = 256 * 1024; /* 256MB */
+  if (fileIOBoundary == 0)
+    fileIOBoundary = 16384;
+  
   if (debugOn) {
     NSLog(@"WOSimpleHTTPParser: max-upload-size:  %dKB", maxUploadSize);
     NSLog(@"WOSimpleHTTPParser: file-IO boundary: %d",   fileIOBoundary);
@@ -544,10 +549,12 @@ static NSString *stringForHeaderName(unsigned char *p) {
   }
   else if (self->clen > maxUploadSize*1024) {
     /* entity is too large */
+    NSString *s;
+
+    s = [NSString stringWithFormat:@"The maximum HTTP transaction size was "
+                  @"exceeded (%d vs %d)", self->clen, maxUploadSize * 1024];
     return [NSException exceptionWithName:@"LimitException"
-                       reason:
-                         @"the maximum HTTP transaction size was exceeded"
-                       userInfo:nil];
+                       reason:s userInfo:nil];
   }
   else if (self->clen > fileIOBoundary) {
     /* we are streaming the content to a file and use a memory mapped data */