1212use DevNet \Common \Configuration \IConfiguration ;
1313use DevNet \Common \Dependency \IServiceProvider ;
1414use DevNet \Common \Dependency \ServiceCollection ;
15+ use DevNet \System \Async \Task ;
1516use DevNet \System \Runtime \LauncherProperties ;
1617use DevNet \Web \Diagnostics \ExceptionHandlerMiddleware ;
1718use DevNet \Web \Http \HttpContext ;
@@ -73,15 +74,17 @@ public function run(): void
7374 return ;
7475 }
7576
76- $ application ($ context )->wait ();
77- $ response = $ context ->Response ;
77+ $ result = $ application ($ context );
78+ if ($ result instanceof Task) {
79+ $ result ->wait ();
80+ }
7881
7982 // Send the "status line".
80- $ statusLine = $ response ->getStatusLine ();
83+ $ statusLine = $ context -> Response ->getStatusLine ();
8184 header ($ statusLine , true );
8285
8386 // Send the response headers from the headers list.
84- foreach ($ response ->Headers ->getAll () as $ name => $ values ) {
87+ foreach ($ context -> Response ->Headers ->getAll () as $ name => $ values ) {
8588 foreach ($ values as $ value ) {
8689 // keep a previous similar header.
8790 header ("$ name: $ value " , false );
@@ -90,8 +93,8 @@ public function run(): void
9093
9194 // Output the message body.
9295 if ($ context ->Response ->Body ->Length > 0 ) {
93- $ response ->Body ->seek (0 );
94- echo $ response -> Body ->read ($ response ->Body ->Length );
96+ $ context -> Response ->Body ->seek (0 );
97+ echo $ context -> Response -> Body ->read ($ context -> Response ->Body ->Length );
9598 }
9699 }
97100
0 commit comments