* Examples/hello/Main.m

add DirectAction to avoid error messages
* GSWeb.framework/GSWEmbeddedObject.m
include NSObject+GNUstepBase.h
* GSWeb.framework/GSWConfig.h
remove GSWOPTVALUE_AcceptedContentEncoding
* GSWeb.framework/GSWResponse.h
remove acceptedEncodings
add + compressableContentTypes
add + setCompressableContentTypes:
remove usesless @interface/@end 
* GSWeb.framework/GSWResponse.m
add compressableContentTypesCache
add + compressableContentTypes
add + setCompressableContentTypes:
remove acceptedEncodings
remove usesless @implementation/@end 
add _browserSupportsCompression:
refactor _finalizeContentEncodingInContext:
* GSWeb.framework/GSWConstants.h
* GSWeb.framework/GSWConstants.m
remove GSWOPT_AcceptedContentEncoding
* GSWeb.framework/GSWComponent.m
do not call setAcceptedEncodings on response.
* GSWeb.framework/GSWApplication.h
* GSWeb.framework/GSWApplication+Defaults.m
remove + acceptedContentEncoding
remove + acceptedContentEncodingArray
remove + setAcceptedContentEncoding:



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@30697 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
dwetzel 2010-06-13 21:51:06 +00:00
parent 31cbfaf084
commit 42b40df773
11 changed files with 134 additions and 177 deletions

View file

@ -1,3 +1,34 @@
2010-06-13 David Wetzel <dave@turbocat.de>
* Examples/hello/Main.m
add DirectAction to avoid error messages
* GSWeb.framework/GSWEmbeddedObject.m
include NSObject+GNUstepBase.h
* GSWeb.framework/GSWConfig.h
remove GSWOPTVALUE_AcceptedContentEncoding
* GSWeb.framework/GSWResponse.h
remove acceptedEncodings
add + compressableContentTypes
add + setCompressableContentTypes:
remove usesless @interface/@end
* GSWeb.framework/GSWResponse.m
add compressableContentTypesCache
add + compressableContentTypes
add + setCompressableContentTypes:
remove acceptedEncodings
remove usesless @implementation/@end
add _browserSupportsCompression:
refactor _finalizeContentEncodingInContext:
* GSWeb.framework/GSWConstants.h
* GSWeb.framework/GSWConstants.m
remove GSWOPT_AcceptedContentEncoding
* GSWeb.framework/GSWComponent.m
do not call setAcceptedEncodings on response.
* GSWeb.framework/GSWApplication.h
* GSWeb.framework/GSWApplication+Defaults.m
remove + acceptedContentEncoding
remove + acceptedContentEncodingArray
remove + setAcceptedContentEncoding:
2010-06-11 David Wetzel <dave@turbocat.de>
* Testing/DynamicElements
Ported to WO names.

View file

@ -35,6 +35,10 @@
@end
/*
* in an real world application you should move these to separate files.
*/
@interface Session:WOSession
{
}
@ -47,8 +51,16 @@
@end
@interface DirectAction:WODirectAction
{
}
@end
@implementation Session
@end
@implementation Application
@end
@implementation DirectAction
@end

View file

@ -330,7 +330,6 @@ GSWeb_InitializeGlobalAppDefaultOptions(void)
LOGOPT_NC(GSWOPT_AdaptorHost);
LOGOPT (GSWOPTVALUE_DefaultTemplateParser);
LOGOPT (GSWOPTVALUE_AcceptedContentEncoding);
LOGOPT (GSWOPTVALUE_DisplayExceptionPages);
LOGOPT (GSWOPTVALUE_AllowsCacheControlHeader);
@ -465,9 +464,6 @@ GSWeb_InitializeGlobalAppDefaultOptions(void)
GSWOPTVALUE_DefaultTemplateParser,
GSWOPT_DefaultTemplateParser[GSWebNamingConv],
GSWOPTVALUE_AcceptedContentEncoding,
GSWOPT_AcceptedContentEncoding[GSWebNamingConv],
GSWOPTVALUE_DisplayExceptionPages,
GSWOPT_DisplayExceptionPages[GSWebNamingConv],
@ -1564,33 +1560,6 @@ static NSString *_dflt_debugSetConfigFilePath = nil;
@"+setSaveResponsesPath: is now obsolete. Use +setRecordingPath:");
};
//--------------------------------------------------------------------
static BOOL _dflt_init_acceptedContentEncoding = NO;
static NSString *_dflt_acceptedContentEncoding = nil;
+(NSString*)acceptedContentEncoding
{
INIT_DFLT_OBJ(acceptedContentEncoding,
GSWOPT_AcceptedContentEncoding[GSWebNamingConv]);
return _dflt_acceptedContentEncoding;
};
//--------------------------------------------------------------------
+(NSArray*)acceptedContentEncodingArray
{
NSArray* acceptedContentEncodingArray=nil;
NSString* acceptedContentEncoding=[self acceptedContentEncoding];
acceptedContentEncodingArray=[acceptedContentEncoding componentsSeparatedByString:@";"];
return acceptedContentEncodingArray;
};
//--------------------------------------------------------------------
+(void)setAcceptedContentEncoding:(NSString*)acceptedContentEncoding
{
ASSIGNCOPY(_dflt_acceptedContentEncoding, acceptedContentEncoding);
_dflt_init_acceptedContentEncoding = YES;
};
//--------------------------------------------------------------------
static BOOL _dflt_init_defaultTemplateParser = NO;
static NSString *_dflt_defaultTemplateParser = nil;

View file

@ -695,9 +695,6 @@ GSWEB_EXPORT GSWApplication* GSWApp;
+(int)defaultUndoStackLimit;
+(BOOL)_lockDefaultEditingContext;
+(void)_setLockDefaultEditingContext:(BOOL)flag;
+(NSString*)acceptedContentEncoding;
+(NSArray*)acceptedContentEncodingArray;
+(void)setAcceptedContentEncoding:(NSString*)acceptedContentEncoding;
+(NSString*)defaultTemplateParser;//NDFN
+(void)setDefaultTemplateParser:(NSString*)defaultTemplateParser;//NDFN
+(BOOL)defaultDisplayExceptionPages;//NDFN

View file

@ -1302,7 +1302,6 @@ Call this method before using a component which was cached in a variable.
if (request != nil) {
httpVersion = [request httpVersion];
[response setAcceptedEncodings:[request browserAcceptedEncodings]];
}
[response setHTTPVersion:httpVersion];

View file

@ -65,7 +65,6 @@
#define GSWOPTVALUE_LockDefaultEditingContext @"NO"
#define GSWOPTVALUE_WorkerThreadCountMin @"16"
#define GSWOPTVALUE_WorkerThreadCountMax @"256"
#define GSWOPTVALUE_AcceptedContentEncoding @"gzip"
#define GSWOPTVALUE_DisplayExceptionPages @"YES"
#define GSWOPTVALUE_AllowsCacheControlHeader @"NO"
#endif // _GSWebConfig_h__

View file

@ -232,7 +232,6 @@ GSWEB_EXPORT NSString* GSWOPT_DebugSetConfigFilePath;
GSWEB_EXPORT NSString* GSWOPT_AdaptorHost[2];
GSWEB_EXPORT NSString* GSWOPT_RecordingPath[2];
GSWEB_EXPORT NSString* GSWOPT_DefaultTemplateParser[2];
GSWEB_EXPORT NSString* GSWOPT_AcceptedContentEncoding[2];
GSWEB_EXPORT NSString* GSWOPT_SessionStoreClassName[2];
GSWEB_EXPORT NSString* GSWOPT_ResourceManagerClassName[2];
GSWEB_EXPORT NSString* GSWOPT_StatisticsStoreClassName[2];

View file

@ -229,7 +229,6 @@ NSString* GSWOPT_DebugSetConfigFilePath=@"GSWDebugSetConfigFilePath";
NSString* GSWOPT_AdaptorHost[2]={ @"GSWAdaptorHost", @"WOAdaptorHost" };
NSString* GSWOPT_RecordingPath[2]={ @"GSWRecordingPath", @"WORecordingPath" };
NSString* GSWOPT_DefaultTemplateParser[2]= { @"GSWDefaultTemplateParser", @"WODefaultTemplateParser" };
NSString* GSWOPT_AcceptedContentEncoding[2]= { @"GSWAcceptedContentEncoding", @"WOAcceptedContentEncoding" };
NSString* GSWOPT_SessionStoreClassName[2]= { @"GSWSessionStoreClassName", @"WOSessionStoreClassName" };
NSString* GSWOPT_ResourceManagerClassName[2]= { @"GSWResourceManagerClassName", @"WOResourceManagerClassName" };
NSString* GSWOPT_StatisticsStoreClassName[2]= { @"GSWStatisticsStoreClassName", @"WOStatisticsStoreClassName" };

View file

@ -32,6 +32,9 @@
RCS_ID("$Id$")
#include "GSWeb.h"
#ifndef GNUSTEP
#include <GNUstepBase/NSObject+GNUstepBase.h>
#endif
//====================================================================
@implementation GSWEmbeddedObject

View file

@ -102,7 +102,6 @@ GSWEB_EXPORT void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(
NSFileHandle* _contentStreamFileHandle;
unsigned int _contentStreamBufferSize;
unsigned long _contentStreamBufferLength;
NSArray* _acceptedEncodings;
BOOL _canDisableClientCaching;
BOOL _isClientCachingDisabled;
BOOL _contentFaultsHaveBeenResolved;
@ -111,11 +110,21 @@ GSWEB_EXPORT void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(
GSWResponseIMPs _selfIMPs;
};
/* Used to determine if the content might be gzip compressed or not before sending to the client.
* This is an extension in GSWeb
*/
+ (NSArray*) compressableContentTypes;
/* You can change the compressable types here. Use an empty array or nil to
* turn the compression functionality off.
* This is an extension in GSWeb
*/
+ (void) setCompressableContentTypes:(NSArray*) cTypes;
-(void)willSend;//NDFN
-(void)forceFinalizeInContext;
-(void)setStatus:(unsigned int)status;
-(void)setAcceptedEncodings:(NSArray*)acceptedEncodings;
-(NSArray*)acceptedEncodings;
-(unsigned int)status;
-(NSString*)description;
@ -124,52 +133,25 @@ GSWEB_EXPORT void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(
// should be called before finalizeInContext
-(void)setCanDisableClientCaching:(BOOL)yn;
@end
//====================================================================
@interface GSWResponse (GSWResponseA)
-(BOOL)isFinalizeInContextHasBeenCalled;//NDFN
-(void)_finalizeInContext:(GSWContext*)context;
-(void)_appendTagAttribute:(NSString*)attributeName
value:(id)value
escapingHTMLAttributeValue:(BOOL)escape;
@end
//====================================================================
@interface GSWResponse (GSWResponseB)
-(void)_resolveContentFaultsInContext:(GSWContext*)context;
-(void)_appendContentFault:(id)unknown;
@end
//====================================================================
@interface GSWResponse (GSWResponseC)
-(BOOL)_isClientCachingDisabled;
-(unsigned int)_contentDataLength;
@end
//====================================================================
@interface GSWResponse (GSWResponseD)
-(BOOL)_responseIsEqual:(GSWResponse*)response;
@end
//====================================================================
@interface GSWResponse (GSWActionResults) <GSWActionResults>
-(GSWResponse*)generateResponse;
@end
//====================================================================
@interface GSWResponse (Stream)
-(void)setContentStreamFileHandle:(NSFileHandle*)fileHandle
bufferSize:(unsigned int)bufferSize
length:(unsigned long)length;
@end
//====================================================================
@interface GSWResponse (GSWResponseError)
//NDFN
//Last cHance Response
@ -181,20 +163,12 @@ escapingHTMLAttributeValue:(BOOL)escape;
inContext:(GSWContext*)context
forRequest:(GSWRequest*)request
forceFinalize:(BOOL)forceFinalize;
@end
//====================================================================
@interface GSWResponse (GSWResponseRefused)
//--------------------------------------------------------------------
//
//Refuse Response
+(GSWResponse*)generateRefusingResponseInContext:(GSWContext*)context
forRequest:(GSWRequest*)request;
@end
//====================================================================
@interface GSWResponse (GSWResponseRedirected)
-(void)_generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location

View file

@ -42,6 +42,7 @@ RCS_ID("$Id$")
static NSString* disabledCacheDateString=nil;
static NSArray* cacheControlHeaderValues=nil;
static NSArray* compressableContentTypesCache=nil;
static SEL appendTagAttributeValueEscapingHTMLAttributeValueSEL = NULL;
@ -90,9 +91,31 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
nil]));
appendTagAttributeValueEscapingHTMLAttributeValueSEL = @selector(_appendTagAttribute:value:escapingHTMLAttributeValue:);
ASSIGN(compressableContentTypesCache, ([NSArray arrayWithObjects:@"text/html",
@"text/plain",
@"text/css",
@"text/csv",
@"text/xml",
@"text/rtf",
@"text/calendar",
@"text/x-vcalendar",
@"text/enriched",
@"text/directory",nil]));
};
};
+ (NSArray*) compressableContentTypes
{
return compressableContentTypesCache;
}
+ (void) setCompressableContentTypes:(NSArray*) cTypes
{
ASSIGN(compressableContentTypesCache,cTypes);
}
//--------------------------------------------------------------------
// init
-(id)init
@ -116,7 +139,6 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
DESTROY(_contentFaults);
// NSDebugFLog0(@"Release Response contentData");
DESTROY(_contentStreamFileHandle);
DESTROY(_acceptedEncodings);
// NSDebugFLog0(@"Release Response");
[super dealloc];
};
@ -129,7 +151,6 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
{
clone->_status=_status;
ASSIGNCOPY(clone->_contentFaults,_contentFaults);
ASSIGNCOPY(clone->_acceptedEncodings,_acceptedEncodings);
clone->_isClientCachingDisabled=_isClientCachingDisabled;
clone->_canDisableClientCaching=_canDisableClientCaching;
clone->_contentFaultsHaveBeenResolved=_contentFaultsHaveBeenResolved;
@ -151,18 +172,6 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
_isFinalizeInContextHasBeenCalled=YES;
};
//--------------------------------------------------------------------
-(NSArray*)acceptedEncodings
{
return _acceptedEncodings;
};
//--------------------------------------------------------------------
-(void)setAcceptedEncodings:(NSArray*)acceptedEncodings
{
ASSIGN(_acceptedEncodings,acceptedEncodings);
};
//--------------------------------------------------------------------
// setStatus:
@ -238,11 +247,6 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
}
@end
//====================================================================
@implementation GSWResponse (GSWResponseA)
//--------------------------------------------------------------------
//NDFN
-(BOOL)isFinalizeInContextHasBeenCalled
@ -250,62 +254,69 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
return _isFinalizeInContextHasBeenCalled;
};
//--------------------------------------------------------------------
- (BOOL)_browserSupportsCompression:(GSWRequest *)aRequest
{
NSString *value;
NSRange range;
if (aRequest && ((value = [aRequest headerForKey:@"accept-encoding"]))) {
range = [value rangeOfString:@"gzip" options:0];
if (range.length) {
return YES;
}
}
return NO;
}
-(void)_finalizeContentEncodingInContext:(GSWContext*)aContext
{
#ifdef HAVE_LIBZ
int dataLength=0;
NSUInteger dataLength=0;
dataLength=[self _contentLength];
NSDebugMLog(@"dataLength=%d",dataLength);
// Now we see if we can gzip the content
if (dataLength>1024) // min length: 1024
// it does not make sense to compress data less than 150 bytes.
if ((dataLength > 150) && ([self _browserSupportsCompression:[aContext request]]))
{
NSString* contentType=[self headerForKey:@"content-type"];
NSString* contentEncoding=[self headerForKey:@"content-encoding"];
if ((contentEncoding) || (!compressableContentTypesCache)) {
return;
}
// only compress if we know it makes sense
if ([compressableContentTypesCache containsObject:contentType])
{
// we could do better by having parameters for types
NSArray* appAcceptedContentEncodingArray=[GSWApplication acceptedContentEncodingArray];
NSDebugMLog(@"appAcceptedContentEncodingArray=%@",appAcceptedContentEncodingArray);
if ([appAcceptedContentEncodingArray count]>0)
{
NSString* contentType=[self headerForKey:@"content-type"];
NSString* gzHeader=[self headerForKey:@"gzip"];
if ([contentType isEqual:@"text/html"])
{
NSString* contentEncoding=[self headerForKey:@"content-encoding"];
// we could do better by handling compress,...
if (([contentEncoding length]==0 // Not already encoded
&& [_acceptedEncodings containsObject:@"gzip"]
&& [appAcceptedContentEncodingArray containsObject:@"gzip"])
&& ((gzHeader == nil) || ([gzHeader isEqual:@"0"])))
{
NSDate* compressStartDate=[NSDate date];
NSData* content=[self content];
NSData* compressedData=[content deflate];
NSDebugMLog(@"compressedData=%@",compressedData);
if (compressedData)
{
#ifdef DEBUG
NSDate* compressStopDate=[NSDate date];
NSString* sizeInfoHeader=[NSString stringWithFormat:@"deflate from %d to %d in %0.3f s",
dataLength,
[compressedData length],
[compressStopDate timeIntervalSinceDate:compressStartDate]];
[self setHeader:sizeInfoHeader
forKey:@"deflate-info"];
NSDate* compressStartDate=[NSDate date];
#endif
[self setContent:compressedData];
dataLength=[self _contentLength];
[self setHeader:@"gzip"
forKey:@"content-encoding"];
};
};
};
};
};
NSData* content=[self content];
NSData* compressedData=[content deflate];
if (compressedData)
{
#ifdef DEBUG
NSDate* compressStopDate=[NSDate date];
NSString* sizeInfoHeader=[NSString stringWithFormat:@"deflate from %d to %d in %0.3f s",
dataLength,
[compressedData length],
[compressStopDate timeIntervalSinceDate:compressStartDate]];
[self setHeader:sizeInfoHeader
forKey:@"deflate-info"];
#endif
[self setContent:compressedData];
dataLength=[self _contentLength];
[self setHeader:@"gzip"
forKey:@"content-encoding"];
}
}
}
#endif // HAVE_LIBZ
}
//--------------------------------------------------------------------
-(void)_finalizeInContext:(GSWContext*)aContext
{
@ -373,10 +384,6 @@ escapingHTMLAttributeValue:(BOOL)escape
};
@end
//====================================================================
@implementation GSWResponse (GSWResponseB)
-(void)_resolveContentFaultsInContext:(GSWContext*)aContext
{
[self notImplemented: _cmd]; //TODOFN
@ -388,11 +395,6 @@ escapingHTMLAttributeValue:(BOOL)escape
[self notImplemented: _cmd]; //TODOFN
};
@end
//====================================================================
@implementation GSWResponse (GSWResponseC)
//--------------------------------------------------------------------
-(BOOL)_isClientCachingDisabled
{
@ -405,11 +407,6 @@ escapingHTMLAttributeValue:(BOOL)escape
return [_contentData length];
};
@end
//====================================================================
@implementation GSWResponse (GSWResponseD)
//--------------------------------------------------------------------
-(BOOL)_responseIsEqual:(GSWResponse*)aResponse
{
@ -417,20 +414,12 @@ escapingHTMLAttributeValue:(BOOL)escape
return NO;
};
@end
//====================================================================
@implementation GSWResponse (GSWActionResults)
//--------------------------------------------------------------------
-(GSWResponse*)generateResponse
{
return self;
};
@end
//====================================================================
@implementation GSWResponse (Stream)
-(void)setContentStreamFileHandle:(NSFileHandle*)fileHandle
bufferSize:(unsigned int)bufferSize
length:(unsigned long)length
@ -442,10 +431,6 @@ escapingHTMLAttributeValue:(BOOL)escape
_contentStreamBufferSize=bufferSize;
_contentStreamBufferLength=length;
};
@end
//====================================================================
@implementation GSWResponse (GSWResponseError)
//--------------------------------------------------------------------
//NDFN
@ -489,11 +474,6 @@ escapingHTMLAttributeValue:(BOOL)escape
return aResponse;
};
@end
//====================================================================
@implementation GSWResponse (GSWResponseRefused)
//--------------------------------------------------------------------
//
//Refuse Response
@ -542,11 +522,6 @@ escapingHTMLAttributeValue:(BOOL)escape
return response;
};
@end
//====================================================================
@implementation GSWResponse (GSWResponseRedirected)
//--------------------------------------------------------------------
-(void)_generateRedirectResponseWithMessage:(NSString*)message
location:(NSString*)location