The SPDY protocol specifies to initialize the compression of name/value data with a predefined block of data:
http://mbelshe.github.com/SPDY-Specification/draft-mbelshe-spdy-00.xml#rfc.section.2.6.9.1
(The way zlib compression works is that it will use less bits for strings of characters that ‘appear’ to reoccur more, so if you pre-load compression with the usual suspects, chances are you’ll end up with less bits after compression more of the time. But now for my real question:)
Is this possible with Delphi’s TCompressionStream from the ZLib unit?
You need to use deflateSetDictionary. It’s available in Delphi XE2’s ZLib.pas, but the compression stream classes don’t expose the
TZStreamRecfield to call it on. Class helpers can access private fields of the associated class, so you can work around that limitation by adding one toTCustomZStream(adding it toTZCompressionStreamwon’t work).Just call SetDictionary with the SPDY string immediately after creating the compression stream.