From 07d92796d263d5add84793064e03108eec85db94 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Feb 2017 20:57:14 -0800 Subject: provide HTTP header parser which honours continuation lines and despite the fact that continuation lines have been deprecated - as they still exist in the wild. --- Zotlabs/Web/HTMLHeaders.php | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Zotlabs/Web/HTMLHeaders.php (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTMLHeaders.php b/Zotlabs/Web/HTMLHeaders.php new file mode 100644 index 000000000..f9bc3043b --- /dev/null +++ b/Zotlabs/Web/HTMLHeaders.php @@ -0,0 +1,46 @@ +in_progress['k']) { + $this->in_progress['v'] .= ' ' . ltrim($line); + continue; + } + } + else { + if($this->in_progress['k']) { + $this->parsed[] = [ $this->in_progress['k'] => $this->in_progress['v'] ]; + $this->in_progress = []; + } + + $this->in_progress['k'] = strtolower(substr($line,0,strpos($line,':'))); + $this->in_progress['v'] = ltrim(substr($line,strpos($line,':') + 1)); + } + + } + if($this->in_progress['k']) { + $this->parsed[] = [ $this->in_progress['k'] => $this->in_progress['v'] ]; + $this->in_progress = []; + } + } + } + + function fetch() { + return $this->parsed; + } +} + + + -- cgit v1.2.3