HTTP data content in Web Service interaction gzip,zlib format compression and decompression encapsulation (shared)

Source: Internet
Author: User

Click to download the standalone DLL

DLL internal Encapsulation API format

Gzipbool  fnzlibdecompresspacket (__in_param unsigned char* gzlibdatabuffer, __in_param size_t gZLibDataLength,_ _out_param char* pchdatabuffer,__out_param DWORD *pdwlength); BOOL  fnzlibcompresspacket (__in_param unsigned char* gzlibdatabuffer, __in_param size_t gzlibdatalength,__out_ PARAM char * pchgzipoutdata,__out_param DWORD *pdwlength);//zlibbool fngzipdecompresspacket (__in_param unsigned char* Gzipdatabuffer,__in_param size_t gzipdatabuffer_length, __out_param char* pchdatabuffer,__out_param DWORD *pdwLength) ; BOOL Fngzipcompresspacket (__in_param const char * gzipdatabuffer,__in_param int Gzipdatabuffer_length,__out_param Char * Dstdatabuffer, __out_param int *pdwlength);


Gzip Call Core Code Demo


typedef BOOL (*uncompressiongzippackettobuffer) (unsigned char* gzipdatabuffer, size_t gzipdatalength, char * pdatabuff Er,dword *dwlength); typedef BOOL (*compressionbufferpackettogzip) (unsigned char* chdatabuffer, size_t chdatalength, C har* Pgzipbuffer,dword *dwlength);    HINSTANCE Hinst=null;    Uncompressiongzippackettobuffer Ungzippacket;    Compressionbufferpackettogzip Comgzipbuffer;    Hinst=loadlibrary (_t ("GzipZlibdll.dll")); if (hinst==null) {return-1;} ungzippacket= (Uncompressiongzippackettobuffer) GetProcAddress (HInst, "Fngzipdecompresspacket");   Comgzipbuffer= (Compressionbufferpackettogzip) GetProcAddress (HInst, "Fngzipcompresspacket");    if (ungzippacket==null) {return-1;} if (comgzipbuffer==null) {return-1; } BOOL Bret=ungzippacket ((unsigned char*) pchgzipbuff,dwreaded,pchdatabuff,&dwtransfersize);// Note that the dwgzipsize must have a value here, cannot pass 0 considering compression must be smaller than the original data. Transfer dwtransfersize size can be bool Breturn=comgzipbuffer ((unsigned char*) PCHDATABUFF,DWTRANSFERSIZE,PCHGZIPBUff,&dwgzipsize); FreeLibrary (HInst);


Zlib Demo example.


HTTP data content in Web Service interaction gzip,zlib format compression and decompression encapsulation (shared)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.