Web Requests

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.

{% hint style="info" %} HTTP sents everything in cleartext while HTTPS sends all communications in encrypted formats. {% endhint %}

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.

HeaderExample
DateDate: Wed, 12 May 2022 11:32:42 GMT
ConnectionConnection: close
Content-TypeContent-Type: text/html
Content-LengthContent-Length: 385
Content-EncodingContent-Encoding: gzip
HostHost: www.domain.com
User-AgentUser-Agent: curl/7.77.0
CookieCookie: 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.

MethodDescription
GETRequests resource.
POSTSends data to server
HEADRequests headers
PUTCreates new resource on server
DELETEDeletes resource on server
OPTIONSShow accpted methods
PATCHApplies 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.