CGI

Principle

As we have seen, HTTP is a simple text-based protocol. Server-side programming actually consists in running code between receiving the request and sending the response.

We have seen that, in this case, some operations are generic enough to be performed every time, such as:

  • Extracting the request headers
  • Retrieving the GET and POST parameters
  • Building the response headers
  • ...

We would like to access the parts of the request in a form specific to our programming language (for example, having the GET parameters in a {} dictionary).

The "bridge" between HTTP and a language is called "CGI".

Moreover, the work of building structures that represent the data of the HTTP request and response is already done for you.

Thus, your server-side technology will have access to the request data, and will be able to modify the response through an API that is simpler than the HTTP protocol itself.

Note

Unlike HTML, JavaScript or CSS, the server-side language is an arbitrary choice.

As a result, there are tons of server-side technologies.

Current landscape

W3Tech.com publishes statistics on the usage of server-side languages (when they are known):

According to it, PHP and ASP.NET are by far the two most popular technologies.

Statistics on trends over time are also available: