/** * If the date returned by the parent is empty the method returns a date created from * {@link DEFAULT_EXPIRES}. * * @return DateTime|Headers\Date */ protected function get_expires() { $expires = parent::get_expires(); if (!$expires->is_empty) { return $expires; } return DateTime::from(self::DEFAULT_EXPIRES); }
/** * If `$body` is null the function does nothing. * * If {@link $rc} is a closure `$body` is set to {@link $rc}. * * Otherwise a JSON string is created with the message, errors and {@link $metas} of the * response. If the response is successful the {@link $rc} property is also present. This JSON * string is set in `$body`. The `Content-Type` header field is set to * "application/json" and the `Content-Length` header field is set to the length of the JSON * string. * * @inheritdoc */ protected function finalize(Headers &$headers, &$body) { parent::finalize($headers, $body); if ($body !== null) { return; } $rc = $this->rc; # streaming if ($rc instanceof \Closure) { $body = $rc; return; } $this->finalize_as_json($this->finalize_as_array($rc), $headers, $body); }