CURL* requestHandle = curl_easy_init();
curl_easy_setopt(requestHandle, CURLOPT_VERBOSE, 1L)
curl_easy_setopt(requestHandle, CURLOPT_NOSIGNAL, 1L) == CURLE_OK);
curl_easy_setopt(requestHandle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(requestHandle, CURLOPT_POSTREDIR, CURL_REDIR_POST_301 | CURL_REDIR_POST_302);
curl_easy_setopt(requestHandle, CURLOPT_ENCODING, "gzip");
curl_easy_setopt(_requestHandler, CURLOPT_URL, m_request.m_uri.GetBuffer();
curl_easy_setopt(_requestHandler, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(_requestHandler, CURLOPT_WRITEFUNCTION, WriteFunction);
curl_easy_setopt(_requestHandler, CURLOPT_WRITEDATA, m_response);
尽管将CURLOPT_ENCODING
设置为“ gzip”,但由于某种原因,我的请求返回仍被编码为乱码。它在“详细”输出中似乎未编码,但是在我的m_response
中的输出却未编码。如果我将CURLOPT_ENCODING
指定为“”(空字符串),它将为我正确解码输出。详细输出没有区别。
根据详细输出,我的外发请求有Accept-Encoding: gzip
入站响应具有HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 362\r\nContent-Encoding: gzip\r\n
为什么“”不能工作,但“ gzip”作为参数在这里工作?我正在使用libcurl 7.54.1