#HTTP & HTTPS

The foundation of web communication.


#HTTP Methods

MethodPurposeIdempotent
GETRetrieve dataYes
POSTCreate resourceNo
PUTUpdate/replaceYes
PATCHPartial updateNo
DELETERemove resourceYes
HEADHeaders onlyYes
OPTIONSGet methodsYes

#Status Codes

RangeCategoryExamples
1xxInformational100 Continue
2xxSuccess200 OK, 201 Created
3xxRedirect301 Moved, 302 Found
4xxClient Error400 Bad Request, 404 Not Found
5xxServer Error500 Internal, 503 Unavailable

#HTTPS

HTTPS = HTTP + TLS encryption

Loading diagram...

#Testing with cURL

bash
1# GET request
2curl https://api.example.com/users
3
4# POST with JSON
5curl -X POST -H "Content-Type: application/json" \
6  -d '{"name":"John"}' https://api.example.com/users
7
8# With headers
9curl -H "Authorization: Bearer token" https://api.example.com
10
11# Show response headers
12curl -I https://example.com
13
14# Verbose mode
15curl -v https://example.com