mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
add data/content type handling
This commit is contained in:
parent
61c9bacb80
commit
c4fc99ed39
|
|
@ -81,16 +81,16 @@ final class Rest
|
||||||
|
|
||||||
// handle different content types
|
// handle different content types
|
||||||
$contentType = $requestHeaders['content-type'] ?? [];
|
$contentType = $requestHeaders['content-type'] ?? [];
|
||||||
if ($request->getData() !== null && (empty($contentType) || \in_array(MimeType::M_POST, $contentType))) {
|
if (empty($contentType) || \in_array(MimeType::M_POST, $contentType)) {
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
\curl_setopt($curl, \CURLOPT_POSTFIELDS, \http_build_query($request->getData()));
|
\curl_setopt($curl, \CURLOPT_POSTFIELDS, \http_build_query($request->data));
|
||||||
} elseif ($request->getData() !== null && \in_array(MimeType::M_JSON, $contentType)) {
|
} elseif (\in_array(MimeType::M_JSON, $contentType)) {
|
||||||
\curl_setopt($curl, \CURLOPT_POSTFIELDS, \json_encode($request->getData()));
|
\curl_setopt($curl, \CURLOPT_POSTFIELDS, \json_encode($request->data));
|
||||||
} elseif ($request->getData() !== null && \in_array(MimeType::M_MULT, $contentType)) {
|
} elseif (\in_array(MimeType::M_MULT, $contentType)) {
|
||||||
$boundary = '----' . \uniqid();
|
$boundary = '----' . \uniqid();
|
||||||
|
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
$data = self::createMultipartData($boundary, $request->getData());
|
$data = self::createMultipartData($boundary, $request->data);
|
||||||
|
|
||||||
// @todo: Replace boundary/ with the correct boundary= in the future.
|
// @todo: Replace boundary/ with the correct boundary= in the future.
|
||||||
// Currently this cannot be done due to a bug. If we do it now the server cannot correclty populate php://input
|
// Currently this cannot be done due to a bug. If we do it now the server cannot correclty populate php://input
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user