@@ -81,7 +81,7 @@ public function appendBody($data): self
8181 */
8282 public function populateHeaders (): void
8383 {
84- $ contentType = service ('superglobals ' )->server ('CONTENT_TYPE ' );
84+ $ contentType = service ('superglobals ' )->server ('CONTENT_TYPE ' , ( string ) getenv ( ' CONTENT_TYPE ' ) );
8585 if (! empty ($ contentType )) {
8686 $ this ->setHeader ('Content-Type ' , $ contentType );
8787 }
@@ -266,25 +266,18 @@ protected function getHeaderName(string $name): string
266266 */
267267 public function setProtocolVersion (string $ version ): self
268268 {
269- // If empty, keep default protocol version (usually 1.1) and do nothing.
270- if ($ version === '' ) {
271- return $ this ;
272- }
273-
274- // If a full protocol string (e.g., "HTTP/1.1") is provided, extract the numeric part.
275- if (str_contains ($ version , '/ ' )) {
269+ if (! is_numeric ($ version )) {
276270 $ version = substr ($ version , strpos ($ version , '/ ' ) + 1 );
277271 }
278272
279- // Normalize to a single decimal place as used in validProtocolVersions.
280- $ normalized = number_format ((float ) $ version , 1 );
273+ // Make sure that version is in the correct format
274+ $ version = number_format ((float ) $ version , 1 );
281275
282- // Throw exception if the version is not recognized.
283- if (! in_array ($ normalized , $ this ->validProtocolVersions , true )) {
276+ if (! in_array ($ version , $ this ->validProtocolVersions , true )) {
284277 throw HTTPException::forInvalidHTTPProtocol ($ version );
285278 }
286279
287- $ this ->protocolVersion = $ normalized ;
280+ $ this ->protocolVersion = $ version ;
288281
289282 return $ this ;
290283 }
0 commit comments