/** * Handle a GET request for this resource * @param Request request * @return Response */ function get($request) { $response = new Response($request); $etag = md5($request->uri); if ($request->ifNoneMatch($etag)) { $response->code = Response::NOTMODIFIED; } else { $response->code = Response::OK; $response->addHeader('Content-type', 'text/plain'); $response->addEtag($etag); $response->body = "Hello world!\n" . "\n" . "This request:\n" . "\n" . $request->__toString() . "\n" . "\n" . "This response:\n" . "\n" . $response->__toString(); } return $response; }
/** * {@inheritdoc} */ public function __toString() { $this->clearBuffer(); return parent::__toString(); }
/** * Convert the object into a string suitable for printing * @return str */ function __toString() { $str = parent::__toString(); $str .= "\n\n" . $this->body; return $str; }