File tree Expand file tree Collapse file tree 3 files changed +14
-18
lines changed
Expand file tree Collapse file tree 3 files changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,12 @@ class Response extends UtopiaResponse
1212 * Send output
1313 *
1414 * @param string $content
15- * @return void
15+ * @return bool False if write cannot complete, such as request ended by client
1616 */
17- protected function write (string $ content ): void
17+ public function write (string $ content ): bool
1818 {
1919 echo $ content ;
20+ return true ;
2021 }
2122
2223 /**
@@ -27,7 +28,7 @@ protected function write(string $content): void
2728 * @param string $content
2829 * @return void
2930 */
30- protected function end (string $ content = null ): void
31+ public function end (string $ content = null ): void
3132 {
3233 if (!is_null ($ content )) {
3334 echo $ content ;
@@ -55,7 +56,7 @@ protected function sendStatus(int $statusCode): void
5556 * @param string $value
5657 * @return void
5758 */
58- protected function sendHeader (string $ key , string $ value ): void
59+ public function sendHeader (string $ key , string $ value ): void
5960 {
6061 \header ($ key .': ' .$ value );
6162 }
Original file line number Diff line number Diff line change @@ -32,11 +32,11 @@ public function getSwooleResponse(): SwooleResponse
3232 * Write
3333 *
3434 * @param string $content
35- * @return void
35+ * @return bool False if write cannot complete, such as request ended by client
3636 */
37- protected function write (string $ content ): void
37+ public function write (string $ content ): bool
3838 {
39- $ this ->swoole ->write ($ content );
39+ return $ this ->swoole ->write ($ content );
4040 }
4141
4242 /**
@@ -45,7 +45,7 @@ protected function write(string $content): void
4545 * @param string|null $content
4646 * @return void
4747 */
48- protected function end (string $ content = null ): void
48+ public function end (string $ content = null ): void
4949 {
5050 $ this ->swoole ->end ($ content );
5151 }
@@ -68,7 +68,7 @@ protected function sendStatus(int $statusCode): void
6868 * @param string $value
6969 * @return void
7070 */
71- protected function sendHeader (string $ key , string $ value ): void
71+ public function sendHeader (string $ key , string $ value ): void
7272 {
7373 $ this ->swoole ->header ($ key , $ value );
7474 }
Original file line number Diff line number Diff line change @@ -511,9 +511,9 @@ public function send(string $body = ''): void
511511 * Send output
512512 *
513513 * @param string $content
514- * @return void
514+ * @return bool False if write cannot complete, such as request ended by client
515515 */
516- abstract protected function write (string $ content ): void ;
516+ abstract public function write (string $ content ): bool ;
517517
518518 /**
519519 * End
@@ -523,12 +523,7 @@ abstract protected function write(string $content): void;
523523 * @param string $content
524524 * @return void
525525 */
526- protected function end (string $ content = null ): void
527- {
528- if (!is_null ($ content )) {
529- echo $ content ;
530- }
531- }
526+ abstract public function end (string $ content = null ): void ;
532527
533528 /**
534529 * Output response
@@ -608,7 +603,7 @@ abstract protected function sendStatus(int $statusCode): void;
608603 * @param string $value
609604 * @return void
610605 */
611- abstract protected function sendHeader (string $ key , string $ value ): void ;
606+ abstract public function sendHeader (string $ key , string $ value ): void ;
612607
613608 /**
614609 * Send Cookie
You can’t perform that action at this time.
0 commit comments