原標題我有URL(http://forexample.com/index),其中我送原標題:掌握狂飲HTTP客戶端
header("HTTP/1.1 401 Some message");
隨着狂飲我想這個RAW頭信息。請求完成後,不幸的是我無法找到這條消息標題之間:
$client = new GuzzleHttp\Client();
try {
$res = $client->post('http://forexample.com/index');
} catch (GuzzleHttp\Exception\BadResponseException $e) {
// On HTTP response other than 200 Guzzle throws an exception
$res = $e->getResponse();
}
var_dump($res->getHeaders());
比方說,如果我把這個網址與本地PHP函數get_headers
:
var_dump(get_headers('http://forexample.com/index'));
我得到的所有頭。那麼有什麼想法?
它不是你之後的HTTP狀態代碼嗎? –
不,我想要得到狀態消息 - 「一些消息」。 – Bounce
然後你在'$ res-> getReasonPhrase()'之後。但是,如果您有狀態代碼,則原因短語絕對不必要。你不應該僅僅依賴於這個短語,而是你的代碼是你的代碼,並且你做了你認爲合適的事情。祝你好運。 –