]> git.lizzy.rs Git - minetest.git/blobdiff - src/httpfetch.cpp
Copy zlib and freetype dll to windows package too
[minetest.git] / src / httpfetch.cpp
index 176a3b22a057792d335da6e374f4d0ee0f201926..69c366ee00734f0a529ab7bfb32983f28075259c 100644 (file)
@@ -18,16 +18,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "socket.h" // for select()
-#include "porting.h" // for sleep_ms()
+#include "porting.h" // for sleep_ms(), get_sysinfo()
 #include "httpfetch.h"
 #include <iostream>
 #include <sstream>
 #include <list>
 #include <map>
 #include <errno.h>
-#ifndef _MSC_VER
-#include <sys/utsname.h>
-#endif
 #include "jthread/jevent.h"
 #include "config.h"
 #include "exceptions.h"
@@ -42,23 +39,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 JMutex g_httpfetch_mutex;
 std::map<unsigned long, std::list<HTTPFetchResult> > g_httpfetch_results;
 
-       HTTPFetchRequest::HTTPFetchRequest()
-       {
-               url = "";
-               caller = HTTPFETCH_DISCARD;
-               request_id = 0;
-               timeout = g_settings->getS32("curl_timeout");
-               connect_timeout = timeout * 5;
-               
-               useragent = std::string("Minetest ") + minetest_version_hash;
-#ifdef _MSC_VER
-               useragent += "Windows";
-#else
-               struct utsname osinfo;
-               uname(&osinfo);
-               useragent += std::string(" (") + osinfo.sysname + "; " + osinfo.release + "; " + osinfo.machine + ")";
-#endif
-       }
+HTTPFetchRequest::HTTPFetchRequest()
+{
+       url = "";
+       caller = HTTPFETCH_DISCARD;
+       request_id = 0;
+       timeout = g_settings->getS32("curl_timeout");
+       connect_timeout = timeout;
+
+       useragent = std::string("Minetest/") + minetest_version_hash + " (" + porting::get_sysinfo() + ")";
+}
 
 
 static void httpfetch_deliver_result(const HTTPFetchResult &fetchresult)
@@ -269,6 +259,10 @@ struct HTTPFetchOngoing
                                        request.extra_headers[i].c_str());
                        }
                        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, httpheader);
+
+                       if (!g_settings->getBool("curl_verify_cert")) {
+                               curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
+                       }
                }
        }
 
@@ -312,7 +306,7 @@ struct HTTPFetchOngoing
                }
 
                if (res != CURLE_OK) {
-                       infostream<<request.url<<" not found ("
+                       errorstream<<request.url<<" not found ("
                                <<curl_easy_strerror(res)<<")"
                                <<" (response code "<<result.response_code<<")"
                                <<std::endl;
@@ -548,7 +542,7 @@ class CurlFetchThread : public JThread
                if (select_timeout > 0) {
                        // in Winsock it is forbidden to pass three empty
                        // fd_sets to select(), so in that case use sleep_ms
-                       if (max_fd == -1) {
+                       if (max_fd != -1) {
                                select_tv.tv_sec = select_timeout / 1000;
                                select_tv.tv_usec = (select_timeout % 1000) * 1000;
                                int retval = select(max_fd + 1, &read_fd_set,
@@ -576,6 +570,8 @@ class CurlFetchThread : public JThread
                log_register_thread("CurlFetchThread");
                DSTACK(__FUNCTION_NAME);
 
+               porting::setThreadName("CurlFetchThread");
+
                CurlHandlePool pool;
 
                m_multi = curl_multi_init();