Skip to content

Commit

Permalink
Allow reading params of PUT more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed May 14, 2020
1 parent 1e348ec commit c840db3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/private/AppFramework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public function __get($name) {
: null;
case 'parameters':
case 'params':
if ($this->content === false) {
return $this->items['parameters'];
}
return $this->getContent();
default:
return isset($this[$name])
Expand Down
31 changes: 31 additions & 0 deletions tests/lib/AppFramework/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,37 @@ public function testPutStream() {
$this->fail('Expected LogicException.');
}

public function testDoubleGetParamOnPut() {
$vars = [
'method' => 'PUT',
'server' => [],
];

$request = new Request(
$vars,
$this->secureRandom,
$this->config,
$this->csrfTokenManager,
$this->stream
);

// trigger decoding of the request
$request->getParam('foo');

$request->setUrlParameters([
'var1' => 'value1',
'var2' => 'value2'
]);

// it should be possible to get unlimited number of URL parameters
// without reading the request body
$var1 = $request->getParam('var1');
$var2 = $request->getParam('var2');

$this->assertEquals('value1', $var1);
$this->assertEquals('value2', $var2);
}

public function testSetUrlParameters() {
$vars = [
'post' => [],
Expand Down

0 comments on commit c840db3

Please sign in to comment.