use SecureRequest\Request; $request = new Request($server, $headers); if ($request->isHTTPS()) { // perform secure actions } else { // redirect to HTTPS header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit; }
use SecureRequest\Request; use SecureRequest\Auth; $request = new Request($server, $headers); $auth = new Auth($realm, $users); if ($auth->isAuthenticated($request)) { // perform authorized actions } else { $auth->sendCredentials($request); }PHP Request Secure library can be found on Github and installed via Composer. The package library name is `secure-request/secure-request`.