From 1aaf5962cbdcc5a2ad97f01598ec7ce5f93aabcd Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Wed, 23 Oct 2019 20:09:42 +0530 Subject: initial commit --- Apache/Solr/HttpTransport/Abstract.php | 89 ++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 Apache/Solr/HttpTransport/Abstract.php (limited to 'Apache/Solr/HttpTransport/Abstract.php') diff --git a/Apache/Solr/HttpTransport/Abstract.php b/Apache/Solr/HttpTransport/Abstract.php new file mode 100755 index 0000000..cf9f76d --- /dev/null +++ b/Apache/Solr/HttpTransport/Abstract.php @@ -0,0 +1,89 @@ +, Donovan Jimenez + */ + +/** + * Convenience class that implements the transport implementation. Can be extended by + * real implementations to do some of the common book keeping + */ +abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface +{ + /** + * Our default timeout value for requests that don't specify a timeout + * + * @var float + */ + private $_defaultTimeout = false; + + /** + * Get the current default timeout setting (initially the default_socket_timeout ini setting) + * in seconds + * + * @return float + */ + public function getDefaultTimeout() + { + // lazy load the default timeout from the ini settings + if ($this->_defaultTimeout === false) + { + $this->_defaultTimeout = (int) ini_get('default_socket_timeout'); + + // double check we didn't get 0 for a timeout + if ($this->_defaultTimeout <= 0) + { + $this->_defaultTimeout = 60; + } + } + + return $this->_defaultTimeout; + } + + /** + * Set the current default timeout for all HTTP requests + * + * @param float $timeout + */ + public function setDefaultTimeout($timeout) + { + $timeout = (float) $timeout; + + if ($timeout >= 0) + { + $this->_defaultTimeout = $timeout; + } + } +} \ No newline at end of file -- cgit