1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
TStringStream * C_Resp, *D_Resp;
unsigned char *GzipBuff ;
unsigned char *UnzipBuff = (unsigned char*)malloc(100000);
C_Resp = new TStringStream();
D_Resp = new TStringStream();
unsigned int SrcLen,DestLen;
Form1->IdHttp->Request->AcceptEncoding ="gzip,deflate";
Form1->IdHttp->Get("http://fr2.darkorbit.bigpoint.com",C_Resp);
SrcLen=C_Resp->Size;
GzipBuff = (unsigned char*)malloc(100000);
Zlib::z_stream strm;
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
int ret =inflateInit2(strm,16);
C_Resp->Seek(0, int(soBeginning));
C_Resp->Read(GzipBuff,SrcLen);
strm.avail_in = SrcLen;
strm.next_in = GzipBuff;
strm.avail_out = 100000; // taille max supposée du buffer décompressé.
strm.next_out = UnzipBuff;
inflate(strm,Z_NO_FLUSH);
DestLen=strm.total_out;
D_Resp->Write(Unzip,DestLen) |
Partager