mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
Merge pull request #10385 from appwrite/allow-head-requests
feat: allow HEAD requests in function executions
This commit is contained in:
commit
f30dc5df49
14 changed files with 58 additions and 26 deletions
|
|
@ -5881,7 +5881,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
"GET",
|
||||
|
|
@ -5889,7 +5889,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -12791,7 +12791,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
"GET",
|
||||
|
|
@ -12799,7 +12799,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -11576,7 +11576,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
"GET",
|
||||
|
|
@ -11584,7 +11584,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -5881,7 +5881,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
"GET",
|
||||
|
|
@ -5889,7 +5889,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -12791,7 +12791,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
"GET",
|
||||
|
|
@ -12799,7 +12799,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -11576,7 +11576,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
"GET",
|
||||
|
|
@ -11584,7 +11584,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -5978,7 +5978,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"default": "POST",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
|
|
@ -5987,7 +5987,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -12836,7 +12836,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"default": "POST",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
|
|
@ -12845,7 +12845,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -11646,7 +11646,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"default": "POST",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
|
|
@ -11655,7 +11655,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -5978,7 +5978,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"default": "POST",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
|
|
@ -5987,7 +5987,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -12836,7 +12836,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"default": "POST",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
|
|
@ -12845,7 +12845,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -11646,7 +11646,7 @@
|
|||
},
|
||||
"method": {
|
||||
"type": "string",
|
||||
"description": "HTTP method of execution. Default value is GET.",
|
||||
"description": "HTTP method of execution. Default value is POST.",
|
||||
"default": "POST",
|
||||
"x-example": "GET",
|
||||
"enum": [
|
||||
|
|
@ -11655,7 +11655,8 @@
|
|||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE",
|
||||
"OPTIONS"
|
||||
"OPTIONS",
|
||||
"HEAD"
|
||||
],
|
||||
"x-enum-name": "ExecutionMethod",
|
||||
"x-enum-keys": []
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class Create extends Base
|
|||
->param('body', '', new Text(10485760, 0), 'HTTP body of execution. Default value is empty string.', true)
|
||||
->param('async', false, new Boolean(true), 'Execute code in the background. Default value is false.', true)
|
||||
->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true)
|
||||
->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], true), 'HTTP method of execution. Default value is POST.', true)
|
||||
->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'], true), 'HTTP method of execution. Default value is POST.', true)
|
||||
->param('headers', [], new AnyOf([new Assoc(), new Text(65535)], AnyOf::TYPE_MIXED), 'HTTP headers of execution. Defaults to empty.', true)
|
||||
->param('scheduledAt', null, new Text(100), 'Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.', true)
|
||||
->inject('response')
|
||||
|
|
|
|||
|
|
@ -925,6 +925,26 @@ class FunctionsCustomServerTest extends Scope
|
|||
|
||||
$executionId = $execution['body']['$id'] ?? '';
|
||||
|
||||
/** Test create execution with HEAD method */
|
||||
$execution = $this->createExecution($data['functionId'], [
|
||||
'async' => 'false',
|
||||
'method' => 'HEAD',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $execution['headers']['status-code']);
|
||||
$this->assertEquals('completed', $execution['body']['status']);
|
||||
$this->assertEquals(200, $execution['body']['responseStatusCode']);
|
||||
$this->assertIsArray($execution['body']['responseHeaders']);
|
||||
$this->assertEmpty($execution['body']['responseBody']); // For HEAD requests, response body is empty
|
||||
|
||||
/** Delete execution */
|
||||
$execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $execution['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
$this->assertEquals(204, $execution['headers']['status-code']);
|
||||
|
||||
/** Test create execution with 400 status code */
|
||||
$execution = $this->createExecution($data['functionId'], [
|
||||
'async' => 'false',
|
||||
'path' => '/?code=400'
|
||||
|
|
@ -934,11 +954,11 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals('completed', $execution['body']['status']);
|
||||
$this->assertEquals(400, $execution['body']['responseStatusCode']);
|
||||
|
||||
/** Delete execution */
|
||||
$execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $execution['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(204, $execution['headers']['status-code']);
|
||||
|
||||
return array_merge($data, ['executionId' => $executionId]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue