// Don't do anything if the request has no body.
if ($request->
getBody()->
getSize() === 0
) { return $fn($request,
$options);
} $modify =
[];
// Add a default content-type if possible.
if (!
$request->
hasHeader('Content-Type'
)) { if ($uri =
$request->
getBody()->
getMetadata('uri'
)) { if (is_string($uri) &&
$type = Psr7\MimeType::
fromFilename($uri)) { $modify['set_headers'
]['Content-Type'
] =
$type;
} } } // Add a default content-length or transfer-encoding header.
if (!
$request->
hasHeader('Content-Length'
) && !
$request->
hasHeader('Transfer-Encoding'
) ) { $size =
$request->
getBody()->
getSize();
if ($size !== null
) {