diff --git a/GSWeb.framework/GSWResponse.m b/GSWeb.framework/GSWResponse.m index 60b88cb..928e04e 100644 --- a/GSWeb.framework/GSWResponse.m +++ b/GSWeb.framework/GSWResponse.m @@ -260,13 +260,17 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse* if ([appAcceptedContentEncodingArray count]>0) { NSString* contentType=[self headerForKey:@"content-type"]; + NSString* gzHeader=[self headerForKey:@"gzip"]; + if ([contentType isEqualTo:@"text/html"]) { NSString* contentEncoding=[self headerForKey:@"content-encoding"]; // we could do better by handling compress,... - if ([contentEncoding length]==0 // Not already encoded + if (([contentEncoding length]==0 // Not already encoded && [_acceptedEncodings containsObject:@"gzip"] - && [appAcceptedContentEncodingArray containsObject:@"gzip"]) + && [appAcceptedContentEncodingArray containsObject:@"gzip"]) + && ((gzHeader == nil) || ([gzHeader isEqual:@"0"]))) + { NSDate* compressStartDate=[NSDate date]; NSData* content=[self content]; diff --git a/GSWeb.framework/NSData+Compress.m b/GSWeb.framework/NSData+Compress.m index 1bc137b..e4488d0 100644 --- a/GSWeb.framework/NSData+Compress.m +++ b/GSWeb.framework/NSData+Compress.m @@ -59,16 +59,14 @@ static int gzHeaderSize=10; int err=Z_OK; unsigned int selfLength=[self length]; - c_stream.zalloc = (alloc_func)0; - c_stream.zfree = (free_func)0; - c_stream.opaque = (voidpf)0; + memset (&c_stream, 0, sizeof(c_stream)); - err = deflateInit2(&c_stream, - Z_BEST_COMPRESSION, - Z_DEFLATED, - -15, - 9, - Z_DEFAULT_STRATEGY); + err = deflateInit2(&c_stream, /* z_streamp strm */ + 4, /* int level */ + Z_DEFLATED, /* int method */ + -15, /* int windowBits */ + 8, /* int memLevel */ + Z_DEFAULT_STRATEGY); /* int strategy */ if (err!=Z_OK) { LOGError(@"deflateInit2 error: %d",err);