File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,7 @@ class CakeResponse {
379
379
*
380
380
* @param array $options list of parameters to setup the response. Possible values are:
381
381
* - body: the response text that should be sent to the client
382
+ * - codes: additional allowable response codes
382
383
* - status: the HTTP status code to respond with
383
384
* - type: a complete mime-type string or an extension mapped in this class
384
385
* - charset: the charset for the response body
@@ -387,6 +388,9 @@ public function __construct(array $options = array()) {
387
388
if (isset ($ options ['body ' ])) {
388
389
$ this ->body ($ options ['body ' ]);
389
390
}
391
+ if (isset ($ options ['statusCodes ' ])) {
392
+ $ this ->httpCodes ($ options ['statusCodes ' ]);
393
+ }
390
394
if (isset ($ options ['status ' ])) {
391
395
$ this ->statusCode ($ options ['status ' ]);
392
396
}
Original file line number Diff line number Diff line change @@ -66,6 +66,21 @@ public function testConstruct() {
66
66
$ this ->assertEquals ('my-custom-charset ' , $ response ->charset ());
67
67
$ this ->assertEquals ('audio/mpeg ' , $ response ->type ());
68
68
$ this ->assertEquals (203 , $ response ->statusCode ());
69
+
70
+ $ options = array (
71
+ 'body ' => 'This is the body ' ,
72
+ 'charset ' => 'my-custom-charset ' ,
73
+ 'type ' => 'mp3 ' ,
74
+ 'status ' => '422 ' ,
75
+ 'statusCodes ' => array (
76
+ 422 => 'Unprocessable Entity '
77
+ )
78
+ );
79
+ $ response = new CakeResponse ($ options );
80
+ $ this ->assertEquals ($ options ['body ' ], $ response ->body ());
81
+ $ this ->assertEquals ($ options ['charset ' ], $ response ->charset ());
82
+ $ this ->assertEquals ($ response ->getMimeType ($ options ['type ' ]), $ response ->type ());
83
+ $ this ->assertEquals ($ options ['status ' ], $ response ->statusCode ());
69
84
}
70
85
71
86
/**
You can’t perform that action at this time.
0 commit comments