@@ -270,36 +270,38 @@ public function prepare(Request $request)
270
270
271
271
if ($ this ->isInformational () || in_array ($ this ->statusCode , array (204 , 304 ))) {
272
272
$ this ->setContent (null );
273
- }
274
-
275
- // Content-type based on the Request
276
- if (!$ headers ->has ('Content-Type ' )) {
277
- $ format = $ request ->getRequestFormat ();
278
- if (null !== $ format && $ mimeType = $ request ->getMimeType ($ format )) {
279
- $ headers ->set ('Content-Type ' , $ mimeType );
273
+ $ headers ->remove ('Content-Type ' );
274
+ $ headers ->remove ('Content-Length ' );
275
+ } else {
276
+ // Content-type based on the Request
277
+ if (!$ headers ->has ('Content-Type ' )) {
278
+ $ format = $ request ->getRequestFormat ();
279
+ if (null !== $ format && $ mimeType = $ request ->getMimeType ($ format )) {
280
+ $ headers ->set ('Content-Type ' , $ mimeType );
281
+ }
280
282
}
281
- }
282
283
283
- // Fix Content-Type
284
- $ charset = $ this ->charset ?: 'UTF-8 ' ;
285
- if (!$ headers ->has ('Content-Type ' )) {
286
- $ headers ->set ('Content-Type ' , 'text/html; charset= ' . $ charset );
287
- } elseif (0 === stripos ($ headers ->get ('Content-Type ' ), 'text/ ' ) && false === stripos ($ headers ->get ('Content-Type ' ), 'charset ' )) {
288
- // add the charset
289
- $ headers ->set ('Content-Type ' , $ headers ->get ('Content-Type ' ). '; charset= ' . $ charset );
290
- }
284
+ // Fix Content-Type
285
+ $ charset = $ this ->charset ?: 'UTF-8 ' ;
286
+ if (!$ headers ->has ('Content-Type ' )) {
287
+ $ headers ->set ('Content-Type ' , 'text/html; charset= ' . $ charset );
288
+ } elseif (0 === stripos ($ headers ->get ('Content-Type ' ), 'text/ ' ) && false === stripos ($ headers ->get ('Content-Type ' ), 'charset ' )) {
289
+ // add the charset
290
+ $ headers ->set ('Content-Type ' , $ headers ->get ('Content-Type ' ) . '; charset= ' . $ charset );
291
+ }
291
292
292
- // Fix Content-Length
293
- if ($ headers ->has ('Transfer-Encoding ' )) {
294
- $ headers ->remove ('Content-Length ' );
295
- }
293
+ // Fix Content-Length
294
+ if ($ headers ->has ('Transfer-Encoding ' )) {
295
+ $ headers ->remove ('Content-Length ' );
296
+ }
296
297
297
- if ($ request ->isMethod ('HEAD ' )) {
298
- // cf. RFC2616 14.13
299
- $ length = $ headers ->get ('Content-Length ' );
300
- $ this ->setContent (null );
301
- if ($ length ) {
302
- $ headers ->set ('Content-Length ' , $ length );
298
+ if ($ request ->isMethod ('HEAD ' )) {
299
+ // cf. RFC2616 14.13
300
+ $ length = $ headers ->get ('Content-Length ' );
301
+ $ this ->setContent (null );
302
+ if ($ length ) {
303
+ $ headers ->set ('Content-Length ' , $ length );
304
+ }
303
305
}
304
306
}
305
307
0 commit comments