Is there any compression available in libcurl

佐手、 提交于 2019-12-11 07:31:43

问题


I need to transfer a huge file from local machine to remote machine using libcurl with C++. Is there any compression option available in-built with libcurl. As the data to be transferred is large (100 MB to 1 GB in size), it would be better if we have any such options available in libcurl itself. I know we can compress the data and send it via libcurl. But just want to know is there any better way of doing so.

Note: In my case, many client machines transfer such huge data to remote server at regular interval of time.

thanks, Prabu


回答1:


According to curl_setopt() and options CURLOPT_ENCODING, you may specify:

The contents of the "Accept-Encoding: " header. This enables decoding of the response. Supported encodings are "identity", "deflate", and "gzip". If an empty string, "", is set, a header containing all supported encoding types is sent.

Here are some examples (just hit search in your browser and type in compression), but I don't know hot exactly does it work and whether it expect already gzipped data.

You still may use gzcompress() and send compressed chunks on your own (and I would do the task this way... you'll have better control on what's actually going on and you'll be able to change used algorithms).




回答2:


You need to send your file with zlib compression by yourself. And perhaps there are some modification needed on the server-side.



来源:https://stackoverflow.com/questions/13379888/is-there-any-compression-available-in-libcurl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!