Skip to content

Commit 9886de2

Browse files
authored
Merge pull request #223 from fbourigault/issue-220
Issue 220
2 parents df9ddc3 + 4322ad4 commit 9886de2

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

lib/Gitlab/Api/AbstractApi.php

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,6 @@ protected function post($path, array $parameters = array(), $requestHeaders = ar
121121
return ResponseMediator::getContent($response);
122122
}
123123

124-
/**
125-
* @param string $path
126-
* @param array $parameters
127-
* @param array $requestHeaders
128-
* @return mixed
129-
*/
130-
protected function patch($path, array $parameters = array(), $requestHeaders = array())
131-
{
132-
$path = $this->preparePath($path);
133-
134-
$body = empty($parameters) ? null : $this->streamFactory->createStream(http_build_query($parameters));
135-
136-
$response = $this->client->getHttpClient()->patch($path, $requestHeaders, $body);
137-
138-
return ResponseMediator::getContent($response);
139-
}
140-
141124
/**
142125
* @param string $path
143126
* @param array $parameters
@@ -148,7 +131,11 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr
148131
{
149132
$path = $this->preparePath($path);
150133

151-
$body = empty($parameters) ? null : $this->streamFactory->createStream(http_build_query($parameters));
134+
$body = null;
135+
if (!empty($parameters)) {
136+
$body = $this->streamFactory->createStream(http_build_query($parameters));
137+
$requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
138+
}
152139

153140
$response = $this->client->getHttpClient()->put($path, $requestHeaders, $body);
154141

@@ -163,11 +150,9 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr
163150
*/
164151
protected function delete($path, array $parameters = array(), $requestHeaders = array())
165152
{
166-
$path = $this->preparePath($path);
167-
168-
$body = empty($parameters) ? null : $this->streamFactory->createStream(http_build_query($parameters));
153+
$path = $this->preparePath($path, $parameters);
169154

170-
$response = $this->client->getHttpClient()->delete($path, $requestHeaders, $body);
155+
$response = $this->client->getHttpClient()->delete($path, $requestHeaders);
171156

172157
return ResponseMediator::getContent($response);
173158
}

0 commit comments

Comments
 (0)