File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,11 @@ your application
128128php vendor/bin/server run 0.0.0.0:8000 --adapter=' My\Namespace\Adapter"
129129```
130130
131+ ### Custom response output
132+
133+ You can internally use the `x-server-message` header for custom server messages.
134+ The server will remove this server value before returning the response content.
135+
131136## Workers
132137
133138This server creates a single worker by default. A simple PHP thread that will
@@ -224,4 +229,4 @@ Some first steps for you!
224229or
225230
226231- [Try a demo](https://github.com/driftphp/demo)
227- - [Install the skeleton](https://github.com/driftphp/skeleton)
232+ - [Install the skeleton](https://github.com/driftphp/skeleton)
Original file line number Diff line number Diff line change @@ -212,6 +212,13 @@ private function toServerResponse(
212212 ->applyResponseEncoding ($ response , $ request ->getHeaderLine ('Accept-encoding ' ))
213213 ->then (function (ResponseInterface $ response ) use ($ request , $ from ) {
214214 $ to = microtime (true );
215+ $ responseMessage = '' ;
216+ if ($ response ->hasHeader ('x-server-message ' )) {
217+ $ responseMessage = $ response ->getHeader ('x-server-message ' );
218+ $ responseMessage = ($ responseMessage [0 ] ?? '' ) ? \strval ($ responseMessage [0 ]) : '' ;
219+ $ response = $ response ->withoutHeader ('x-server-message ' );
220+ }
221+
215222 $ serverResponse =
216223 new ServerResponseWithMessage (
217224 $ response ,
@@ -220,7 +227,7 @@ private function toServerResponse(
220227 $ request ->getUri ()->getPath (),
221228 $ request ->getMethod (),
222229 $ response ->getStatusCode (),
223- '' ,
230+ $ responseMessage ,
224231 TimeFormatter::formatTime ($ to - $ from )
225232 )
226233 );
You can’t perform that action at this time.
0 commit comments