]> err.no Git - sope/commitdiff
added method to enforce simple parsers for apps which require that
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 8 Sep 2004 17:58:01 +0000 (17:58 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 8 Sep 2004 17:58:01 +0000 (17:58 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@122 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-appserver/NGObjWeb/ChangeLog
sope-appserver/NGObjWeb/Version
sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m

index 42bd24aa49388548bdc28a8aecf29fdd7035ace5..b413b43a55581aae0e18f0de4e631aa4a9aedf6a 100644 (file)
@@ -1,3 +1,12 @@
+2004-09-08  Helge Hess  <helge.hess@opengroupware.org>
+
+       * WOHttpAdaptor/WOHttpTransaction.m: check whether the simple HTTP
+         parser is to be used using the
+         -shouldUseSimpleHTTPParserForTransaction: method on
+         WOCoreApplication. That way applications which require the parser
+         (like xmlrpcd/ZideStore) can override the default
+         WOHttpTransactionUseSimpleParser default (v4.3.30)
+
 2004-09-07  Helge Hess  <helge.hess@skyrix.com>
 
        * Defaults.plist: disable WODebugging per default (v4.3.29)
index 08aa2af45d0f3830b9f687b36f155a036549b6f8..cbfe80e99897d994600aefb1bd6cf67db6ab4aab 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=29
+SUBMINOR_VERSION:=30
 
 # v4.2.413 requires libSaxObjC      v4.2.33
 # v4.2.341 requires libNGExtensions v4.2.77
index fcacaa64b33e57d1cce7874ee89e3e2fcdb85c63..f63c39b29aaff35f08243273f6a52b9bc9aaf703 100644 (file)
@@ -48,6 +48,12 @@ NSString *WOAsyncResponse = @"WOAsyncResponse";
 
 static int HTTP_PERFLOG = -1;
 
+@interface WOCoreApplication(SimpleParserSelection)
+
+- (BOOL)shouldUseSimpleHTTPParserForTransaction:(id)_tx;
+
+@end
+
 @implementation WOHttpTransaction
 
 static NSMutableDictionary *pendingTransactions = nil; // THREAD
@@ -61,18 +67,16 @@ static NSString *adLogPath = nil;
 }
 + (void)initialize {
   static BOOL didInit = NO;
-  if (!didInit) {
-    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
-    didInit = YES;
-    
-    useSimpleParser = [ud boolForKey:@"WOHttpTransactionUseSimpleParser"];
-    debugOn = [[ud objectForKey:@"WODebugHttpTransaction"] boolValue] ? 1 : 0;
-    doCore = [[ud objectForKey:@"WOCoreOnHTTPAdaptorException"] boolValue]?1:0;
-    
-    adLogPath = [[ud stringForKey:@"WOAdaptorLogPath"] copy];
-    if (adLogPath == nil)
-      adLogPath = @"";
-  }
+  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+  if (didInit) return;
+  didInit = YES;
+  
+  useSimpleParser = [ud boolForKey:@"WOHttpTransactionUseSimpleParser"];
+  debugOn = [[ud objectForKey:@"WODebugHttpTransaction"] boolValue] ? 1 : 0;
+  doCore = [[ud objectForKey:@"WOCoreOnHTTPAdaptorException"] boolValue]?1:0;
+  
+  adLogPath = [[ud stringForKey:@"WOAdaptorLogPath"] copy];
+  if (adLogPath == nil) adLogPath = @"";
 }
 
 - (BOOL)optionLogStream {
@@ -100,7 +104,9 @@ static NSString *adLogPath = nil;
 }
 
 - (void)dealloc {
-  //[self debugWithFormat:@"dealloc ..."];
+#if 0
+  [self debugWithFormat:@"dealloc ..."];
+#endif
   [self reset];
   [self->socket        release];
   [self->lastException release];
@@ -108,6 +114,8 @@ static NSString *adLogPath = nil;
   [super dealloc];
 }
 
+/* state management */
+
 - (void)reset {
   if (self->asyncResponseToken) {
     [self logWithFormat:
@@ -134,18 +142,20 @@ static NSString *adLogPath = nil;
   self->t = [self->startDate timeIntervalSince1970];
 }
 - (void)finish {
-  if (self->woResponse) {
-    [self logResponse:self->woResponse
-          toRequest:self->woRequest
-          connection:self->socket];
+  if (self->woResponse == nil)
+    return;
+
+  [self logResponse:self->woResponse
+       toRequest:self->woRequest
+       connection:self->socket];
     
-    if (HTTP_PERFLOG) {
+  if (HTTP_PERFLOG) {
       struct timeval tv;
       gettimeofday(&tv, NULL);
       self->t = (((double)tv.tv_sec) * ((double)tv.tv_usec) / 1000.0)  - 
        self->t;
-      NSLog(@"processing of request took %4.3fs.", self->t < 0.0 ? -1.0 : t);
-    }
+      NSLog(@"processing of request took %4.3fs.", 
+           self->t < 0.0 ? -self->t : self->t);
   }
 }
 
@@ -163,11 +173,13 @@ static NSString *adLogPath = nil;
   }
   return self->io != nil ? YES : NO;
 }
+
 static int logCounter = 0;
 
 - (NSString *)currentRecordingPath:(NSString *)_suffix {
   static NSString *s = nil;
   NSString *p;
+  
   if (s == nil) {
     s = [[self->application recordingPath] copy];
     if (s == nil) s = @"";
@@ -326,7 +338,7 @@ static int logCounter = 0;
   if (self->woRequest)
     [self logWithFormat:@"WARNING: woRequest already set ???"];
   
-  if (useSimpleParser) {
+  if ([self->application shouldUseSimpleHTTPParserForTransaction:self]) {
     WOSimpleHTTPParser *parser;
     
     parser = [[WOSimpleHTTPParser alloc] initWithStream:self->io];
@@ -968,9 +980,7 @@ static __inline__ const unsigned char *monthAbbr(int m) {
   fflush(stdout);
 }
 
-@end /* WOHttpTransaction */
-
-@implementation WOHttpTransaction(NGHttpMessageParserDelegate)
+/* NGHttpMessageParserDelegate */
 
 - (BOOL)httpParserWillParseRequest:(NGHttpMessageParser *)_parser {
   return YES;
@@ -988,4 +998,12 @@ static __inline__ const unsigned char *monthAbbr(int m) {
 - (void)parser:(NGMimePartParser *)_parser didParseHeader:(NGHashMap *)_header {
 }
 
-@end /* WOHttpAdaptor(NGHttpMessageParserDelegate) */
+@end /* WOHttpAdaptor */
+
+@implementation WOCoreApplication(SimpleParserSelection)
+
+- (BOOL)shouldUseSimpleHTTPParserForTransaction:(id)_tx {
+  return useSimpleParser;
+}
+
+@end /* WOCoreApplication(SimpleParserSelection) */