Don't hardcode supported HTTP methods.
authorJan Schneider <jan@horde.org>
Thu, 1 Apr 2010 17:33:57 +0000 (19:33 +0200)
committerJan Schneider <jan@horde.org>
Mon, 5 Apr 2010 22:16:52 +0000 (00:16 +0200)
framework/Http/lib/Horde/Http/Request/Peclhttp.php

index feedf9f..95df64f 100644 (file)
 class Horde_Http_Request_Peclhttp extends Horde_Http_Request_Base
 {
     /**
-     * Map of HTTP methods to HTTP_METH_* constants
-     * @var array
-     */
-    protected $_httpMethods = array(
-        'GET' => HTTP_METH_GET,
-        'HEAD' => HTTP_METH_HEAD,
-        'POST' => HTTP_METH_POST,
-        'PUT' => HTTP_METH_PUT,
-        'DELETE' => HTTP_METH_DELETE,
-    );
-
-    /**
      * Map of HTTP authentication schemes from Horde_Http constants to HTTP_AUTH constants.
      * @var array
      */
@@ -62,7 +50,11 @@ class Horde_Http_Request_Peclhttp extends Horde_Http_Request_Base
      */
     public function send()
     {
-        $httpRequest = new HttpRequest($this->uri, $this->_httpMethods[$this->method]);
+        if (!defined('HTTP_METH_' . $this->method)) {
+            throw new Horde_Http_Exception('Method ' . $this->method . ' not supported.'); 
+        }
+
+        $httpRequest = new HttpRequest($this->uri, constant('HTTP_METH_' . $this->method));
 
         $data = $this->data;
         if (is_array($data)) {