I have a page with this code:
<?php
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
header('HTTP/1.0 405 Method Not Allowed');
exit(); }
If I access it with a form in GET method, it works, and doesn't exit, which is ok. But when I try to access this file directly, I would expect the file to perform the exit -
unless, a GET request is sent automatically whenever one access a file, even when not through a form?
unless, a GET request is sent automatically whenever one access a file, even when not through a form?
It is.
When you follow a link or type a URL into the address bar, you are getting a resource (you aren't asking for just metadata (HEAD), or sending any kind of data (PUT, POST), or deleting something (DELETE)) so you use GET.
Unless you specifically issue a POST
, PUT
, HEAD
, etc. request then it is GET
. If you click a link in a page or use the URL bar in the browser it is GET
.