You need to use deflateSetDictionary . It is available in Delphi XE2 ZLib.pas , but the compression stream classes do not expose the TZStreamRec field to call it. Class helpers can access the private fields of a related class, so you can get around this limitation by adding it to TCustomZStream (adding it to TZCompressionStream will not work).
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, dictionary, dictLength) else raise Exception.Create('Invalid class type'); end;
Just call SetDictionary with the SPDY line immediately after creating the compression stream.
source share