From bf89259d62f9408d3e7cdd297519034a09c5ae4f Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 8 Sep 2004 17:58:01 +0000 Subject: [PATCH] added method to enforce simple parsers for apps which require that git-svn-id: http://svn.opengroupware.org/SOPE/trunk@122 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 9 +++ sope-appserver/NGObjWeb/Version | 2 +- .../WOHttpAdaptor/WOHttpTransaction.m | 68 ++++++++++++------- 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 42bd24aa..b413b43a 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,12 @@ +2004-09-08 Helge Hess + + * 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 * Defaults.plist: disable WODebugging per default (v4.3.29) diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 08aa2af4..cbfe80e9 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -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 diff --git a/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m b/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m index fcacaa64..f63c39b2 100644 --- a/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m +++ b/sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m @@ -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) */ -- 2.39.5