Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/private/AppFramework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ public function __get($name) {
: null;
case 'parameters':
case 'params':
if ($this->isPutStreamContent()) {
return $this->items['parameters'];
}
return $this->getContent();
default:
return isset($this[$name])
Expand Down Expand Up @@ -391,12 +394,7 @@ public function getCookie(string $key) {
*/
protected function getContent() {
// If the content can't be parsed into an array then return a stream resource.
if ($this->method === 'PUT'
&& $this->getHeader('Content-Length') !== '0'
&& $this->getHeader('Content-Length') !== ''
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
&& strpos($this->getHeader('Content-Type'), 'application/json') === false
) {
if ($this->isPutStreamContent()) {
if ($this->content === false) {
throw new \LogicException(
'"put" can only be accessed once if not '
Expand All @@ -411,6 +409,14 @@ protected function getContent() {
}
}

private function isPutStreamContent(): bool {
return $this->method === 'PUT'
&& $this->getHeader('Content-Length') !== '0'
&& $this->getHeader('Content-Length') !== ''
&& strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') === false
&& strpos($this->getHeader('Content-Type'), 'application/json') === false;
}

/**
* Attempt to decode the content and populate parameters
*/
Expand Down