Add Server-Timing headers for the TimeData collector

@see https://www.w3.org/TR/server-timing/
@param Response $response
544868
protected function addServerTimingHeaders(Response $response)
    {
        if ($this->hasCollector('time')) {
            $collector = $this->getCollector('time');

            $headers = [];
            foreach ($collector->collect()['measures'] as $k => $m) {
                $headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
            }

            $response->headers->set('Server-Timing', $headers, false);
        }
    }
613697
protected function addCookieConsentScriptToResponse(Response $response)
    {
        $content = $response->getContent();

        $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);

        $content = ''
            .substr($content, 0, $closingBodyTagPosition)
            .view('cookieConsent::index')->render()
            .substr($content, $closingBodyTagPosition);

        return $response->setContent($content);
    }
567279
protected function addCookieToResponse(Response $response, Session $session)
    {
        if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig())) {
            $response->headers->setCookie(new Cookie(
                $session->getName(), $session->getId(), $this->getCookieExpirationDate(),
                $config['path'], $config['domain'], $config['secure'] ?? false,
                $config['http_only'] ?? true, false, $config['same_site'] ?? null
            ));
        }
    }
443094
public function prepareResponse(Response $response)
    {
        $cto = $this->getContentTypeObject();
        if (!empty($cto)) {
            $ctt_type = $cto->getContentType();
        } else {
            $ctt_type = $this->getContentType();
        }
        $response->setContentType($ctt_type);
    }
517003
protected function addHeaders(Response $response, $maxAttempts, $remainingAttempts, $retryAfter = null)
    {
        $headers = [
            'X-RateLimit-Limit' => $maxAttempts,
            'X-RateLimit-Remaining' => $remainingAttempts,
        ];

        if (!is_null($retryAfter)) {
            $headers['Retry-After'] = $retryAfter;
        }

        $response->headers->add($headers);

        return $response;
    }
479386
protected function addCookieToResponse( Response $response, SessionInterface $session )
	{
		if ( $this->usingHandler( CookieSessionHandler::class ) )
			$this->driver()->save();

		if ( $this->sessionIsPersistent() )
			$response->headers->setCookie( new Cookie( $session->getName(), $session->getId(), $this->getCookieExpirationDate(), Config::get( $this->configPrefix . '.path' ), Config::get( $this->configPrefix . '.domain' ), Config::get( $this->configPrefix . '.secure', false ), Config::get( $this->configPrefix . '.http_only', true ) ) );
	}
746042
private function _setResponseHeaders()
    {
        $this->_response->setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT", true)
                        ->setHeader("Last-Modified", gmdate("D, d M Y H:i:s") . " GMT", true)
                        ->setHeader("Cache-Control", "no-store, no-cache, must-revalidate", true)
                        ->setHeader("Cache-Control", "post-check=0, pre-check=0", false)
                        ->setHeader("Pragma", "no-cache", true)
                        ->sendHeaders();
    }
522268
protected function addCookieToResponse(Response $response, SessionInterface $session)
	{
		$s = $session;

		if ($this->sessionIsPersistent($c = $this->manager->getSessionConfig()))
		{
			$secure = array_get($c, 'secure', false);

			$response->headers->setCookie(new Cookie(
				$s->getName(), $s->getId(), $this->getCookieLifetime(), $c['path'], $c['domain'], $secure
			));
		}
	}
572692
protected function writeQueuedCookies(Response $response)
    {
        foreach ($this->queue->getQueuedCookies() as $cookie) {
            $response->headers->setCookie($cookie);
        }
    }
983726
private function parseResponse($response) {
        $response = trim($response);
        $this->responseStatus = (int) substr($response, 0, 3);
        $this->response = substr($response, 4);
    }
229342
private void setDateAndCacheHeaders(HttpResponse response, File fileToCache) {
        response.headers().set(HttpConst.DATE, DateKit.gmtDate());
        // Add cache headers
        if (httpCacheSeconds > 0) {
            response.headers().set(HttpConst.EXPIRES, DateKit.gmtDate(LocalDateTime.now().plusSeconds(httpCacheSeconds)));
            response.headers().set(HttpConst.CACHE_CONTROL, "private, max-age=" + httpCacheSeconds);
            if (null != fileToCache) {
                response.headers().set(HttpConst.LAST_MODIFIED, DateKit.gmtDate(new Date(fileToCache.lastModified())));
            } else {
                response.headers().set(HttpConst.LAST_MODIFIED, DateKit.gmtDate(LocalDateTime.now().plusDays(-1)));
            }
        }
    }
556449
private function setErrorFromResponse(Response $response)
    {
        $this->statusCode = $response->getStatus();
        $body = $response->getBody();
        if (isset($body['ErrorInfo'])) {
            $this->errorInfo = $body['ErrorInfo'];
        }
        if (isset($body['ErrorMessage'])) {
            $this->errorMessage = $body['ErrorMessage'];
        }
        if (isset($body['ErrorIdentifier'])) {
            $this->errorIdentifier = $body['ErrorIdentifier'];
        }
    }
882611
private function getLastModifiedTimestampFromResponse(\StdClass $response)
    {
        if (!property_exists($response, 'lastModifiedDateTime')) {
            return;
        }

        //date can be given with or without microseconds, try to parse from both formats
        $date = \DateTime::createFromFormat('Y-m-d\TH:i:s.uO', $response->lastModifiedDateTime, new \DateTimeZone('UTC'));
        if (!$date) {
            $date = \DateTime::createFromFormat('Y-m-d\TH:i:sO', $response->lastModifiedDateTime, new \DateTimeZone('UTC'));
        }

        if (!$date) {
            throw new OneDriveAdapterException('Incorrect last modified date returned from the API.');
        }

        return $date->getTimestamp();
    }
1249146
protected function renderResponse(Response $response)
    {
        $sendEvent = new SendResponseEvent();
        $sendEvent->setResponse($response);

        $this->responseSender->__invoke($sendEvent);
    }
296007
function build(iHttpResponse $response)
    {
        ($this->version       === null) ?: $response->setVersion($this->version);
        ($this->status_code   === null) ?: $response->setStatusCode($this->status_code);
        ($this->status_reason === null) ?: $response->setStatusReason($this->status_reason);
        ($this->headers       === null) ?: $response->setHeaders($this->headers);
        ($this->body          === null) ?: $response->setBody($this->body);
    }
788835
protected function withStaticHeaders(ResponseInterface $response, array $headers): ResponseInterface
    {
        foreach ($headers as $name => $header) {
            $response = $response->withAddedHeader($name, $header);
        }

        return $response;
    }
1320686
protected function setNeededAction(Response $response) {
        if ($response->hasHtml())
        {
            $response->setNeededAction(Response::NEEDED_SHOW_HTML);
        }
        elseif ($response->isProcessing())
        {
            $response->setNeededAction(Response::NEEDED_STATUS_UPDATE);
        }
    }