From 9fe9c9b36d9acd1f16f3913a6feaa53de1ca750a Mon Sep 17 00:00:00 2001 From: mmicael Date: Fri, 28 Oct 2011 18:58:39 +0300 Subject: [PATCH 1/2] Add curl timeout For not blocking a script if Brightcove API is slow to respond --- bc-mapi.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bc-mapi.php b/bc-mapi.php index fd91f2b..8967f2b 100644 --- a/bc-mapi.php +++ b/bc-mapi.php @@ -1353,7 +1353,8 @@ private function curlRequest($request, $get_request = FALSE) curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $request); } - + // Add curl timeout + curl_setopt($curl, CURLOPT_TIMEOUT, 15); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl); From fb21d093c0540a0679fb710c437fedb2cfda6e1c Mon Sep 17 00:00:00 2001 From: mmicael Date: Fri, 28 Oct 2011 19:08:16 +0300 Subject: [PATCH 2/2] add attribute timeout --- bc-mapi.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bc-mapi.php b/bc-mapi.php index 8967f2b..2d8e33a 100644 --- a/bc-mapi.php +++ b/bc-mapi.php @@ -67,6 +67,7 @@ class BCMAPI private $media_delivery = 'default'; private $secure = FALSE; private $show_notices = FALSE; + private $timeout = 15; private $timeout_attempts = 100; private $timeout_current = 0; private $timeout_delay = 1; @@ -1354,7 +1355,7 @@ private function curlRequest($request, $get_request = FALSE) curl_setopt($curl, CURLOPT_POSTFIELDS, $request); } // Add curl timeout - curl_setopt($curl, CURLOPT_TIMEOUT, 15); + curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($curl);