processHeader() reads header lines from socket until the line equals $lastLine
@return array of headers with header names as keys and header content as values
548671
function processHeader($lastLine = "\r\n") {
      $headers = array();
      $finished = false;

      while ( (!$finished) && (!feof($this->socket)) ) {
        $str = fgets($this->socket, 1024);
        $finished = ($str == $lastLine);
        if (!$finished) {
          list($hdr, $value) = preg_split('/: /', $str, 2);
// nasty workaround broken multiple same headers (eg. Set-Cookie headers) @FIXME
          if (isset($headers[$hdr])) {
            $headers[$hdr] .= '; ' . trim($value);
          } else {
            $headers[$hdr] = trim($value);
          }
        }
      }

      return $headers;
    }
1111588
protected function readChunkHeader()
	{
		static $m = NULL;
		
		if(preg_match("'([a-fA-F0-9]+).*\r\n'", $this->buffer, $m))
		{
			$this->remainder = hexdec($m[1]);
			$this->buffer = (string)substr($this->buffer, strlen($m[0]));
		}
		else
		{
			$this->remainder = 0;
		}
	}
1042214
public function getHeaders()
    {
        $headers = [];
        $pattern = '#(.*?): (.*?);#i';
        if (preg_match_all($pattern, $this->header, $match)) {
            foreach ($match[1] as $co => $vo) {
                if (!isset($headers[$vo])) {
                    $headers[$vo] = [];
                }
                $headers[$vo][] = $match[2][$co];
            }
        }
        return $headers;
    }
1088364
public function toArray(): array
    {
        $hs = [];
        foreach ($this->headers as $k => $header) {
            $hs[$k] = $header->getValues();
        }
        return $hs;
    }
774461
public function read()
    {
        // First, read headers only
        $response = '';
        $gotStatus = false;
        while ($line = @fgets($this->socket)) {
            $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
            if ($gotStatus) {
                $response .= $line;
                if (!chop($line)) { break;
                }
            }
        }

        $statusCode = Zend_Http_Response::extractCode($response);
         
        // Handle 100 and 101 responses internally by restarting the read again
        if ($statusCode == 100 || $statusCode == 101) { return $this->read();
        }

        /**
         * Responses to HEAD requests and 204 or 304 responses are not expected
         * to have a body - stop reading here
         */
        if ($statusCode == 304 || $statusCode == 204  
            || $this->method == Zend_Http_Client::HEAD
        ) { return $response;
        }

        // Check headers to see what kind of connection / transfer encoding we have
        $headers = Zend_Http_Response::extractHeaders($response);

        // if the connection is set to close, just read until socket closes
        if (isset($headers['connection']) && $headers['connection'] == 'close') {
            while ($buff = @fread($this->socket, 8192)) {
                $response .= $buff;
            }

            $this->close();

            // Else, if we got a transfer-encoding header (chunked body)
        } elseif (isset($headers['transfer-encoding'])) {
            if ($headers['transfer-encoding'] == 'chunked') {
                do {
                    $chunk = '';
                    $line = @fgets($this->socket);
                    $chunk .= $line;

                    $hexchunksize = ltrim(chop($line), '0');
                    $hexchunksize = strlen($hexchunksize) ? strtolower($hexchunksize) : 0;

                    $chunksize = hexdec(chop($line));
                    if (dechex($chunksize) != $hexchunksize) {
                        @fclose($this->socket);
                        include_once 'Zend/Http/Client/Adapter/Exception.php';
                        throw new Zend_Http_Client_Adapter_Exception(
                            'Invalid chunk size "' .
                            $hexchunksize . '" unable to read chunked body'
                        );
                    }

                    $left_to_read = $chunksize;
                    while ($left_to_read > 0) {
                        $line = @fread($this->socket, $left_to_read);
                        $chunk .= $line;
                        $left_to_read -= strlen($line);
                    }

                    $chunk .= @fgets($this->socket);
                    $response .= $chunk;
                } while ($chunksize > 0);
            } else {
                throw new Zend_Http_Client_Adapter_Exception(
                    'Cannot handle "' .
                    $headers['transfer-encoding'] . '" transfer encoding'
                );
            }

            // Else, if we got the content-length header, read this number of bytes
        } elseif (isset($headers['content-length'])) {
            $left_to_read = $headers['content-length'];
            $chunk = '';
            while ($left_to_read > 0) {
                $chunk = @fread($this->socket, $left_to_read);
                $left_to_read -= strlen($chunk);
                $response .= $chunk;
            }
        
            // Fallback: just read the response (should not happen)
        } else {
            while ($buff = @fread($this->socket, 8192)) {
                $response .= $buff;
            }

            $this->close();
        }

        return $response;
    }
1088644
protected function normalizeCustomHeaders()
    {
        $headers = [];

        // The spec requires that headers are sorted by header name.
        sort($this->headers);
        foreach ($this->headers as $header) {
            if ($this->request->hasHeader($header)) {
                $headers[] = strtolower($header) . ':' . $this->request->getHeaderLine($header);
            }
        }

        return $headers;
    }
561629
public function headers()
	{
		if (!$this->headers)
		{
			$this->rewind();

			$row = fgetcsv($this->file, self::ROW_LENGTH, $this->delimiter);

			$this->position++;

			// store headers for later
			if ($this->position == 1)
			{
				$this->headers = $row;
			}

			$this->rewind();
		}

		return $this->headers;
	}
763477
public function getHeaderLines()
    {
        $headers = [];
        foreach ($this->headers->getIterator() as $name => $value) {
            $headers[] = $name . ': ' . $value;
        }

        return $headers;
    }
978965
public function get_headers()
	{
		$headers = array();
		foreach ($this->headers as $key => $value)
		{
			$headers[] = is_int($key) ? $value : $key.': '.$value;
		}

		return $headers;
	}
107931
public function getHeaders()
    {
        $h = array();
        if (!empty($this->timeout))
            $h['Refresh'] = $this->timeout . '; url=' . $this->url;
        else
            $h['Location'] = (string)$this->url;
        return $h;
    }
1302683
public function headers() {
    $headers = array();
    $readers = array();
    $writers = array();

    // Create the rule strings. We need two copies, one for READ and
    // one for WRITE.
    foreach ($this->rules as $rule) {
      // We generate read and write rules separately so that the
      // generation logic has a chance to respond to the differences
      // allowances for READ and WRITE ACLs.
      if (self::READ & $rule['mask']) {
        $ruleStr = $this->ruleToString(self::READ, $rule);
        if (!empty($ruleStr)) {
          $readers[] = $ruleStr;
        }
      }
      if (self::WRITE & $rule['mask']) {
        $ruleStr = $this->ruleToString(self::WRITE, $rule);
        if (!empty($ruleStr)) {
          $writers[] = $ruleStr;
        }
      }
    }

    // Create the HTTP headers.
    if (!empty($readers)) {
      $headers[self::HEADER_READ] = implode(',', $readers);
    }
    if (!empty($writers)) {
      $headers[self::HEADER_WRITE] = implode(',', $writers);
    }

    return $headers;
  }
273959
public function getAllHeaderLines()
    {
        $headers = [];
        foreach ($this->getAllHeaders() as $field => $valueArray) {
            foreach ($valueArray as $value) {
                $headers[] = "{$field}: $value";
            }
        }

        return $headers;
    }
776823
public function getHeadersAsArray()
    {
        $headers = array();
        foreach ($this->getHeaders() as $headerNode) {
            $header = array(
                'type' => $headerNode->getType(),
                'name' => $headerNode->getName(),
                'value' => $headerNode->getValue(),
                'uri' => $headerNode->getUri(),
                'override' => $headerNode->getOverride(),
                'append' => $headerNode->getAppend()
            );
            $headers[$headerNode->getType()][] = $header;
        }
        return $headers;
    }
935525
protected function receiveHeader()
    {
        if(strlen($this->bufferData) > 8)
        {
            $header = substr($this->bufferData,0,8);
            $this->waitingFor = intval($header);
            $this->bufferData = substr($this->bufferData,8);
            $this->headerReceived = true;
            return strlen($this->bufferData) > 0;
        }
        return false;
    }
781803
public function extractHeaders(){
        $absoluteUrl = $this->getAbsoluteUrl();
        $headersArrRaw = get_headers($absoluteUrl, 1); 
        
        if($headersArrRaw === false){
            throw new \Exception("cannot get headers for {$absoluteUrl}");
        }
        
        $headersArr = array_change_key_case($headersArrRaw, CASE_LOWER);        
        if(isset($headersArr[0]) === true && strpos($headersArr[0], 'HTTP/') !== false){
            $statusStmt = $headersArr[0];
            $statusParts = explode(' ', $statusStmt);
            $headersArr['status-code'] = $statusParts[1];
            
            $statusIndex = strrpos($statusStmt, $statusParts[1])+ strlen($statusParts[1])+1;
            $headersArr['status'] = trim(substr($statusStmt, $statusIndex));
        }
        if(is_array($headersArr['content-type']) === true){
            $headersArr['content-type'] = end($headersArr['content-type']);
        }
        
        return $headersArr;
    }
954672
public function getHeaders()
	{
		// Define a headers array
		$headers = [];

		foreach($this->items as $key => $value)
		{
			// Does our server attribute have our header prefix ?
			if(strpos($key, $this->http_header_prefix) === 0)
			{
				$key = substr($key, strlen($this->http_header_prefix));
			}
			else if(! in_array($key, $this->http_nonprefixed_headers))
			{
				continue;
			}

			$key = HeaderCollection::normalizeKey($key);

			// Add our server attribute to our header array
			$headers[$key] = $value;
		}

		return $headers;
	}
1069545
public function getHeaders()
    {
        $headers = [];

        foreach($this->headers as $name => $values) {
            $headers[strtolower($name)] = $values;
        }

        return $headers;
    }