HTTP in Detail 1690850720
HTTP in Detail 1690850720
1
CyberHost Assignment No: 01
2
CyberHost Assignment No: 01
THM{INVALID_HTTP_CERT}
3
CyberHost Assignment No: 01
Making a Request:
4
CyberHost Assignment No: 01
It's possible to make a request to a web server with just one line "GET /
HTTP/1.1"
But for a much richer web experience, you’ll need to send other data as
well. This other data is sent in what is called headers, where headers
contain extra information to give to the web server you’re communicating
with, but we’ll go more into this in the Header task.
Example Request:
GET / HTTP/1.1
Host: tryhackme.com
User-Agent: Mozilla/5.0 Firefox/87.0
Referer: https://tryhackme.com/
5
CyberHost Assignment No: 01
Line 1: HTTP 1.1 is the version of the HTTP protocol the server is using
and then followed by the HTTP Status Code in this case "200 Ok" which
tells us the request has completed successfully.
Line 2: This tells us the web server software and version number.
6
CyberHost Assignment No: 01
Line 3: The current date, time and timezone of the web server.
Line 4: The Content-Type header tells the client what sort of information
is going to be sent, such as HTML, images, videos, pdf, XML.
Line 5: Content-Length tells the client how long the response is, this way
we can confirm no data is missing.
Line 6: HTTP response contains a blank line to confirm the end of the
HTTP response.
Lines 7-14: The information that has been requested, in this instance
the homepage.
2. What response header tells the browser how much data to expect?
Content-Length
POST: To send data to the server for processing, use the POST method.
It can have unintended consequences for the server (such as data creation,
7
CyberHost Assignment No: 01
PUT: A resource on the server can be updated using the PUT technique. It
is idempotent, which means that repeated PUT requests that are exactly
the same should have the same effect. PUT is typically used to create a
new resource at a specific URL or to completely replace an existing
resource with a new version.
DELETE: To remove a resource from the server, use the DELETE method.
The server should delete the associated resource when a client sends a
DELETE request to a certain URL.
PUT
3. What method would be used to remove a picture you've uploaded to
your account?
DELETE
4. What method would be used to view a news article?
GET
8
CyberHost Assignment No: 01
These are sent to tell the client the first part of their request has been
100-199 - Information Response accepted and they should continue sending the rest of their request. These
codes are no longer very common.
This range of status codes is used to tell the client their request was
200-299 - Success
successful.
These are used to redirect the client's request to another resource. This can
300-399 - Redirection
be either to a different webpage or a different website altogether.
400-499 - Client Errors Used to inform the client that there was an error with their request.
This is reserved for errors happening on the server-side and usually indicate
500-599 - Server Errors
quite a major problem with the server handling the request.
201 - Created A resource has been created (for example a new user or new blog post).
9
CyberHost Assignment No: 01
This redirects the client's browser to a new webpage or tells search engines
301 - Permanent Redirect
that the page has moved somewhere else and to look there instead.
Similar to the above permanent redirect, but as the name suggests, this is
302 - Temporary Redirect
only a temporary change and it may change again in the near future.
This tells the browser that something was either wrong or missing in their
400 - Bad Request request. This could sometimes be used if the web server resource that is
being requested expected a certain parameter that the client didn't send.
You are not currently allowed to view this resource until you have
401 - Not Authorised authorised with the web application, most commonly with a username and
password.
You do not have permission to view this resource whether you are logged in
403 - Forbidden
or not.
The resource does not allow this method request, for example, you send a
405 - Method Not Allowed GET request to the resource /create-account when it was expecting a POST
request instead.
404 - Page Not Found The page/resource you requested does not exist.
The server has encountered some kind of error with your request that it
500 - Internal Service Error
doesn't know how to handle properly.
This server cannot handle your request as it's either overloaded or down for
503 - Service Unavailable
maintenance.
Click the "View Site" button on the right to see what some of these HTTP status
messages look like in a browser.
10
CyberHost Assignment No: 01
11
CyberHost Assignment No: 01
Headers:
HTTP headers are parts of the messages used for HTTP requests and
responses that contain extra data about the request or answer. They
inform the server or client of metadata or instructions that will affect how
the message should be processed or handled. In order to identify
content categories, enable authentication, control caching behaviour,
and manage cookies, among other things, HTTP headers are crucial.
Below are a few typical headers in more detail.
Common Request Headers:
These are headers that are sent from the client (usually your browser) to
the server.
Host: Some web servers host multiple websites so by providing
the host headers you can tell it which one you require, otherwise
you'll just receive the default website for the server.
User-Agent: This is your browser software and version number,
telling the web server your browser software helps it format the
website properly for your browser and also some elements of
HTML, JavaScript and CSS are only available in certain browsers.
Content-Length: When sending data to a web server such as in a
form, the content length tells the web server how much data to
expect in the web request. This way the server can ensure it isn't
missing any data.
Accept-Encoding: Tells the web server what types of
compression methods the browser supports so the data can be
made smaller for transmitting over the internet.
Cookie: Data sent to the server to help remember your information
(see cookies task for more information).
These are the headers that are returned to the client from the server after a
request.
Set-Cookie: Information to store which gets sent back to the web
server on each request (see cookies task for more information).
12
CyberHost Assignment No: 01
Cookies
Cookies are little data files that websites place on users' devices (such
computers or smartphones) when they visit them. These text files have
several uses and are crucial to contemporary web browsing. Websites
may track user behaviour, remember user preferences, and improve user
experiences with the aid of cookies. Cookies assist in the maintenance of
user sessions during sessions. A session cookie is created when you
check in to a website to keep you logged in as you visit different pages.
You won't need to log in to each page separately this way. It's important
to keep in mind that while cookies are useful for enhancing user
experiences and enabling various website activities, they have also raised
privacy issues. Modern online browsers offer improved transparency and
control over cookies in response to these worries, enabling users to alter
their privacy preferences. Additionally, laws have been put in place in
some jurisdictions (such as the GDPR in the European Union) to control
cookie usage and safeguard user privacy. Cookies keep track of user
choices and settings, including language, theme, and text size. This
makes it possible for websites to show visitors personalised content
depending on their choices. Only the server has access to and control
over HttpOnly cookies. This improves security by preventing client-side
scripts from accessing private cookie information.
To add an extra layer of protection and prevent unauthorised parties from
intercepting them, secure cookies are only transferred via encrypted
HTTPS connections. When making cross-site queries, the SameSite
property specifies how cookies are transmitted. To regulate cookie
behaviour and stop specific types of attacks like Cross-Site Request
Forgery (CSRF), it can be set to "Strict," "Lax," or "None."
Types of Cookies
13
CyberHost Assignment No: 01
14
CyberHost Assignment No: 01
15
CyberHost Assignment No: 01
16
CyberHost Assignment No: 01
17