/** * Attaches the header and the content to the passed in request object. * * @param ResponseInterface response */ public function sendLogs(ResponseInterface &$response = null) { if (is_null($response)) { $response = Services::response(null, true); } $data = base64_encode(utf8_encode(json_encode($this->json))); $response->setHeader($this->header, $data); }
/** * Get our Response object, and set some default values, including * the HTTP protocol version and a default successful response. */ protected function getResponseObject() { $this->response = Services::response($this->config); if (!is_cli()) { $this->response->setProtocolVersion($this->request->getProtocolVersion()); } // Assume success until proven otherwise. $this->response->setStatusCode(200); }
</td> </tr> <?php } ?> </tbody> </table> <?php } ?> </div> <!-- Response --> <?php $response = \CodeIgniter\Services::response(null, true); $response->setStatusCode(http_response_code()); ?> <div class="content" id="response"> <table> <tr> <td style="width: 15em">Response Status</td> <td><?php echo $response->getStatusCode() . ' - ' . $response->getReason(); ?> </td> </tr> </table> <?php $headers = $response->getHeaders();
/** * Convenience method that works with the current global $request and * $router instances to redirect using named/reverse-routed routes * to determine the URL to go to. If nothing is found, will treat * as a traditional redirect and pass the string in, letting * $response->redirect() determine the correct method and code. * * If more control is needed, you must use $response->redirect explicitly. * * @param string $uri * @param $params */ function redirect(string $uri, ...$params) { $response = Services::response(null, true); $routes = Services::routes(true); if ($route = $routes->reverseRoute($uri, ...$params)) { $uri = $route; } $response->redirect($uri); }