More QA fixes
This commit is contained in:
parent
345df3f2ca
commit
d5fd3a28f9
6 changed files with 25 additions and 24 deletions
|
@ -1492,7 +1492,7 @@ App::post('/v1/functions/:functionId/executions')
|
||||||
$headersFiltered = [];
|
$headersFiltered = [];
|
||||||
foreach ($executionResponse['headers'] as $key => $value) {
|
foreach ($executionResponse['headers'] as $key => $value) {
|
||||||
if (\in_array($key, FUNCTION_WHITELIST_HEADERS_REQUEST)) {
|
if (\in_array($key, FUNCTION_WHITELIST_HEADERS_REQUEST)) {
|
||||||
$headersFiltered[] = [ 'key' => $key, 'value' => $value ];
|
$headersFiltered[] = [ 'name' => $key, 'value' => $value ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,8 +1536,13 @@ App::post('/v1/functions/:functionId/executions')
|
||||||
$execution->setAttribute('errors', '');
|
$execution->setAttribute('errors', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$headers = [];
|
||||||
|
foreach ($executionResponse['headers'] as $key => $value) {
|
||||||
|
$headers[] = [ 'name' => $key, 'value' => $value ];
|
||||||
|
}
|
||||||
|
|
||||||
$execution->setAttribute('responseBody', $executionResponse['body']);
|
$execution->setAttribute('responseBody', $executionResponse['body']);
|
||||||
$execution->setAttribute('responseHeaders', $executionResponse['headers']);
|
$execution->setAttribute('responseHeaders', $headers);
|
||||||
|
|
||||||
$response
|
$response
|
||||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||||
|
|
|
@ -78,7 +78,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip Appwrite Router for ACME challenge. Nessessary for certificate generation
|
// Skip Appwrite Router for ACME challenge. Nessessary for certificate generation
|
||||||
$path = ($swooleRequest->server['request_uri'] ?? '');
|
$path = ($swooleRequest->server['request_uri'] ?? '/');
|
||||||
if (\str_starts_with($path, '/.well-known/acme-challenge')) {
|
if (\str_starts_with($path, '/.well-known/acme-challenge')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques
|
||||||
$functionId = $route->getAttribute('resourceId');
|
$functionId = $route->getAttribute('resourceId');
|
||||||
$projectId = $route->getAttribute('projectId');
|
$projectId = $route->getAttribute('projectId');
|
||||||
|
|
||||||
$path = ($swooleRequest->server['request_uri'] ?? '');
|
$path = ($swooleRequest->server['request_uri'] ?? '/');
|
||||||
$query = ($swooleRequest->server['query_string'] ?? '');
|
$query = ($swooleRequest->server['query_string'] ?? '');
|
||||||
if (!empty($query)) {
|
if (!empty($query)) {
|
||||||
$path .= '?' . $query;
|
$path .= '?' . $query;
|
||||||
|
@ -137,14 +137,17 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques
|
||||||
$execution = \json_decode($executionResponse, true);
|
$execution = \json_decode($executionResponse, true);
|
||||||
|
|
||||||
foreach ($execution['responseHeaders'] as $header) {
|
foreach ($execution['responseHeaders'] as $header) {
|
||||||
$response->setHeader($header['key'], $header['value']);
|
$response->setHeader($header['name'], $header['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = $execution['responseBody'] ?? '';
|
$body = $execution['responseBody'] ?? '';
|
||||||
|
|
||||||
if (($execution['responseHeaders']['x-open-runtimes-encoding'] ?? '') === 'base64') {
|
$encodingKey = \array_search('x-open-runtimes-encoding', \array_column($execution['responseHeaders'], 'name'));
|
||||||
|
if (!empty($encodingKey)) {
|
||||||
|
if (($execution['responseHeaders'][$encodingKey] ?? '') === 'base64') {
|
||||||
$body = \base64_decode($body);
|
$body = \base64_decode($body);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$response->setStatusCode($execution['responseStatusCode'] ?? 200)->send($body);
|
$response->setStatusCode($execution['responseStatusCode'] ?? 200)->send($body);
|
||||||
return true;
|
return true;
|
||||||
|
@ -327,8 +330,7 @@ App::init()
|
||||||
->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-Appwrite-JWT, X-Appwrite-Response-Format, X-SDK-Version, X-SDK-Name, X-SDK-Language, X-SDK-Platform, X-SDK-GraphQL, X-Appwrite-ID, X-Appwrite-Timestamp, Content-Range, Range, Cache-Control, Expires, Pragma')
|
->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-Appwrite-JWT, X-Appwrite-Response-Format, X-SDK-Version, X-SDK-Name, X-SDK-Language, X-SDK-Platform, X-SDK-GraphQL, X-Appwrite-ID, X-Appwrite-Timestamp, Content-Range, Range, Cache-Control, Expires, Pragma')
|
||||||
->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies')
|
->addHeader('Access-Control-Expose-Headers', 'X-Fallback-Cookies')
|
||||||
->addHeader('Access-Control-Allow-Origin', $refDomain)
|
->addHeader('Access-Control-Allow-Origin', $refDomain)
|
||||||
->addHeader('Access-Control-Allow-Credentials', 'true')
|
->addHeader('Access-Control-Allow-Credentials', 'true');
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate Client Domain - Check to avoid CSRF attack
|
* Validate Client Domain - Check to avoid CSRF attack
|
||||||
|
@ -643,8 +645,7 @@ App::error()
|
||||||
->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||||
->addHeader('Expires', '0')
|
->addHeader('Expires', '0')
|
||||||
->addHeader('Pragma', 'no-cache')
|
->addHeader('Pragma', 'no-cache')
|
||||||
->setStatusCode($code)
|
->setStatusCode($code);
|
||||||
;
|
|
||||||
|
|
||||||
$template = ($route) ? $route->getLabel('error', null) : null;
|
$template = ($route) ? $route->getLabel('error', null) : null;
|
||||||
|
|
||||||
|
@ -658,8 +659,7 @@ App::error()
|
||||||
->setParam('projectURL', $project->getAttribute('url'))
|
->setParam('projectURL', $project->getAttribute('url'))
|
||||||
->setParam('message', $error->getMessage())
|
->setParam('message', $error->getMessage())
|
||||||
->setParam('code', $code)
|
->setParam('code', $code)
|
||||||
->setParam('trace', $trace)
|
->setParam('trace', $trace);
|
||||||
;
|
|
||||||
|
|
||||||
$response->html($layout->render());
|
$response->html($layout->render());
|
||||||
}
|
}
|
||||||
|
@ -744,6 +744,7 @@ include_once __DIR__ . '/shared/api.php';
|
||||||
include_once __DIR__ . '/shared/api/auth.php';
|
include_once __DIR__ . '/shared/api/auth.php';
|
||||||
|
|
||||||
App::wildcard()
|
App::wildcard()
|
||||||
|
->groups(['api'])
|
||||||
->action(function () {
|
->action(function () {
|
||||||
throw new AppwriteException(AppwriteException::GENERAL_ROUTE_NOT_FOUND);
|
throw new AppwriteException(AppwriteException::GENERAL_ROUTE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
|
@ -582,8 +582,6 @@ App::shutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($project->getId() !== 'console') {
|
if ($project->getId() !== 'console') {
|
||||||
if ($mode !== APP_MODE_ADMIN) {
|
if ($mode !== APP_MODE_ADMIN) {
|
||||||
$fileSize = 0;
|
$fileSize = 0;
|
||||||
|
|
|
@ -233,7 +233,6 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
|
||||||
$request = new Request($swooleRequest);
|
$request = new Request($swooleRequest);
|
||||||
$response = new Response($swooleResponse);
|
$response = new Response($swooleResponse);
|
||||||
|
|
||||||
|
|
||||||
// Serve static files (console) only for main domain
|
// Serve static files (console) only for main domain
|
||||||
$host = $request->getHostname() ?? '';
|
$host = $request->getHostname() ?? '';
|
||||||
$mainDomain = App::getEnv('_APP_DOMAIN', '');
|
$mainDomain = App::getEnv('_APP_DOMAIN', '');
|
||||||
|
@ -251,8 +250,6 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$app = new App('UTC');
|
$app = new App('UTC');
|
||||||
|
|
||||||
$pools = $register->get('pools');
|
$pools = $register->get('pools');
|
||||||
|
|
|
@ -204,7 +204,7 @@ Server::setResource('execute', function () {
|
||||||
$headersFiltered = [];
|
$headersFiltered = [];
|
||||||
foreach ($executionResponse['headers'] as $key => $value) {
|
foreach ($executionResponse['headers'] as $key => $value) {
|
||||||
if (\in_array($key, FUNCTION_WHITELIST_HEADERS_REQUEST)) {
|
if (\in_array($key, FUNCTION_WHITELIST_HEADERS_REQUEST)) {
|
||||||
$headersFiltered[] = [ 'key' => $key, 'value' => $value ];
|
$headersFiltered[] = [ 'name' => $key, 'value' => $value ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ class Execution extends Model
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'Developers are awesome.',
|
'example' => 'Developers are awesome.',
|
||||||
])
|
])
|
||||||
->addRule('responseheaders', [
|
->addRule('responseHeaders', [
|
||||||
'type' => Response::MODEL_HEADERS,
|
'type' => Response::MODEL_HEADERS,
|
||||||
'description' => 'HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous.',
|
'description' => 'HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous.',
|
||||||
'default' => [],
|
'default' => [],
|
||||||
|
|
Loading…
Reference in a new issue