Skip to content

Commit

Permalink
Use request timeout of 10 seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Mar 10, 2014
1 parent 1071f7b commit 3ba5f93
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions framework/Release/lib/Horde/Release/Freecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public function publish($params)
$params['tag_list'] = implode(', ', $params['tag_list']);
$fm_params = array('auth_code' => $this->_token,
'release' => $params);
$http = new Horde_Http_Client();
try {
$response = $http->post('https://freecode.com/projects/' . $this->_project . '/releases.json',
Horde_Serialize::serialize($fm_params, Horde_Serialize::JSON),
array('Content-Type' => 'application/json'));
$response = $this->_getClient()
->post('https://freecode.com/projects/' . $this->_project . '/releases.json',
Horde_Serialize::serialize($fm_params, Horde_Serialize::JSON),
array('Content-Type' => 'application/json'));
} catch (Horde_Http_Exception $e) {
if (strpos($e->getMessage(), '201 Created') === false) {
throw new Horde_Exception_Wrapped($e);
Expand All @@ -93,7 +93,7 @@ public function updateLinks($links)
{
// Need to get the list of current URLs first, then find the one we want
// to update.
$http = new Horde_Http_Client();
$http = $this->_getClient();
try {
$response = $http->get('https://freecode.com/projects/' . $this->_project . '/urls.json?auth_code=' . $this->_token);
} catch (Horde_Http_Exception $e) {
Expand All @@ -120,7 +120,6 @@ public function updateLinks($links)
}
$link = array('auth_code' => $this->_token,
'url' => $link);
$http = new Horde_Http_Client();
if (empty($permalink)) {
// No link found to update...create it.
try {
Expand Down Expand Up @@ -151,4 +150,9 @@ public function updateLinks($links)

return true;
}

protected function _getClient()
{
return new Horde_Http_Client(array('request.timeout' => 10));
}
}

0 comments on commit 3ba5f93

Please sign in to comment.