Skip to content

Commit

Permalink
[Network][Http] Add OPTIONS/TRACE verb support
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs committed Apr 19, 2015
1 parent ea4e0e6 commit fbfc9fa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Network/Http/Client.php
Expand Up @@ -254,6 +254,36 @@ public function patch($url, $data = [], array $options = [])
return $this->_doRequest(Request::METHOD_PATCH, $url, $data, $options);
}

/**
* Do an OPTIONS request.
*
* @param string $url The url or path you want to request.
* @param mixed $data The request data you want to send.
* @param array $options Additional options for the request.
* @return \Cake\Network\Http\Response
*/
public function options($url, $data = [], array $options = [])
{
$options = $this->_mergeOptions($options);
$url = $this->buildUrl($url, [], $options);
return $this->_doRequest(Request::METHOD_OPTIONS, $url, $data, $options);
}

/**
* Do a TRACE request.
*
* @param string $url The url or path you want to request.
* @param mixed $data The request data you want to send.
* @param array $options Additional options for the request.
* @return \Cake\Network\Http\Response
*/
public function trace($url, $data = [], array $options = [])
{
$options = $this->_mergeOptions($options);
$url = $this->buildUrl($url, [], $options);
return $this->_doRequest(Request::METHOD_TRACE, $url, $data, $options);
}

/**
* Do a DELETE request.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Network/Http/Message.php
Expand Up @@ -106,6 +106,20 @@ class Message
*/
const METHOD_PATCH = 'PATCH';

/**
* HTTP OPTIONS method
*
* @var string
*/
const METHOD_OPTIONS = 'OPTIONS';

/**
* HTTP TRACE method
*
* @var string
*/
const METHOD_TRACE = 'TRACE';

/**
* HTTP HEAD method
*
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase/Network/Http/ClientTest.php
Expand Up @@ -319,6 +319,8 @@ public static function methodProvider()
[Request::METHOD_PUT],
[Request::METHOD_DELETE],
[Request::METHOD_PATCH],
[Request::METHOD_OPTIONS],
[Request::METHOD_TRACE],
];
}
/**
Expand Down

0 comments on commit fbfc9fa

Please sign in to comment.