/** * @return null|string */ protected function getRequestMethod() { $method = $_SERVER['REQUEST_METHOD']; if (!HttpConst::isMethod($method)) { return null; } return $method; }
/** * @param int $code * @return AbstractModeHandler this */ protected function error($code) { if (!HttpConst::isStatus($code)) { throw new RuntimeException('unknown HTTP-Status Code `' . $code . '`'); } http_response_code($code); # pipe to URL if (isset($this->settings['err' . $code . '-pipe'])) { $target = new MAPUrl($this->settings['err' . $code . '-pipe'], $this->config); if ($target->get() === $this->request->get()) { Logger::error('endless pipe-loop (status: `' . $code . '`) - interrupted with HTTP-Status `508`'); return $this->error(508); } $this->setLocation(new Url($this->settings['err' . $code . '-pipe'])); return $this; } # default error output if (defined('peer\\http\\HttpConst::STATUS_' . $code)) { $message = constant('peer\\http\\HttpConst::STATUS_' . $code); } else { $message = 'N/A'; } $this->setContentType('text/plain'); echo '[' . $code . '] ' . $message; return $this; }