问题
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