【发布时间】:2016-12-16 23:51:43
【问题描述】:
我正在使用 Guzzle 6,但在从 REST 端点取回图像数据时遇到问题。
$client = new Client(['base_uri' => $base_uri]);
$type = 'POST'; //..or 'GET'...doesn't make a difference
$url = //..the endpoint where the image is served from
$headers['Content-Type'] = 'text/xml; charset=x-user-defined';
$response = $client->request($type, $url, ['headers'=>$headers, 'decode_content' => false] );
我强制使用 mime 类型的请求被忽略,返回的内容类型始终为 "image/jpeg",并且数据已被处理,因此我不能简单地将其粘贴到 html "<img src=... />" 标记中。
【问题讨论】: