3 * @file src/Util/HTTPHeaders.php
5 namespace Friendica\Util;
9 private $in_progress = [];
12 function __construct($headers)
14 $lines = explode("\n", str_replace("\r", '', $headers));
17 foreach ($lines as $line) {
18 if (preg_match('/^\s+/', $line, $matches) && trim($line)) {
19 if ($this->in_progress['k']) {
20 $this->in_progress['v'] .= ' ' . ltrim($line);
24 if ($this->in_progress['k']) {
25 $this->parsed[] = [$this->in_progress['k'] => $this->in_progress['v']];
26 $this->in_progress = [];
29 $this->in_progress['k'] = strtolower(substr($line, 0, strpos($line, ':')));
30 $this->in_progress['v'] = ltrim(substr($line, strpos($line, ':') + 1));
34 if ($this->in_progress['k']) {
35 $this->parsed[] = [$this->in_progress['k'] => $this->in_progress['v']];
36 $this->in_progress = [];
51 foreach ($this->parsed as $x) {
52 foreach ($x as $y => $z) {