gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 02/02: -fetch response code first before testing on it


From: gnunet
Subject: [gnunet] 02/02: -fetch response code first before testing on it
Date: Fri, 30 Jul 2021 16:10:29 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit fd277f253027f03f3a7b0dc8acc935e799d645f5
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Jul 30 15:57:10 2021 +0200

    -fetch response code first before testing on it
---
 src/curl/curl.c | 34 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 23 deletions(-)

diff --git a/src/curl/curl.c b/src/curl/curl.c
index 79aac74ce..71672c780 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -759,6 +759,15 @@ GNUNET_CURL_download_get_result_ (struct 
GNUNET_CURL_DownloadBuffer *db,
               "Downloaded body: %.*s\n",
               (int) db->buf_size,
               (char *) db->buf);
+  if (CURLE_OK !=
+      curl_easy_getinfo (eh,
+                         CURLINFO_RESPONSE_CODE,
+                         response_code))
+  {
+    /* unexpected error... */
+    GNUNET_break (0);
+    *response_code = 0;
+  }
   if ((CURLE_OK !=
        curl_easy_getinfo (eh,
                           CURLINFO_CONTENT_TYPE,
@@ -768,15 +777,6 @@ GNUNET_CURL_download_get_result_ (struct 
GNUNET_CURL_DownloadBuffer *db,
   {
     /* No content type or explicitly not JSON, refuse to parse
        (but keep response code) */
-    if (CURLE_OK !=
-        curl_easy_getinfo (eh,
-                           CURLINFO_RESPONSE_CODE,
-                           response_code))
-    {
-      /* unexpected error... */
-      GNUNET_break (0);
-      *response_code = 0;
-    }
     if (0 != db->buf_size)
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Did NOT detect response `%.*s' as JSON\n",
@@ -784,6 +784,8 @@ GNUNET_CURL_download_get_result_ (struct 
GNUNET_CURL_DownloadBuffer *db,
                   (const char *) db->buf);
     return NULL;
   }
+  if (MHD_HTTP_NO_CONTENT == *response_code)
+    return NULL;
   if (0 == *response_code)
   {
     char *url;
@@ -798,8 +800,6 @@ GNUNET_CURL_download_get_result_ (struct 
GNUNET_CURL_DownloadBuffer *db,
                 url);
     return NULL;
   }
-  if (MHD_HTTP_NO_CONTENT == *response_code)
-    return NULL;
   json = NULL;
   if (0 == db->eno)
   {
@@ -816,18 +816,6 @@ GNUNET_CURL_download_get_result_ (struct 
GNUNET_CURL_DownloadBuffer *db,
   GNUNET_free (db->buf);
   db->buf = NULL;
   db->buf_size = 0;
-  if (NULL != json)
-  {
-    if (CURLE_OK !=
-        curl_easy_getinfo (eh,
-                           CURLINFO_RESPONSE_CODE,
-                           response_code))
-    {
-      /* unexpected error... */
-      GNUNET_break (0);
-      *response_code = 0;
-    }
-  }
   return json;
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]