diff --git a/app/config/specs/open-api3-1.8.x-client.json b/app/config/specs/open-api3-1.8.x-client.json index 1ccf7d82ab..553b7ce385 100644 --- a/app/config/specs/open-api3-1.8.x-client.json +++ b/app/config/specs/open-api3-1.8.x-client.json @@ -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": [] diff --git a/app/config/specs/open-api3-1.8.x-console.json b/app/config/specs/open-api3-1.8.x-console.json index cd2bb95ee6..7d33440d01 100644 --- a/app/config/specs/open-api3-1.8.x-console.json +++ b/app/config/specs/open-api3-1.8.x-console.json @@ -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": [] diff --git a/app/config/specs/open-api3-1.8.x-server.json b/app/config/specs/open-api3-1.8.x-server.json index 7e5847f94c..d117377a21 100644 --- a/app/config/specs/open-api3-1.8.x-server.json +++ b/app/config/specs/open-api3-1.8.x-server.json @@ -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": [] diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index 1ccf7d82ab..553b7ce385 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -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": [] diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index cd2bb95ee6..7d33440d01 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -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": [] diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 7e5847f94c..d117377a21 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -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": [] diff --git a/app/config/specs/swagger2-1.8.x-client.json b/app/config/specs/swagger2-1.8.x-client.json index b08d8b0036..9b9a695896 100644 --- a/app/config/specs/swagger2-1.8.x-client.json +++ b/app/config/specs/swagger2-1.8.x-client.json @@ -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": [] diff --git a/app/config/specs/swagger2-1.8.x-console.json b/app/config/specs/swagger2-1.8.x-console.json index b4dfbb8ca6..d8fc57519f 100644 --- a/app/config/specs/swagger2-1.8.x-console.json +++ b/app/config/specs/swagger2-1.8.x-console.json @@ -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": [] diff --git a/app/config/specs/swagger2-1.8.x-server.json b/app/config/specs/swagger2-1.8.x-server.json index 2c358475f8..f9c84e4f2d 100644 --- a/app/config/specs/swagger2-1.8.x-server.json +++ b/app/config/specs/swagger2-1.8.x-server.json @@ -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": [] diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index b08d8b0036..9b9a695896 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -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": [] diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index b4dfbb8ca6..d8fc57519f 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -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": [] diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 2c358475f8..f9c84e4f2d 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -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": [] diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php index cb4b50984c..1603e8f997 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php @@ -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') diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 916e41d8a4..220ffb3cdb 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -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]);