From eb06c8a33edec61ed7bfa9c5470465c2d3945e56 Mon Sep 17 00:00:00 2001 From: jfefe <jf.ferry@aternatik.fr> Date: Sat, 11 Oct 2014 04:25:32 +0200 Subject: [PATCH] Allow to make PUT request with getURLContent() function --- htdocs/core/lib/geturl.lib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 8a9ac1385be..50c02125fb7 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -72,6 +72,13 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea curl_setopt($ch, CURLOPT_POST, 1); // POST curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields } + else if ($postorget == 'PUT') + { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT' + if ( ! is_array($param) ) + parse_str($param, $array_param); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields + } else if ($postorget == 'HEAD') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD' -- GitLab