Sets the packet identifier straight from the raw MQTT headers

@param string $rawMQTTHeaders
@return self
@throws \OutOfRangeException
423121
final public function setPacketIdentifierFromRawHeaders(string $rawMQTTHeaders): self
    {
        $this->packetIdentifier = new PacketIdentifier(
            Utilities::convertBinaryStringToNumber($rawMQTTHeaders{2} . $rawMQTTHeaders{3})
        );

        return $this;
    }
1098718
private function setRequestHeaders($headers = array()) {
        foreach ($this->headers as $key => $value) {
            $headers[] = $key . ': ' . $value;
        }
        curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
    }
1018148
private function setIpAddress(?string $ipAddress): self
    {
        $this->updatePropertyValue(
            IpAddressFieldInterface::PROP_IP_ADDRESS,
            $ipAddress
        );

        return $this;
    }
896203
public function setAsNotModified()
    {
        $this->setStatusCode(304);
        $this->setContent('');

        // remove headers that MUST NOT be included with 304 Not Modified responses
        $headersToRemove = [
            'Allow',
            'Content-Encoding',
            'Content-Language',
            'Content-Length',
            'Content-MD5',
            'Content-Type',
            'Last-Modified'
        ];
        foreach ($headersToRemove as $header) {
            $this->headers->removeKey($header);
        }

        return $this;
    }
674172
public function sendHeaders()
    {
        foreach ($this->_headers as $key => $value) {
            if (is_array($value)) {
                foreach ($value as $v) {
                    header($key.': '.$v, false);
                }
            } else {
                header($key.': '.$value);
            }
        }

        return $this;
    }
524071
protected function prepareHeaders(array $rawHeaders)
    {
        $headers = array();
        
        foreach ($rawHeaders as $rawHeader) {
            if (strpos($rawHeader, ':')) {
                $data = explode(':', $rawHeader);
                $headers[$data[0]][] = trim($data[1]);
            }            
        }
        
        return $headers;
    }
647984
void setNettyHeaders(io.netty.handler.codec.http.HttpHeaders headers) {
        this.nettyHeaders = headers;
    }
1007078
public function setFieldIdentifier($fieldIdentifier)
    {
        if ($fieldIdentifier == '' || Format::isIdentifier($fieldIdentifier)) {
            $this->fieldIdentifier = $fieldIdentifier;
        } else {
            $msg = "'${fieldIdentifier}' is not a valid QTI identifier.";
            throw new InvalidArgumentException($msg);
        }
    }
1353680
protected function splitHeaders($rawHeaders)
    {
        $headers = array();

        $lines = explode("\n", trim($rawHeaders));
        $headers['HTTP'] = array_shift($lines);

        foreach ($lines as $h) {
            $h = explode(':', $h, 2);

            if (isset($h[1])) {
                $headers[$h[0]] = trim($h[1]);
            }
        }

        return (object)$headers;
    }
376545
public function setHeaders(array $headers)
    {
        foreach ($headers as $key => $value) {
            $this->headers[$key] = $value;
        }

        return $this;
    }
362513
public static function setResponseHeaders($headers)
    {
        foreach ($headers as $name => $headerValues) {
            $header = $name . ": " . implode(", ", $headerValues);
            header($header);
        }
    }
42809
private function parseHeader($rawHeader) {

        // Initialize the headers.
        $headers = [];
        $key     = "";

        // Handle each header.
        foreach (explode("\n", $rawHeader) as $h) {
            $h = explode(":", $h, 2);
            if (true === isset($h[1])) {
                if (false === isset($headers[$h[0]])) {
                    $headers[$h[0]] = trim($h[1]);
                } elseif (true === is_array($headers[$h[0]])) {
                    $headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]);
                } else {
                    $headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]);
                }
                $key = $h[0];
            } else {
                if ("\t" === substr($h[0], 0, 1)) {
                    $headers[$key] .= "\r\n\t" . trim($h[0]);
                } elseif (!$key) {
                    $headers[0] = trim($h[0]);
                }
                trim($h[0]);
            }
        }

        // Return the headers.
        return $headers;
    }
1228238
public function setMacAddress(string $macAddress)
    {
        $this->macAddress = $macAddress;

        $this->raw = array_merge($this->raw, ['MacAddress' => $macAddress]);

        return $this;
    }
418445
private function performRemainingLengthFieldOperations(
        string &$rawMQTTHeaders,
        ClientInterface $client
    ): int {
        // Early return: assume defaults if first digit has a value under 128, no further need for complex checks
        if (ord($rawMQTTHeaders{1}) < 128) {
            return ord($rawMQTTHeaders{1});
        }

        // If we have less than 4 bytes now, we should really try to recover the rest of the remaining field data
        if (strlen($rawMQTTHeaders) < 4) {
            // At this point we could actually read at least 128 as a minimum, but restrict it to what we need right now
            $rawMQTTHeaders .= $client->readBrokerData(4 - strlen($rawMQTTHeaders));
        }

        $remainingBytes = Utilities::convertRemainingLengthStringToInt(substr($rawMQTTHeaders, 1, 4));

        // Estimate how much longer is the remaining length field, this will also set $this->sizeOfRemainingLengthField
        $this->calculateSizeOfRemainingLengthField($remainingBytes);
        return $remainingBytes;
    }
699486
public function setQos($qos)
    {
        Utility::CheckQoS($qos);
        $this->qos = (int) $qos;

        if ($this->qos > 0) {
            /*
              SUBSCRIBE, UNSUBSCRIBE, and PUBLISH (in cases where QoS > 0) Control Packets MUST contain a
              non-zero 16-bit Packet Identifier [MQTT-2.3.1-1].
             */
            $this->require_msgid = true;
        } else {
            /*
              A PUBLISH Packet MUST NOT contain a Packet Identifier if its QoS value is set to 0 [MQTT-2.3.1-5].
             */
            $this->require_msgid = false;
        }
    }
256079
public function setHeaders($headers) {
    $this->allHeaders = array();

    foreach ($headers as $name => $value) {
      if (strpos($name, Container::METADATA_HEADER_PREFIX) !== 0) {
        $this->allHeaders[$name] = $value;
      }
    }

    return $this;
  }
232523
public function addDefaultHeaders($headers)
    {
        foreach ($headers as $name => $value) {
            $this->addDefaultHeader($name, $value);
        }

        return $this;
    }