libcurl (linux, C) - Is there a built-in way to POST/PUT a gzipped request?

瘦欲@ 提交于 2019-12-11 08:34:33

问题


I want to perform a HTTP POST and/or PUT (using libcurl) with the request being compressed using GZIP. I haven't been able to find any native support for this in libcurl, and am wondering if I just haven't found the correct documentation or if there really is no support for this? (ie. Will I have to implement my own wrapper to gzip the request body?)


回答1:


HTTP has no "automatic" or negotiated compression for requests, you need to do them explicitly by yourself before sending the data.

Also, I disagree with Aditya who provided another answer (judging my bias it's not that strange) but would say that libcurl is one of the best possible options for you to do HTTP requests with C (or C++, or other languages) ...




回答2:


I would recommend not using libcurl if you are interested in supporting automatic proxy detection, certificate store (think HTTPS/SSL support) along with stuff like gzipping of requests.

You could use zlib for coming out of this situation, but what about other scenarios? It is better to use platform APIs for network requests even if overall program is platform independent in C++.



来源:https://stackoverflow.com/questions/7732950/libcurl-linux-c-is-there-a-built-in-way-to-post-put-a-gzipped-request

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