[Asterisk-code-review] Mofified funcs/func_curl.c so that 404's are handled as a failure (asterisk[master])

Dovid Bender asteriskteam at digium.com
Sun Sep 13 19:45:08 CDT 2020


Dovid Bender has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14900 )


Change subject: Mofified funcs/func_curl.c so that 404's are handled as a failure
......................................................................

Mofified funcs/func_curl.c so that 404's are handled as a failure

Change-Id: Ib10e14ce240e8ceb659da63ea11b1d91ce6b179a
---
M funcs/func_curl.c
1 file changed, 9 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/14900/1

diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index 3e09d1c..16d4a1c 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -655,7 +655,8 @@
 static int acf_curl_helper(struct ast_channel *chan, struct curl_args *args)
 {
 	struct ast_str *escapebuf = ast_str_thread_get(&thread_escapebuf, 16);
-	int ret = -1;
+	int ret = 0;
+	long http_code = 0;	
 	CURL **curl;
 	struct curl_settings *cur;
 	struct curl_slist *headers = NULL;
@@ -739,6 +740,13 @@
 	 * CURLOPT_ERRORBUFFER" (62bcf005f4678a93158358265ba905bace33b834). */
 	curl_easy_setopt(*curl, CURLOPT_ERRORBUFFER, (char*)NULL);
 
+	curl_easy_getinfo (*curl, CURLINFO_RESPONSE_CODE, &http_code);
+
+	if (http_code == 404){
+		ast_log(LOG_NOTICE, "Curl CURLINFO_RESPONSE_CODE (%ld).\n",http_code);
+		ret=-1;
+	}
+
 	if (store) {
 		AST_LIST_UNLOCK(list);
 	}
@@ -774,7 +782,6 @@
 			ast_free(fields);
 			ast_free(values);
 		}
-		ret = 0;
 	}
 
 	if (chan) {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14900
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib10e14ce240e8ceb659da63ea11b1d91ce6b179a
Gerrit-Change-Number: 14900
Gerrit-PatchSet: 1
Gerrit-Owner: Dovid Bender <dovid at telecurve.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200913/3617df22/attachment.html>


More information about the asterisk-code-review mailing list