Sfoglia il codice sorgente

Attempt to fix cURL backend.

Miku AuahDark 3 anni fa
parent
commit
d05fd9b7d2
1 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. 7 2
      src/generic/CurlClient.cpp

+ 7 - 2
src/generic/CurlClient.cpp

@@ -73,10 +73,15 @@ HTTPSClient::Reply CurlClient::request(const HTTPSClient::Request &req)
 	curl.easy_setopt(handle, CURLOPT_URL, req.url.c_str());
 	curl.easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
 
+	if (req.method == "PUT")
+		curl.easy_setopt(handle, CURLOPT_PUT, 1L);
+	else if (req.method == "POST")
+		curl.easy_setopt(handle, CURLOPT_POST, 1L);
+	else
+		curl.easy_setopt(handle, CURLOPT_CUSTOMREQUEST, req.method.c_str());
+
 	if (req.postdata.size() > 0 && (req.method != "GET" && req.method != "HEAD"))
 	{
-		//curl.easy_setopt(handle, CURLOPT_POST, 1L);
-		curl.easy_setopt(handle, CURLOPT_CUSTOMREQUEST, req.method.c_str());
 		curl.easy_setopt(handle, CURLOPT_POSTFIELDS, req.postdata.c_str());
 		curl.easy_setopt(handle, CURLOPT_POSTFIELDSIZE, req.postdata.size());
 	}