1: <?php
2: /**
3: * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
4: *
5: * @author Chuck Hagenbuch <chuck@horde.org>
6: * @license http://www.horde.org/licenses/bsd BSD
7: * @category Horde
8: * @package Http
9: */
10:
11: /**
12: * @author Chuck Hagenbuch <chuck@horde.org>
13: * @license http://www.horde.org/licenses/bsd BSD
14: * @category Horde
15: * @package Http
16: */
17: class Horde_Http_Request_Factory
18: {
19: /**
20: * Find the best available request backend
21: *
22: * @return Horde_Http_Request_Base
23: */
24: public function create()
25: {
26: if (class_exists('HttpRequest', false)) {
27: return new Horde_Http_Request_Peclhttp();
28: } elseif (extension_loaded('curl')) {
29: return new Horde_Http_Request_Curl();
30: } elseif (ini_get('allow_url_fopen')) {
31: return new Horde_Http_Request_Fopen();
32: } else {
33: throw new Horde_Http_Exception('No HTTP request backends are available. You must install pecl_http, curl, or enable allow_url_fopen.');
34: }
35: }
36: }
37: