Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

HTTP Client Supporting PATCH Method #793

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+16 −3
Split
@@ -358,7 +358,8 @@ public function setMethod($method)
$method = $this->getRequest()->setMethod($method)->getMethod();
if (($method == Request::METHOD_POST || $method == Request::METHOD_PUT ||
- $method == Request::METHOD_DELETE) && empty($this->encType)) {
+ $method == Request::METHOD_DELETE || $method == Request::METHOD_PATCH)
+ && empty($this->encType)) {
$this->setEncType(self::ENC_URLENCODED);
}
@@ -1097,7 +1098,7 @@ protected function prepareHeaders($body, $uri)
/**
- * Prepare the request body (for POST and PUT requests)
+ * Prepare the request body (for POST, PUT, and PATCH requests)
*
* @return string
* @throws \Zend\Http\Client\Exception
@@ -22,6 +22,7 @@ class Request extends Message implements RequestDescription
const METHOD_DELETE = 'DELETE';
const METHOD_TRACE = 'TRACE';
const METHOD_CONNECT = 'CONNECT';
+ const METHOD_PATCH = 'PATCH';
/**#@-*/
/**#@+
@@ -92,7 +93,8 @@ public static function fromString($string)
$matches = null;
$methods = implode('|', array(
self::METHOD_OPTIONS, self::METHOD_GET, self::METHOD_HEAD, self::METHOD_POST,
- self::METHOD_PUT, self::METHOD_DELETE, self::METHOD_TRACE, self::METHOD_CONNECT
+ self::METHOD_PUT, self::METHOD_DELETE, self::METHOD_TRACE, self::METHOD_CONNECT,
+ self::METHOD_PATCH
));
$regex = '^(?P<method>' . $methods . ')\s(?<uri>[^ ]*)(?:\sHTTP\/(?<version>\d+\.\d+)){0,1}';
$firstLine = array_shift($lines);
@@ -492,6 +494,16 @@ public function isConnect()
}
/**
+ * Is this a PATCH method request?
+ *
+ * @return bool
+ */
+ public function isPatch()
+ {
+ return ($this->method === self::METHOD_PATCH);
+ }
+
+ /**
* Return the formatted request line (first line) for this http request
*
* @return string