Ver código fonte

Better error handling in xs_webmention_send().

grunfink 1 ano atrás
pai
commit
97568a7c93
1 arquivos alterados com 6 adições e 1 exclusões
  1. 6 1
      xs_webmention.h

+ 6 - 1
xs_webmention.h

@@ -105,11 +105,16 @@ int xs_webmention_send(const char *source, const char *target, const char *user_
         xs *body = xs_fmt("source=%s&target=%s", source, target);
         xs *body = xs_fmt("source=%s&target=%s", source, target);
 
 
         xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0);
         xs *rsp = xs_http_request("POST", endpoint, headers, body, strlen(body), &status, NULL, 0, 0);
+
+        if (status < 200 || status > 299)
+            status = -4;
+        else
+            status = 1;
     }
     }
     else
     else
         status = 0;
         status = 0;
 
 
-    return status >= 200 && status <= 299;
+    return status;
 }
 }