delphi – TCompressionStream用数据初始化
发布时间:2020-12-15 04:10:41 所属栏目:大数据 来源:网络整理
导读:SPDY协议指定使用预定义的数据块初始化名称/值数据的压缩: http://mbelshe.github.com/SPDY-Specification/draft-mbelshe-spdy-00.xml#rfc.section.2.6.9.1 (zlib压缩的工作方式是,对于“看起来”再次出现更多的字符串,它将使用更少的位,因此如果您使用通常
SPDY协议指定使用预定义的数据块初始化名称/值数据的压缩:
http://mbelshe.github.com/SPDY-Specification/draft-mbelshe-spdy-00.xml#rfc.section.2.6.9.1 (zlib压缩的工作方式是,对于“看起来”再次出现更多的字符串,它将使用更少的位,因此如果您使用通常的嫌疑人预加载压缩,那么在压缩之后您可能会得到更少的位当时.但现在我真正的问题:) 这可能来自ZLib单元的Delphi的TCompressionStream吗? 解决方法
您需要使用
deflateSetDictionary.它可以在Delphi XE2的ZLib.pas中使用,但压缩流类不会公开TZStreamRec字段来调用它.类助手可以访问关联类的私有字段,因此您可以通过向TCustomZStream添加一个来解决该限制(将其添加到TZCompressionStream将不起作用).
type TCustomZStreamHelper = class helper for TCustomZStream function SetDictionary(dictionary: PByte; dictLength: Cardinal): Integer; end; function TCustomZStreamHelper.SetDictionary(dictionary: PByte; dictLength: Cardinal): Integer; begin if Self is TZCompressionStream then Result := deflateSetDictionary(Self.FZStream,dictionary,dictLength) else if Self is TZDecompressionStream then Result := inflateSetDictionary(Self.FZStream,dictLength) else raise Exception.Create('Invalid class type'); end; 在创建压缩流后立即使用SPDY字符串调用SetDictionary. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |