HTTP… to GET or not to GET?

We’ve just released our latest version of Server Check, which adds a search bar, better error information when testing a monitor, and improves the web page loading experience.

We also added a new mailing option to the software, which allows you to use the Server Check Mail System to send all emails instead of SMTP. This is great if you don’t have your own SMTP server, or your SMTP server has usage or technical restrictions in place. Using the Server Check Mail System option is also a lot quicker and hassle-free to set up, and it’s available in all licensed versions of our server monitoring software including the free 10-monitor version (as long as it is registered and has a license key applied to it!).

Another great new addition is the HTTP Request Method option, which is specific to HTTP monitors. This allows you to choose whether an HTTP or HTTPS request is made using the GET request method or the POST request method. On the surface, and particularly when monitoring a website with a plain address with no query string, these two methods appear to do the same thing. GET is the most common request method used, and is commonly used to request data from a resource. POST is often used to send data to a server for a variety of reasons, including submitting form data.

The magic happens when you are requesting a web address that includes a query string, for example:

https://www.mywebsite.com/index.php?variable=yellow&anothervariable=tuesday

In this example, https://www.mywebsite.com/index.php is the resource we are requesting, while variable=yellow&anothervariable=tuesday is the query string. The ? separates the requested resource and the query string.

The query string contains name/value pairs, which in our example above are set to:

variable = yellow
anothervariable = tuesday

There could be any number of these name/value pairs, all joined with an ampersand (&) between each. This is the data that is being used by the server in some way, to either process the request correctly and send back the correct information, or to provide information to the server for it to process, for example, to write to a database or look up something in a database.

The data in the query string can be sent to the server as part of the URL, which often means it is visible in the server logs (this is the GET request method) or sent more privately in the request body and not usually shown in server logs (this is the POST request method).

In Server Check, because we enter the URL in one text box, we include the name/value pairs as part of the URL, regardless of whether we want to make the request using the GET method or the POST method. Server Check will then either keep it as part of the URL when GETting the monitor check, or parse it out from the URL and send it in the request body when POSTing the monitor check.

So, if we use GET for our example above, Server Check will send a request to the server that looks something like this:

GET /index.php?variable=yellow&anothervariable=tuesday HTTP/1.1
Host: www.mywebsite.com
User-Agent: Mozilla/5.0
Connection: close

And if we use POST, Server Check will send the request in this format instead:

POST /index.php HTTP/1.1
Host: www.mywebsite.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 39
User-Agent: Mozilla/5.0
Connection: close

variable=yellow&anothervariable=tuesday

There are some other important differences between GET and POST. GET requests can be cached, can remain in a browser’s history, can be bookmarked, and they have length restrictions. POST requests are never cached, they do not remain in a browser’s history (only the URL without the data would remain), they cannot be bookmarked without losing the data, and there are usually no restrictions on data length.

Other request methods also exist, including PUT, HEAD, DELETE and OPTIONS, but these are not currently available within Server Check.

If you want to find out more about HTTP request methods, you can visit https://www.w3schools.com and https://developer.mozilla.org.