Skip to content

Commit c07c4d0

Browse files
authored
Merge pull request #245 from aik099/trailing-question-mark-in-get-requests-fix
Don't send trailing "?" in GET API urls without parameters
2 parents cc6f50b + 571e2e2 commit c07c4d0

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/Jira/Api/Client/CurlClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function sendRequest(
7777

7878
$curl = curl_init();
7979

80-
if ( $method == 'GET' ) {
80+
if ( $method == 'GET' && $data ) {
8181
if ( !is_array($data) ) {
8282
throw new \InvalidArgumentException('Data must be an array.');
8383
}

src/Jira/Api/Client/PHPClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function sendRequest(
151151
$context['http']['header'] = implode("\r\n", $header);
152152
$context['http']['content'] = $__data;
153153
}
154-
elseif ( $method == 'GET' ) {
154+
elseif ( $method == 'GET' && $data ) {
155155
if ( !is_array($data) ) {
156156
throw new \InvalidArgumentException('Data must be an array.');
157157
}

tests/Jira/Api/Client/AbstractClientTestCase.php

+7
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ public static function emptyResponseWithKnownHttpCodeDataProvider()
243243
);
244244
}
245245

246+
public function testNoTrailingQuestionMarkInGetRequests()
247+
{
248+
$trace_result = $this->traceRequest(Api::REQUEST_GET);
249+
250+
$this->assertEquals('/', substr($trace_result['_SERVER']['REQUEST_URI'], -1), 'Incorrect URI ending symbol');
251+
}
252+
246253
/**
247254
* Checks, that request contained specified content type.
248255
*

0 commit comments

Comments
 (0)