Skip to content

Commit

Permalink
AppAPIProxy: send raw data and all headers to ExApp
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Jul 19, 2024
1 parent b75e303 commit e00cf8f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions lib/Controller/ExAppProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,23 @@ public function ExAppPost(string $appId, string $other): Response {
return new NotFoundResponse();
}

$stream = fopen('php://input', 'r');
$options = [
RequestOptions::COOKIES => $this->buildProxyCookiesJar($_COOKIE, $this->service->getExAppDomain($exApp)),
'body' => $stream,
'headers' => getallheaders(),
];
if (str_starts_with($this->request->getHeader('Content-Type'), 'multipart/form-data') || count($_FILES) > 0) {
$multipart = $this->buildMultipartFormData($this->prepareBodyParams($this->request->getParams()), $_FILES);
$options[RequestOptions::MULTIPART] = $multipart;
}
$bodyParams = $this->prepareBodyParams($this->request->getParams());

$response = $this->service->requestToExApp2(
$exApp, '/' . $other, $this->userId,
queryParams: $_GET, bodyParams: $bodyParams, options: $options,
queryParams: $_GET, options: $options,
request: $this->request,
);
fclose($stream);
if (is_array($response)) {
return (new Response())->setStatus(500);
}
Expand All @@ -129,20 +132,23 @@ public function ExAppPut(string $appId, string $other): Response {
return new NotFoundResponse();
}

$stream = fopen('php://input', 'r');
$options = [
RequestOptions::COOKIES => $this->buildProxyCookiesJar($_COOKIE, $this->service->getExAppDomain($exApp)),
'body' => $stream,
'headers' => getallheaders(),
];
if (str_starts_with($this->request->getHeader('Content-Type'), 'multipart/form-data') || count($_FILES) > 0) {
$multipart = $this->buildMultipartFormData($this->prepareBodyParams($this->request->getParams()), $_FILES);
$options[RequestOptions::MULTIPART] = $multipart;
}
$bodyParams = $this->prepareBodyParams($this->request->getParams());

$response = $this->service->requestToExApp2(
$exApp, '/' . $other, $this->userId, 'PUT', queryParams: $_GET, bodyParams: $bodyParams,
$exApp, '/' . $other, $this->userId, 'PUT', queryParams: $_GET,
options: $options,
request: $this->request,
);
fclose($stream);
if (is_array($response)) {
return (new Response())->setStatus(500);
}
Expand All @@ -157,14 +163,17 @@ public function ExAppDelete(string $appId, string $other): Response {
return new NotFoundResponse();
}

$bodyParams = $this->prepareBodyParams($this->request->getParams());
$stream = fopen('php://input', 'r');
$options = [
RequestOptions::COOKIES => $this->buildProxyCookiesJar($_COOKIE, $this->service->getExAppDomain($exApp)),
'body' => $stream,
'headers' => getallheaders(),
];
$response = $this->service->requestToExApp2(
$exApp, '/' . $other, $this->userId, 'DELETE', queryParams: $_GET, bodyParams: $bodyParams,
options: [
RequestOptions::COOKIES => $this->buildProxyCookiesJar($_COOKIE, $this->service->getExAppDomain($exApp)),
],
request: $this->request,
$exApp, '/' . $other, $this->userId, 'DELETE', queryParams: $_GET,
options: $options, request: $this->request,
);
fclose($stream);
if (is_array($response)) {
return (new Response())->setStatus(500);
}
Expand Down

0 comments on commit e00cf8f

Please sign in to comment.