]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Add `connect-timeout` option for curl API command
authorTravis Cross <tc@traviscross.com>
Sun, 16 Nov 2014 19:16:39 +0000 (19:16 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 16 Nov 2014 19:31:00 +0000 (19:31 +0000)
This option sets the maximum number of seconds that curl will wait to
connect with the server.

Right now this is a synonym for the `timeout` option.

src/mod/applications/mod_curl/mod_curl.c

index bff5df864cbb22494bec28dbf113f19e64434cae..68c21f61e48054cc55f7ce59ae59377654ec4b28 100644 (file)
@@ -51,7 +51,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load);
  */
 SWITCH_MODULE_DEFINITION(mod_curl, mod_curl_load, mod_curl_shutdown, NULL);
 
-static char *SYNTAX = "curl url [headers|json|content-type <mime-type>|timeout <seconds>] [get|head|post|delete|put [data]]";
+static char *SYNTAX = "curl url [headers|json|content-type <mime-type>|connect-timeout <seconds>|timeout <seconds>] [get|head|post|delete|put [data]]";
 
 #define HTTP_SENDFILE_ACK_EVENT "curl_sendfile::ack"
 #define HTTP_SENDFILE_RESPONSE_SIZE 32768
@@ -944,6 +944,16 @@ SWITCH_STANDARD_API(curl_function)
                                if (++i < argc) {
                                        content_type = switch_core_strdup(pool, argv[i]);
                                }
+                       } else if (!strcasecmp("connect-timeout", argv[i])) {
+                               if (++i < argc) {
+                                       int tmp = atoi(argv[i]);
+
+                                       if (tmp > 0) {
+                                               options.connect_timeout = tmp;
+                                       } else {
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Invalid connect-timeout!\n");
+                                       }
+                               }
                        } else if (!strcasecmp("timeout", argv[i])) {
                                if (++i < argc) {
                                        int tmp = atoi(argv[i]);