Networking 3 Flashcards
Web Servers
SW apps that accept and process requests (according to HTTP)
Generic Web Servers (GWS)
Multi-purpose apps that serve files which exist in a certain folder on the OS.
Apache and Nginx are the two most popular.
Configured to use a folder as a ‘web root’; that folder will contain the files needed for the website. Should include an index file, e.g. index.html or index.php, that is served when a ‘/’ request is made.
Most of the internet still runs on these.
Advantages of GWS
- Easy to set up
- Require no programming knowledge
Custom Web Servers (CWS)
Purpose-built programs designed to run one specific site.
Instead of serving files directly out of a folder, the routes usually need to be programmed into the software.
The code of the web server will define what happens when a user tries to access a certain path or route.
Ports
Typically web servers will listen on either port 80 (HTTP Unencrypted), or 443 (HTTPS Encrypted).
Web servers can be configured to listen on non-standard ports, but that means anyone who needs to access them will need to put the port number at the end of the domain.
HTTP Requests
GET, HEAD, POST, PUT, DELETE
GET Request
Asks to retrieve a specified resource.
HEAD Request
Asks to retrieve a specified resource, but without the response body. In other words, retrieve only the metadata without the data.
This type of request is not common and is more often used when developers are testing their site.
POST Request
Used to send data to the web server without expecting anything back. This is commonly used by HTML forms, for example.
PUT Request
Used to ask the web server to store the data sent in the request at the path requested.
So for example, a PUT request to ‘https://some-fake-domain.fake/about.html’ would add the data sent to the web server in the PUT request as ‘about.html’ (if authorised). If ‘about.html’ already exists, it is overwritten with the new data.
Also not common.
DELETE Request
Deletes the resource specified in the request (if authorised). Again, this one is not commonly seen.
HTTP Response
The HTTP response is split into the response header and the response body.
The response body contains the data that was retrieved.
The request header, on the other hand, will contain metadata about the request, including usually valid request types for that page, the response length, date, name of the server, type of web server being used and so on.
HTML
HTML is a markup language, rather than a programming language. In other words, it is a way of describing data.
HTML uses tags, which are enclosed in less than () signs.
Javascript
JavaScript is a programming language that is designed to run inside a browser. It can be used to make changes to HTML even after it has been loaded onto the page.
PHP
The difference between PHP and JavaScript is that PHP is executed by the web server and then the result of that execution (usually HTML) is sent as a response to an HTTP request.