@@ -30,10 +30,10 @@ trait SapiEmitterTrait {
3030
3131 private function assertNoPreviousOutput (): void {
3232 if (headers_sent ()) {
33- throw EmitterException :: forHeadersSent();
33+ // throw EmitterException::forHeadersSent();
3434 }
3535 if (ob_get_level () > 0 && ob_get_length () > 0 ) {
36- throw EmitterException :: forOutputSent();
36+ // throw EmitterException::forOutputSent();
3737 }
3838 }
3939
@@ -55,11 +55,39 @@ trait SapiEmitterTrait {
5555 );
5656 }
5757
58+ protected async function putStatusLineAsync (
59+ string $version ,
60+ int $statusCode ,
61+ string $reasonPhrase ,
62+ bool $_replace ,
63+ ): Awaitable <void > {
64+ header (
65+ Str \format (
66+ ' HTTP/%s %d%s' ,
67+ $version ,
68+ $statusCode ,
69+ (! Str \is_empty ($reasonPhrase ) ? ' ' . $reasonPhrase : ' ' )
70+ ),
71+ true ,
72+ $statusCode
73+ );
74+ }
75+
5876 private function emitStatusLine (ResponseInterface $response ): void {
59- $statusCode = $response -> getStatusCode();
6077 $this -> putStatusLine(
6178 $response -> getProtocolVersion(),
62- $statusCode ,
79+ $response -> getStatusCode(),
80+ $response -> getReasonPhrase(),
81+ true ,
82+ );
83+ }
84+
85+ private async function emitStatusLineAsync (
86+ ResponseInterface $response
87+ ): Awaitable <void > {
88+ await $this -> putStatusLineAsync(
89+ $response -> getProtocolVersion(),
90+ $response -> getStatusCode(),
6391 $response -> getReasonPhrase(),
6492 true ,
6593 );
@@ -86,6 +114,20 @@ trait SapiEmitterTrait {
86114 }
87115 }
88116
117+ private async function emitHeadersAsync (
118+ ResponseInterface $response
119+ ): Awaitable <void > {
120+ $statusCode = $response -> getStatusCode();
121+ foreach ($response -> getHeaders() as $header => $values ) {
122+ $name = $this -> filterHeader($header );
123+ $first = $name === ' Set-Cookie' ? false : true ;
124+ foreach ($values as $value ) {
125+ $this -> putHeaders($name , $value , $first , $statusCode );
126+ $first = false ;
127+ }
128+ }
129+ }
130+
89131 private function filterHeader (string $header ): string {
90132 return Str \replace ($header ,' -' , ' ' )
91133 |> Str \capitalize_words ($$)
0 commit comments