Skip to content

Commit 362665a

Browse files
committed
Add Response::accepted() to set status code 202
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/202
1 parent cacb872 commit 362665a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Rest API change log
33

44
## ?.?.? / ????-??-??
55

6+
## 5.1.0 / 2025-07-20
7+
8+
* Added `Response::accepted()` which sets the HTTP status code to 202, see
9+
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/202
10+
(@thekid)
11+
612
## 5.0.0 / 2025-05-04
713

814
* **Heads up:** Dropped support for PHP < 7.4, see xp-framework/rfc#343

src/main/php/web/rest/Response.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ public static function created($location= null, ... $arguments) {
5959
return $self;
6060
}
6161

62+
/**
63+
* Creates a new response instance with the status code set to 202 (Accepted)
64+
*
65+
* @return self
66+
*/
67+
public static function accepted() {
68+
return new self(202);
69+
}
70+
6271
/**
6372
* Creates a new response instance with the status code set to 204 (No content)
6473
*

src/test/php/web/rest/unittest/ResponseTest.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public function created_with_location_and_arguments() {
3939
);
4040
}
4141

42+
#[Test]
43+
public function accepted() {
44+
Assert::equals(
45+
['status' => 201, 'headers' => [], 'body' => null],
46+
Response::accepted()->export()
47+
);
48+
}
49+
4250
#[Test]
4351
public function no_content() {
4452
Assert::equals(

0 commit comments

Comments
 (0)