X Tutup
Skip to content

Commit c840db3

Browse files
committed
Allow reading params of PUT more than once
1 parent 1e348ec commit c840db3

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lib/private/AppFramework/Http/Request.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ public function __get($name) {
256256
: null;
257257
case 'parameters':
258258
case 'params':
259+
if ($this->content === false) {
260+
return $this->items['parameters'];
261+
}
259262
return $this->getContent();
260263
default:
261264
return isset($this[$name])

tests/lib/AppFramework/Http/RequestTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,37 @@ public function testPutStream() {
332332
$this->fail('Expected LogicException.');
333333
}
334334

335+
public function testDoubleGetParamOnPut() {
336+
$vars = [
337+
'method' => 'PUT',
338+
'server' => [],
339+
];
340+
341+
$request = new Request(
342+
$vars,
343+
$this->secureRandom,
344+
$this->config,
345+
$this->csrfTokenManager,
346+
$this->stream
347+
);
348+
349+
// trigger decoding of the request
350+
$request->getParam('foo');
351+
352+
$request->setUrlParameters([
353+
'var1' => 'value1',
354+
'var2' => 'value2'
355+
]);
356+
357+
// it should be possible to get unlimited number of URL parameters
358+
// without reading the request body
359+
$var1 = $request->getParam('var1');
360+
$var2 = $request->getParam('var2');
361+
362+
$this->assertEquals('value1', $var1);
363+
$this->assertEquals('value2', $var2);
364+
}
365+
335366
public function testSetUrlParameters() {
336367
$vars = [
337368
'post' => [],

0 commit comments

Comments
 (0)
X Tutup