From 84e2b2be6f7537e0a4a9f0c323555404d2682a8a Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 29 Aug 2019 18:45:48 +0200 Subject: Add HTTP class This class was written in 2015 and originally had it's own repository. I decided to include it to the snippets repository because this piece of code does not need it's own repository. --- PHP/HTTP-Class/index.php | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 PHP/HTTP-Class/index.php (limited to 'PHP/HTTP-Class/index.php') diff --git a/PHP/HTTP-Class/index.php b/PHP/HTTP-Class/index.php new file mode 100755 index 0000000..cc52561 --- /dev/null +++ b/PHP/HTTP-Class/index.php @@ -0,0 +1,71 @@ + 'value_three'])) { + // do something +} + +#============================================================================== +# Check the HTTP request method +#============================================================================== +if(HTTP::requestMethod('GET') OR HTTP::requestMethod('POST') OR HTTP::requestMethod('HEAD')) { + // do something +} + +#============================================================================== +# Get the HTTP request method +#============================================================================== +$requestMethod = HTTP::requestMethod(); + +#============================================================================== +# Get the HTTP status code of the current request +#============================================================================== +$statusCode = HTTP::responseStatus(); + +#============================================================================== +# Send a HTTP status code to the client +#============================================================================== +HTTP::responseStatus(200); + +#============================================================================== +# Send a custom HTTP response header to the client +#============================================================================== +HTTP::responseHeader(HTTP::HEADER_CONTENT_TYPE, HTTP::CONTENT_TYPE_TEXT); + +#============================================================================== +# Send a HTTP redirect to the client and stop script execution +#============================================================================== +# HTTP::redirect('https://example.org/'); +# HTTP::redirect('https://example.org/', 303); +?> \ No newline at end of file -- cgit v1.2.3