From 92ea125d4fdf3a8d67e998282771f7c6a96b342e Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Mon, 6 Jan 2025 09:59:38 -0600 Subject: [PATCH] small client updates while I procrastinate on tests --- .../core/client/class_response_headers.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/template/core/client/class_response_headers.php b/template/core/client/class_response_headers.php index 7c22557a..fe2e5050 100644 --- a/template/core/client/class_response_headers.php +++ b/template/core/client/class_response_headers.php @@ -70,6 +70,8 @@ public function addLine(string $line): int } /** + * Return all parsed values for a given response header, if it exists. + * * @param string $name * @return null|array */ @@ -80,6 +82,22 @@ public function get(string $name): null|array } /** + * Return the first value for a given response header, if it exists. + * + * @return null|string + */ + public function getFirst(string $name): null|string + { + $v = $this->get($name); + if (null === $v || [] === $v) { + return null; + } + return $v[0]; + } + + /** + * Returns an iterator containing the raw header lines extracted from the repsonse. + * * @return iterable */ public function getLinesIterator(): iterable @@ -88,6 +106,8 @@ public function getLinesIterator(): iterable } /** + * Returns an iterator containing the parsed header lines from the response. + * * @return iterable */ public function getParsedIterator(): iterable