dirmngr: New function http_status2string.
authorWerner Koch <wk@gnupg.org>
Tue, 11 Dec 2018 12:24:21 +0000 (13:24 +0100)
committerWerner Koch <wk@gnupg.org>
Tue, 11 Dec 2018 12:24:31 +0000 (13:24 +0100)
* dirmngr/http.c (http_status2string): New.
--

Right now only the standard 5xx codes.

Signed-off-by: Werner Koch <wk@gnupg.org>
dirmngr/http.c
dirmngr/http.h

index 6c183b2..eb7d99a 100644 (file)
@@ -3663,3 +3663,27 @@ http_prepare_redirect (http_redir_info_t *info, unsigned int status_code,
   *r_url = newurl;
   return 0;
 }
+
+
+/* Return string describing the http STATUS.  Returns an empty string
+ * for an unknown status.  */
+const char *
+http_status2string (unsigned int status)
+{
+  switch (status)
+    {
+    case 500: return "Internal Server Error";
+    case 501: return "Not Implemented";
+    case 502: return "Bad Gateway";
+    case 503: return "Service Unavailable";
+    case 504: return "Gateway Timeout";
+    case 505: return "HTTP version Not Supported";
+    case 506: return "Variant Also Negation";
+    case 507: return "Insufficient Storage";
+    case 508: return "Loop Detected";
+    case 510: return "Not Extended";
+    case 511: return "Network Authentication Required";
+    }
+
+  return "";
+}
index 4755b92..492e867 100644 (file)
@@ -197,5 +197,7 @@ gpg_error_t http_prepare_redirect (http_redir_info_t *info,
                                    unsigned int status_code,
                                    const char *location, char **r_url);
 
+const char *http_status2string (unsigned int status);
+
 
 #endif /*GNUPG_COMMON_HTTP_H*/