From ed2a2df98223fdd6b06496242e0974302597bdee Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Wed, 14 Jan 2015 18:15:13 -0500 Subject: [PATCH] updating Request utility methods to match all of RFC7231 --- src/Unirest/Request.php | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/Unirest/Request.php b/src/Unirest/Request.php index 2ad7b6d..fd67ba9 100644 --- a/src/Unirest/Request.php +++ b/src/Unirest/Request.php @@ -61,6 +61,48 @@ class Request return self::send(Method::GET, $url, $parameters, $headers, $username, $password); } + /** + * Send a HEAD request to a URL + * @param string $url URL to send the HEAD request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username + * @param string $password Basic Authentication password + * @return string|stdObj response string or stdObj if response is json-decodable + */ + public static function head($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::HEAD, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a OPTIONS request to a URL + * @param string $url URL to send the OPTIONS request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username + * @param string $password Basic Authentication password + * @return string|stdObj response string or stdObj if response is json-decodable + */ + public static function options($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::OPTIONS, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a CONNECT request to a URL + * @param string $url URL to send the CONNECT request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username + * @param string $password Basic Authentication password + * @return string|stdObj response string or stdObj if response is json-decodable + */ + public static function connect($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::CONNECT, $url, $parameters, $headers, $username, $password); + } + /** * Send POST request to a URL * @param string $url URL to send the POST request to @@ -117,6 +159,20 @@ class Request return self::send(Method::PATCH, $url, $body, $headers, $username, $password); } + /** + * Send TRACE request to a URL + * @param string $url URL to send the TRACE request to + * @param array $headers additional headers to send + * @param mixed $body TRACE body data + * @param string $username Basic Authentication username + * @param string $password Basic Authentication password + * @return string|stdObj response string or stdObj if response is json-decodable + */ + public static function trace($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::TRACE, $url, $body, $headers, $username, $password); + } + /** * Prepares a file for upload. To be used inside the parameters declaration for a request. * @param string $path The file path