devinow / http
Devinow Framework Http Library,HTTP Utilities.
3.0.0
2023-08-03 15:46 UTC
Requires
- php: >=8.1.0
README
composer require devinow/http
Usage
Response headers
-
Retrieving a header (with optional value prefix)
$header = \Devinow\Http\ResponseHeader::get('Content-Type'); // or $header = \Devinow\Http\ResponseHeader::get('Content-Type', 'text/html');
-
Setting a header (overwriting other headers with the same name)
\Devinow\Http\ResponseHeader::set('X-Frame-Options', 'sameorigin');
-
Adding a header (preserving other headers with the same name)
\Devinow\Http\ResponseHeader::add('Vary', 'User-Agent');
-
Removing a header (with optional value prefix)
$success = \Devinow\Http\ResponseHeader::remove('X-Powered-By'); // or $success = \Devinow\Http\ResponseHeader::remove('X-Powered-By', 'PHP');
-
Retrieving and removing a header at once (with optional value prefix)
$header = \Devinow\Http\ResponseHeader::take('Set-Cookie'); // or $header = \Devinow\Http\ResponseHeader::take('Set-Cookie', 'mysession=test');