-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(OCS): Add IRequest::getFormat to determine the response Content-Type the same way everywhere #54627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(OCS): Add IRequest::getFormat to determine the response Content-Type the same way everywhere #54627
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -877,4 +877,23 @@ private function fromTrustedProxy(): bool { | |
|
|
||
| return \is_array($trustedProxies) && $this->isTrustedProxy($trustedProxies, $remoteAddress); | ||
| } | ||
|
|
||
| public function getFormat(): ?string { | ||
| $format = $this->getParam('format'); | ||
| if ($format !== null) { | ||
| return $format; | ||
| } | ||
|
|
||
| $prefix = 'application/'; | ||
| $headers = explode(',', $this->getHeader('Accept')); | ||
| foreach ($headers as $header) { | ||
| $header = strtolower(trim($header)); | ||
|
|
||
| if (str_starts_with($header, $prefix)) { | ||
| return substr($header, strlen($prefix)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opposed to This works properly until Nextcloud 31.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have upstreamed https://github.com/nextcloud/spreed/blob/38e56a3fe460f07e128c49be2759362592728a22/lib/Controller/AEnvironmentAwareOCSController.php#L60-L75 before it was cool :D