Skip to content

Commit fbfc9fa

Browse files
committed
[Network][Http] Add OPTIONS/TRACE verb support
1 parent ea4e0e6 commit fbfc9fa

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/Network/Http/Client.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,36 @@ public function patch($url, $data = [], array $options = [])
254254
return $this->_doRequest(Request::METHOD_PATCH, $url, $data, $options);
255255
}
256256

257+
/**
258+
* Do an OPTIONS request.
259+
*
260+
* @param string $url The url or path you want to request.
261+
* @param mixed $data The request data you want to send.
262+
* @param array $options Additional options for the request.
263+
* @return \Cake\Network\Http\Response
264+
*/
265+
public function options($url, $data = [], array $options = [])
266+
{
267+
$options = $this->_mergeOptions($options);
268+
$url = $this->buildUrl($url, [], $options);
269+
return $this->_doRequest(Request::METHOD_OPTIONS, $url, $data, $options);
270+
}
271+
272+
/**
273+
* Do a TRACE request.
274+
*
275+
* @param string $url The url or path you want to request.
276+
* @param mixed $data The request data you want to send.
277+
* @param array $options Additional options for the request.
278+
* @return \Cake\Network\Http\Response
279+
*/
280+
public function trace($url, $data = [], array $options = [])
281+
{
282+
$options = $this->_mergeOptions($options);
283+
$url = $this->buildUrl($url, [], $options);
284+
return $this->_doRequest(Request::METHOD_TRACE, $url, $data, $options);
285+
}
286+
257287
/**
258288
* Do a DELETE request.
259289
*

src/Network/Http/Message.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ class Message
106106
*/
107107
const METHOD_PATCH = 'PATCH';
108108

109+
/**
110+
* HTTP OPTIONS method
111+
*
112+
* @var string
113+
*/
114+
const METHOD_OPTIONS = 'OPTIONS';
115+
116+
/**
117+
* HTTP TRACE method
118+
*
119+
* @var string
120+
*/
121+
const METHOD_TRACE = 'TRACE';
122+
109123
/**
110124
* HTTP HEAD method
111125
*

tests/TestCase/Network/Http/ClientTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ public static function methodProvider()
319319
[Request::METHOD_PUT],
320320
[Request::METHOD_DELETE],
321321
[Request::METHOD_PATCH],
322+
[Request::METHOD_OPTIONS],
323+
[Request::METHOD_TRACE],
322324
];
323325
}
324326
/**

0 commit comments

Comments
 (0)