Web Requests

HyperText Transfer Protocol (HTTP)

Internet communication uses the protocol HTTP which is an application level-protocol. HTTP is client - server based communciation using requests.

DNS

DNS is used to resolve domain names to get its matching IP. After getting the IP a GET request is send asking for root path, result in a 200 OK code when a file is found.

HTTP sents everything in cleartext while HTTPS sends all communications in encrypted formats.

Requests and Responses

HTTP request is from client, containing details required from a server like resources, request data and headers. The server proceses and sends a HTTP response.

Request Headers

Headers are used to pass information between client and server, some are specific and some general.

Header
Example

Date

Date: Wed, 12 May 2022 11:32:42 GMT

Connection

Connection: close

Content-Type

Content-Type: text/html

Content-Length

Content-Length: 385

Content-Encoding

Content-Encoding: gzip

Host

Host: www.domain.com

User-Agent

User-Agent: curl/7.77.0

Cookie

Cookie: PHPSESSID=b4e4fbd93540

Response Headers

Header
Example

Server

Server: Apache/2.2.14 (Win32)

Set-Cookie

Set-Cookie: PHPSESSID=b4e4fbd93540

Content-Security-Policy

Content-Security-Policy: script-src 'self'

Referrer-Policy

Referrer-Policy: origin

HTTP Methods

Methods are used to tell server how to process requests we send and how to reply.

Method
Description

GET

Requests resource.

POST

Sends data to server

HEAD

Requests headers

PUT

Creates new resource on server

DELETE

Deletes resource on server

OPTIONS

Show accpted methods

PATCH

Applies modifications to resource

Reponse Codes

HTTP status codes tells client the status of a request. Most common are.

Code
Description

200 OK

Succesfull request

302 Found

Redirect to another URL

400 Bad Request

Returns malformed request

403 Forbidden

No access to resource

404 Not Found

Doesn't exist

500 Interal Server Error

Server cannot process request.

Last updated

Was this helpful?