在内容前面添加2个字节 deflate_dummy_header: array [0..1] of Byte = (120, 1); 就可以。你得智能判断,不能所有deflate编码的页面全部加。给你一段参考代码片段 zlibStrm.next_out := PByte(@dest); zlibStrm.avail_out := SizeOf(dest); ret := inflate(zlibStrm, Z_NO_FLUSH);
if ret in [Z_OK, Z_STREAM_END] then isFirstByte := False else if (ret = Z_DATA_ERROR) and isFirstByte then begin inflateReset(zlibStrm); zlibStrm.next_in := @deflate_dummy_header[0]; zlibStrm.avail_in := SizeOf(deflate_dummy_header); zlibStrm.next_out := PByte(@dest); zlibStrm.avail_out := SizeOf(dest); ret := inflate(zlibStrm, Z_NO_FLUSH);
if ret = Z_OK then begin zlibStrm.next_in := PByte(buf); zlibStrm.avail_in := len; ret := inflate(zlibStrm, Z_NO_FLUSH); end; end;
----------------------------------------------
这家伙很懒,什么都没有留下。
if fGZIPAllowed and (Pos('content-encoding: gzip', LowerCase(Headers.Text)) > 0) then begin try GZDecompressStream(Document, MemStream); bOK := True; except bOK := False; end;
if bOK then begin Document.Clear; Document.LoadFromStream(MemStream); end; end;
----------------------------------------------
-