Just to post some enhancements to my early proposed changes.
------------------------------------------------------------------------
if not Assigned(FDocStream) then
PutStringInSendBuffer('Content-Length: 0' + #13#10)
else begin
if hoContentEncoding in FServer.Options then begin { V7.20 are
we allowed to compress content }
CompressionHandled := false;
TriggerContentEncode(ContentEncoding,
CompressionHandled); { let application do it, or find cached file }
if CompressionHandled then
PutStringInSendBuffer('Content-Encoding: ' +
ContentEncoding + #13#10)
else
if ((ContType = '') or (Pos ('text/', ContType) > 0))
and { only compress textual stuff }
((FDocStream.Size >= FServer.SizeCompressMin)
and { too small a waste of time }
(FDocStream.Size < FServer.SizeCompressMax)) then
begin { too large will block server and use a lot of memory }
if Pos('deflate', FRequestAcceptEncoding) > 0 then begin
ContentEncoding:='deflate';
ZStreamType := zsRaw;
end
else if Pos('gzip', FRequestAcceptEncoding) > 0 then
begin
ContentEncoding:='gzip';
ZStreamType := zSGZip;
end
else
ZStreamType := zsZLib;
if (ZStreamType <> zsZLib) {$IFNDEF USE_ZLIB_OBJ}and
ZLibLoaded {$ENDIF} then begin
PutStringInSendBuffer('Content-Encoding: ' +
ContentEncoding + #13#10);
ZDocStream := TMemoryStream.Create;
FDocStream.Seek (0, 0); { reset to start }
ZlibCompressStreamEx(FDocStream, ZDocStream,
clDefault, ZStreamType, true);
FDocStream.free;
FDocStream := ZDocStream;
TriggerContEncoded; { let application cache
compressed file or report what we did }
end;
end;
end;
PutStringInSendBuffer('Content-Length: ' +
_IntToStr(FDocStream.Size) + #13#10);
end;
-----------------------------------------------------
In OverbyteIcsZLibDll.pas
var
LoadDLLAlreadyTried:Boolean
Function ZLIbLoaded:boolean;
begin
if zlibDllLoaded then
result:=true
else if not LoadDLLAlreadyTried then begin
ZLibLoadDll(ZLibDllName);
result:=zlibDllLoaded;
LoadDLLAlreadyTried:=true;
end else
result:=false;
end;
initialization
LoadDLLAlreadyTried:=false;
...
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be