try convert once

This commit is contained in:
Sergey Linnik
2017-10-09 17:16:24 +03:00
parent 6088e7d685
commit f376c50fd9
4 changed files with 2 additions and 43 deletions

View File

@ -38,8 +38,5 @@ $GLOBALS['ExtsDocument'] = array(".doc", ".docx", ".docm",
".html", ".htm", ".mht",
".pdf", ".djvu", ".fb2", ".epub", ".xps");
if ( !defined('ServiceConverterMaxTry') )
define( 'ServiceConverterMaxTry', 3);
?>

View File

@ -219,8 +219,6 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
)
);
$countTry = 0;
$opts = array('http' => array(
'method' => 'POST',
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT'],
@ -235,17 +233,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
}
$context = stream_context_create($opts);
while ($countTry < ServiceConverterMaxTry)
{
$countTry = $countTry + 1;
$response_data = file_get_contents($urlToConverter, FALSE, $context);
if ($response_data !== false) { break; }
}
if ($countTry == ServiceConverterMaxTry)
{
throw new Exception ("Bad Request or timeout error");
}
$response_data = file_get_contents($urlToConverter, FALSE, $context);
return $response_data;
}