Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
FAQs Support
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials

HTTP and the Web

HTTP Versions

VersionYearKey Features
HTTP/1.01996One request per connection; no persistent connections
HTTP/1.11997Persistent connections (keep-alive), pipelining, chunked transfer, Host header
HTTP/22015Binary framing, multiplexing (multiple requests over one connection), header compression (HPACK), server push
HTTP/32022Built on QUIC (UDP-based), eliminates head-of-line blocking, faster connection setup, built-in TLS 1.3

HTTP Methods

MethodPurposeIdempotentSafe
GETRetrieve a resourceYesYes
POSTCreate a resource or submit dataNoNo
PUTReplace a resource entirelyYesNo
PATCHPartially update a resourceNoNo
DELETEDelete a resourceYesNo
HEADSame as GET but returns headers onlyYesYes
OPTIONSDescribe communication options (used in CORS preflight)YesYes

HTTP Status Codes

RangeCategoryCommon Codes
1xxInformational100 Continue, 101 Switching Protocols
2xxSuccess200 OK, 201 Created, 204 No Content
3xxRedirection301 Moved Permanently, 302 Found, 304 Not Modified
4xxClient Error400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests
5xxServer Error500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable

Important HTTP Headers

HeaderDirectionPurpose
Content-TypeRequest/ResponseMedia type of the body (e.g., application/json, text/html)
AuthorizationRequestCredentials for authentication (Bearer token, Basic auth)
Cache-ControlRequest/ResponseCaching directives (no-cache, max-age, private)
AcceptRequestMedia types the client can handle
LocationResponseURL for redirects (3xx) or newly created resource (201)
Set-CookieResponseSets a cookie on the client
CORS headersResponseAccess-Control-Allow-Origin, Access-Control-Allow-Methods

HTTPS and TLS

HTTPS = HTTP + TLS (Transport Layer Security). TLS encrypts the HTTP communication to provide:

  • Confidentiality: Data is encrypted - cannot be read by eavesdroppers
  • Integrity: Data cannot be tampered with in transit (MAC)
  • Authentication: Server identity verified via digital certificate (X.509)

TLS 1.3 (current standard) improvements over TLS 1.2: faster handshake (1-RTT vs 2-RTT), removed weak cipher suites, mandatory forward secrecy.

REST Architecture

REST (Representational State Transfer) is an architectural style for designing web APIs. Key constraints:

  • Stateless: Each request contains all information needed; server stores no client state
  • Client-Server: Separation of concerns between UI and data storage
  • Uniform Interface: Resources identified by URIs; standard HTTP methods
  • Cacheable: Responses must define themselves as cacheable or non-cacheable
  • Layered System: Client doesn't know if it's talking to the actual server or a proxy

WebSockets

WebSockets provide full-duplex, persistent communication over a single TCP connection. Unlike HTTP (request-response), WebSockets allow the server to push data to the client at any time.

  • Initiated with an HTTP Upgrade request (Upgrade: websocket)
  • Uses ws:// (unencrypted) or wss:// (encrypted) protocol
  • Ideal for: real-time chat, live notifications, collaborative editing, gaming

Cookies vs Sessions

FeatureCookiesSessions
StorageClient-side (browser)Server-side
SecurityLess secure (visible to client)More secure (data on server)
Capacity~4 KB per cookieLimited by server memory
ExpirySet by server (persistent or session)Expires when browser closes or timeout
ScalabilityStateless - scales easilyStateful - requires sticky sessions or shared store (Redis)
Use caseRemember me, preferences, trackingLogin state, shopping cart

Previous Next

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.