From df25c44a2dd3ca118bbe3001a0f5f51c66830d34 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 7 Jan 2019 22:08:32 +0100 Subject: [PATCH] HttpClient getHeader can return empty string Fixes #11999 Signed-off-by: Roeland Jago Douma --- lib/private/Http/Client/Response.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/private/Http/Client/Response.php b/lib/private/Http/Client/Response.php index 73c14c2926..6786ecd6fc 100644 --- a/lib/private/Http/Client/Response.php +++ b/lib/private/Http/Client/Response.php @@ -71,7 +71,13 @@ class Response implements IResponse { * @return string */ public function getHeader(string $key): string { - return $this->response->getHeader($key)[0]; + $headers = $this->response->getHeader($key); + + if (count($headers) === 0) { + return ''; + } + + return $headers[0]; } /**