Httpvshttps

21 min read4,082 words

HTTP and HTTPS — Hypertext Transfer Protocol

HTTP and HTTPS are application-layer protocols used for communication between clients and servers, especially on the Web.

The easiest way to remember the difference is:

HTTP Client ──────────────── Server Plain HTTP HTTPS Client ════════════════ Server HTTP + TLS Encrypted

Exam definition

HTTP (Hypertext Transfer Protocol) is an application-layer protocol used to transfer web resources between clients and servers. HTTPS is HTTP carried over a secure TLS connection, providing encryption, authentication, and integrity protection.

1. What Is HTTP?

HTTP = Hypertext Transfer Protocol

It is a protocol used for communication between:

Client ↕ Server

The client is usually a:

  • Web browser
  • Mobile application
  • API client
  • Command-line tool

The server may be:

  • Web server
  • Application server
  • API server

Example:

Browser │ │ HTTP Request ↓ Web Server │ │ HTTP Response ↓ Browser

2. What Is HTTPS?

HTTPS = HTTP Secure

More precisely:

HTTPS is HTTP transmitted over TLS (Transport Layer Security).

Simplified:

HTTP ↓ TLS ↓ TCP ↓ IP

For traditional HTTPS using HTTP/1.1 or HTTP/2:

Browser ↓ TLS ↓ TCP ↓ IP

HTTPS provides:

  • Encryption
  • Authentication
  • Integrity

3. HTTP vs HTTPS

FeatureHTTPHTTPS
Full formHypertext Transfer ProtocolHTTP Secure
ApplicationWeb/API communicationSecure Web/API communication
EncryptionNoYes, through TLS
AuthenticationNo TLS server authenticationUsually yes, via certificates
Integrity protectionNo cryptographic protectionYes
Common portTCP 80TCP 443
URLhttp://https://
Suitable for sensitive dataNoYes
CertificateNot requiredNormally required
Data visibility to network observersPotentially readableProtected by TLS

Important:

HTTPS does not mean a website is trustworthy or non-malicious. It means the connection to that domain is protected by TLS.

4. HTTP Architecture

A basic HTTP communication looks like:

HTTP │ ┌──────┴──────┐ │ │ Client Server │ │ └──────┬──────┘ │ Request/Response

Example:

Browser │ │ GET /index.html ↓ Server │ │ 200 OK │ HTML ↓ Browser

5. HTTP Is Request-Response Based

HTTP normally works using a:

Request → Response

model.

Client sends request

Client → HTTP Request → Server

Server sends response

Client ← HTTP Response ← Server

Complete:

Browser │ │ Request ↓ Server │ │ Response ↓ Browser

6. HTTP Request

An HTTP request contains things such as:

Request Line Headers Blank Line Optional Body

Example:

GET /index.html HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 Accept: text/html

7. HTTP Request Line

The request line contains:

METHOD PATH VERSION

Example:

GET /index.html HTTP/1.1

Here:

GET ↓ Method /index.html ↓ Resource/path HTTP/1.1 ↓ HTTP version

8. HTTP Methods

HTTP defines methods that indicate the intended operation.

Important methods:

GET POST PUT PATCH DELETE HEAD OPTIONS CONNECT TRACE

The most important for beginners are:

GET POST PUT PATCH DELETE

9. GET

GET is used to retrieve a resource.

Example:

GET /products HTTP/1.1 Host: example.com

Meaning:

"Give me the /products resource."

Typical uses:

GET /home GET /products GET /users/10 GET /api/posts

GET requests generally should not be used to perform state-changing operations.

10. POST

POST is commonly used to submit data or request creation/processing.

Example:

POST /login HTTP/1.1 Host: example.com Content-Type: application/json { "username": "user", "password": "example" }

The request body contains data.

Common uses:

  • Login
  • Form submission
  • Creating resources
  • Uploading data
  • Sending API requests

11. PUT

PUT is commonly used to create or completely replace a resource at a specified URI.

Example:

PUT /users/10 HTTP/1.1

Conceptually:

Replace/update user 10

12. PATCH

PATCH is used for partial modification.

Example:

PATCH /users/10

Body:

{ "email": "new@example.com" }

Only the specified field may be changed.

13. DELETE

Used to request deletion of a resource.

Example:

DELETE /users/10

Meaning:

Delete user 10

Actual behavior depends on the server/application.

14. HEAD

HEAD is similar to GET, but the server returns headers without the normal response body.

Example:

HEAD /index.html

Useful for checking information such as:

  • Resource existence
  • Content type
  • Content length
  • Cache information

15. OPTIONS

OPTIONS asks what communication options are supported for a resource.

Example:

OPTIONS /api/users

It is also commonly encountered with CORS preflight requests in browsers.

16. HTTP Request Headers

Headers provide additional information.

Example:

GET / HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 Accept: text/html Accept-Language: en-US Connection: keep-alive

Headers can communicate:

  • Host information
  • Content type
  • Authentication information
  • Cookies
  • Caching instructions
  • Accepted formats
  • Client information

17. Important HTTP Request Headers

Host

Identifies the requested host.

Host: example.com

This is especially important because many websites can share the same IP address.

User-Agent

Identifies the client software.

User-Agent: Mozilla/5.0

Accept

Indicates response formats the client can handle.

Accept: text/html

Content-Type

Describes the request body format.

Example:

Content-Type: application/json

Authorization

Can carry authentication credentials/tokens.

Example:

Authorization: Bearer <token>

Cookie

Sends cookies to the server.

Cookie: sessionid=abc123

18. HTTP Request Body

Some HTTP requests contain a body.

Example:

POST /api/users HTTP/1.1 Host: example.com Content-Type: application/json { "name": "Uday", "age": 22 }

The body contains application data.

GET requests can technically have a body according to HTTP specifications, but many systems do not use or expect one for GET.

19. HTTP Response

The server sends an HTTP response.

Structure:

Status Line Headers Blank Line Optional Body

Example:

HTTP/1.1 200 OK Content-Type: text/html Content-Length: 1250 <html> ... </html>

20. HTTP Status Codes

HTTP status codes tell the client what happened.

They are divided into five major categories:

1xx → Informational 2xx → Success 3xx → Redirection 4xx → Client error 5xx → Server error

Remember:

1 = Information 2 = Success 3 = Redirect 4 = Client problem 5 = Server problem

21. 1xx — Informational

Examples:

100 Continue 101 Switching Protocols 103 Early Hints

These provide intermediate information.

22. 2xx — Success

Important examples:

200 OK

Request succeeded.

200 OK

201 Created

A resource was created.

201 Created

202 Accepted

Request accepted for processing, but processing may not be complete.

204 No Content

Request succeeded but there is no response body.

23. 3xx — Redirection

Important examples:

301 Moved Permanently 302 Found 303 See Other 304 Not Modified 307 Temporary Redirect 308 Permanent Redirect

For example:

http://example.com ↓ 301 ↓ https://example.com

A browser may then request the new URL.

24. 4xx — Client Errors

These indicate that the request cannot be fulfilled as requested, often because of something about the client request.

Important:

400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 405 Method Not Allowed 408 Request Timeout 409 Conflict 429 Too Many Requests

400

Invalid request.

401

Authentication is required or authentication credentials are not accepted.

403

The server understood the request but refuses to authorize it.

404

Requested resource was not found.

429

Too many requests.

25. 401 vs 403

Very important.

401

Think:

"You need valid authentication."

403

Think:

"I understand who/what you are, but access is not allowed."

Simplified:

401 → Authentication issue 403 → Authorization/access issue

26. 5xx — Server Errors

These indicate that the server encountered an error or cannot fulfill the request.

Important:

500 Internal Server Error 501 Not Implemented 502 Bad Gateway 503 Service Unavailable 504 Gateway Timeout

500

Generic server-side error.

502

A gateway/proxy received an invalid response from an upstream server.

503

Server temporarily unavailable.

504

Gateway/proxy timed out waiting for an upstream server.

27. Status Code Summary

CodeMeaning
200OK
201Created
204No Content
301Permanent redirect
302Temporary/found redirect
304Not modified
400Bad request
401Unauthorized
403Forbidden
404Not found
405Method not allowed
429Too many requests
500Internal server error
502Bad gateway
503Service unavailable
504Gateway timeout

28. HTTP Headers in Response

Example:

HTTP/1.1 200 OK Content-Type: text/html Content-Length: 2048 Cache-Control: max-age=3600 Set-Cookie: sessionid=abc123

Important response headers include:

Content-Type Content-Length Cache-Control Set-Cookie Location ETag Last-Modified Server Strict-Transport-Security

29. Content-Type

Tells the client what type of content is being sent.

Examples:

text/html text/plain application/json image/png image/jpeg application/pdf text/css application/javascript

Example:

Content-Type: application/json

means the response body contains JSON data.

30. Cookies

HTTP itself is fundamentally stateless, but websites can use cookies to maintain state across requests.

Example:

Server ↓ Set-Cookie ↓ Browser

Later:

Browser ↓ Cookie ↓ Server

Example:

Set-Cookie: sessionid=abc123

Then:

Cookie: sessionid=abc123

31. Why Are Cookies Used?

Cookies can be used for:

  • Login sessions
  • Preferences
  • Shopping carts
  • Analytics
  • Other application state

HTTPS protects cookies in transit when the connection is properly secured.

Security-related cookie attributes include:

Secure HttpOnly SameSite

32. HTTP Is Stateless

HTTP request/response interactions are generally stateless.

For example:

Request 1 Request 2 Request 3

Each request can be handled independently at the protocol level.

Applications can add state using:

Cookies Sessions Tokens Databases

So:

HTTP is stateless, but web applications can maintain state.

33. HTTP Persistent Connections

Older HTTP/1.0 usage often involved a new TCP connection per request unless keep-alive behavior was used.

HTTP/1.1 made persistent connections the normal behavior.

Conceptually:

TCP Connection │ ├── HTTP Request ├── HTTP Response ├── HTTP Request └── HTTP Response

This reduces connection-establishment overhead.

34. HTTP/1.0

HTTP/1.0 was an early widely deployed HTTP version.

A simplified model was:

TCP connection ↓ Request ↓ Response ↓ Connection may close

Persistent connections could also be used through mechanisms available in implementations.

35. HTTP/1.1

HTTP/1.1 introduced/improved important capabilities including:

  • Persistent connections
  • Host header requirements
  • Chunked transfer encoding
  • Better caching controls
  • More flexible request methods and semantics

Example:

GET / HTTP/1.1 Host: example.com

36. HTTP/2

HTTP/2 significantly improved how HTTP messages are transported.

Instead of treating every request as an independent textual exchange over the wire, HTTP/2 uses a binary framing layer.

Important features include:

  • Binary framing
  • Multiplexing
  • Stream prioritization mechanisms
  • Header compression using HPACK
  • One connection carrying multiple concurrent streams

Conceptually:

One TCP connection │ ┌──────┼─────────┐ ↓ ↓ ↓ Stream 1 Stream 2 Stream 3 HTML CSS API

This helps reduce some problems associated with HTTP/1.1.

37. HTTP/3

HTTP/3 is the newest major HTTP version.

It uses:

HTTP/3 ↓ QUIC ↓ UDP ↓ IP

Instead of:

HTTP/2 ↓ TCP

QUIC provides transport functionality including reliable streams, congestion control, and encryption integration.

38. HTTP Version Comparison

FeatureHTTP/1.1HTTP/2HTTP/3
Common transportTCPTCPUDP
Binary framingNoYesYes
MultiplexingLimitedYesYes
Header compressionNo HPACKHPACKQPACK
Encryption required by protocolNoNoYes, via QUIC
TransportTCPTCPQUIC
Typical secure port443443443

39. HTTP vs HTTPS Architecture

HTTP

Browser ↓ HTTP ↓ TCP ↓ IP

Common port:

TCP 80

Data is not cryptographically protected by HTTP itself.

HTTPS with HTTP/1.1 or HTTP/2

Browser ↓ HTTP ↓ TLS ↓ TCP ↓ IP

Common port:

TCP 443

HTTPS with HTTP/3

Browser ↓ HTTP/3 ↓ QUIC ↓ UDP ↓ IP

Common port:

UDP 443

This is an important modern networking detail.

40. What Does HTTPS Actually Protect?

HTTPS provides three major security properties.

1. Confidentiality

Encryption prevents ordinary network observers from reading the protected application data.

Without HTTPS:

Client │ │ username=abc │ password=123 ↓ Network

A network observer could potentially read unencrypted traffic.

With HTTPS:

Client │ │ Encrypted data ↓ Network │ └── Cannot normally read HTTP contents

41. Integrity

HTTPS/TLS helps detect unauthorized modification of protected data in transit.

Without protection:

Client → Data → Server ↑ Modification

With TLS:

Client ═══ Protected Data ═══ Server

An attacker cannot normally modify the protected data without detection.

42. Authentication

HTTPS normally uses digital certificates to authenticate the server's domain identity.

Simplified:

Browser │ │ "Prove you are example.com" ↓ Server │ │ Certificate ↓ Browser validates certificate

The certificate is generally issued through a trusted certificate authority (CA) ecosystem.

43. TLS Certificate

A certificate can contain information such as:

Domain names Public key Issuer Validity period Signature

For example:

example.com ↓ Certificate ↓ Public Key ↓ CA Signature

The browser validates the certificate chain against its trusted roots and checks relevant properties such as hostname and validity.

44. HTTPS Does Not Hide Everything

A common misconception is:

"HTTPS hides everything."

Not exactly.

TLS protects application data, but network observers can still learn some metadata.

Depending on the protocol, configuration, and technology, observers may see information such as:

Source IP Destination IP Traffic timing Traffic volume

Traditional DNS may also reveal the domain being queried unless encrypted DNS is used.

Modern technologies such as TLS 1.3 and encrypted ClientHello can reduce some metadata exposure, but HTTPS does not make a device invisible on the network.

45. HTTP Example

Suppose you visit:

http://example.com

The browser might send:

GET / HTTP/1.1 Host: example.com

The server responds:

HTTP/1.1 200 OK Content-Type: text/html <html> ... </html>

With plain HTTP, this content is not encrypted by HTTP itself.

46. HTTPS Example

You visit:

https://example.com

Conceptually:

Browser │ ├── TCP connection │ ├── TLS handshake │ └── Encrypted HTTP communication

The HTTP request still exists conceptually:

GET / HTTP/1.1 Host: example.com

But it is carried inside the encrypted TLS connection rather than sent as readable HTTP on the network.

47. HTTPS Handshake — Simplified

For traditional HTTPS over TCP:

Client Server │ │ │──── TCP SYN ────────────────>│ │<─── TCP SYN-ACK ─────────────│ │──── TCP ACK ────────────────>│ │ │ │──── TLS Handshake ─────────>│ │<─── TLS Handshake ──────────│ │ │ │════ Encrypted HTTP ═════════│

Modern TLS 1.3 generally reduces handshake latency compared with older TLS versions.

48. TLS 1.3 Conceptually

TLS 1.3 establishes:

  • Secure cryptographic keys
  • Server authentication
  • Encrypted communication
  • Integrity protection

Simplified:

Client │ │ ClientHello ↓ Server │ │ ServerHello + Certificate + ... ↓ Client │ │ Encrypted application data ↓ Server

The exact handshake contains more details and cryptographic steps.

49. HTTPS Encryption

HTTPS uses symmetric encryption for bulk application data after the secure session is established.

Public-key cryptography is used as part of the handshake/authentication process, while symmetric keys are then used efficiently for ongoing encrypted communication.

Conceptually:

TLS Handshake ↓ Establish shared session keys ↓ Symmetric encryption ↓ HTTP data

This combination provides both secure establishment and efficient data encryption.

50. HTTP Redirect to HTTPS

Many websites redirect:

http://example.com

to:

https://example.com

For example:

Client │ │ HTTP request ↓ Server │ │ 301/308 │ Location: https://example.com ↓ Client │ │ HTTPS request ↓ Server

But the initial HTTP request itself was not protected.

For stronger protection against downgrade/initial HTTP exposure, sites can use HSTS.

51. HSTS

HSTS = HTTP Strict Transport Security

A website can tell browsers:

"Use HTTPS for this domain."

Example response header:

Strict-Transport-Security: max-age=31536000

The browser can then enforce HTTPS for future requests according to the policy.

52. HTTP Caching

HTTP supports caching.

Example:

Browser │ │ Request ↓ Server │ │ Response ↓ Browser Cache

Later:

Browser ↓ Cache ↓ Use cached resource

This can improve:

  • Speed
  • Bandwidth usage
  • Server performance

53. Cache-Control

Example:

Cache-Control: max-age=3600

This provides caching instructions.

Other directives include:

no-cache no-store private public max-age must-revalidate

These have specific semantics and should not be treated as simple "cache yes/no" switches.

54. HTTP ETag

An ETag identifies a particular representation of a resource.

Example:

ETag: "abc123"

The browser can later send:

If-None-Match: "abc123"

If the resource hasn't changed, the server may respond:

304 Not Modified

This saves bandwidth.

55. HTTP Cookies and Sessions

A common login flow:

Browser │ │ POST /login ↓ Server │ │ Set-Cookie ↓ Browser

Later:

Browser │ │ Cookie ↓ Server │ │ Identify session ↓ Response

HTTPS is especially important for protecting session cookies while they travel across networks.

56. HTTP and APIs

HTTP is not only for web pages.

It is widely used for APIs.

Example:

GET /api/users/10 HTTP/1.1 Host: api.example.com Accept: application/json

Response:

HTTP/1.1 200 OK Content-Type: application/json { "id": 10, "name": "User" }

Modern applications commonly use:

Web App Mobile App ESP32/IoT device Backend

communicating through HTTP-based APIs.

57. HTTP and REST APIs

REST-style APIs commonly use:

GET → Read POST → Create/submit PUT → Replace PATCH → Partial update DELETE → Delete

Example:

GET /api/products POST /api/products GET /api/products/10 PATCH /api/products/10 DELETE /api/products/10

This is a convention, not a requirement that every HTTP API must follow.

58. HTTP and IoT

Your ESP32 can communicate with a web server using HTTP.

Example:

ESP32 │ │ HTTP POST ↓ Web API │ ↓ Database

ESP32 might send:

{ "temperature": 28.5, "humidity": 62 }

The server responds:

{ "status": "success" }

For simple IoT projects, HTTP is easy to understand and integrate.

For lightweight publish/subscribe IoT communication, MQTT is often a better fit.

59. HTTP vs MQTT for IoT

HTTPMQTT
Request-responsePublish-subscribe
Larger overheadLightweight
Client requests dataBroker distributes messages
Good for APIs/web servicesExcellent for telemetry
Commonly TCP/TLSCommonly TCP/TLS
Easy web integrationExcellent IoT messaging model

60. HTTP Security Problems

Plain HTTP can expose sensitive information.

Example:

Username Password Session Cookie Personal Data

If transmitted without encryption:

Client │ │ Plain HTTP ↓ Network │ └── Potential interception

This is why sensitive websites should use HTTPS.

61. HTTPS Security Limitations

HTTPS is extremely important, but it doesn't solve every security problem.

HTTPS does not automatically protect against:

  • SQL injection
  • XSS
  • CSRF
  • Broken authentication
  • Weak passwords
  • Server vulnerabilities
  • Malicious JavaScript
  • Compromised servers
  • Phishing

For example:

https://fake-bank.example

can still be a malicious website.

The connection can be securely encrypted while the website itself is malicious.

62. HTTP Request in Browser Developer Tools

In a browser, you can inspect HTTP traffic through:

Developer Tools ↓ Network

You can see:

Request URL Method Status Code Request Headers Response Headers Cookies Payload Timing

For example:

GET /api/users Status: 200 Content-Type: application/json

This is very useful for web development and cybersecurity learning.

63. HTTP with curl

You can inspect a website using:

curl -I https://example.com

-I requests headers only.

You might see:

HTTP/2 200 content-type: text/html server: ...

To make a normal request:

curl https://example.com

To show request/response details:

curl -v https://example.com

Use these against systems you are authorized to access.

64. HTTP with Nmap

For authorized systems, Nmap can help identify HTTP services.

For example:

nmap -p 80,443 example.com

You can also use service detection:

nmap -sV -p 80,443 example.com

This can help identify what services are exposed.

65. HTTP vs HTTPS — Security View

HTTP │ ├── No TLS encryption ├── Data can potentially be read ├── Data can potentially be modified └── No TLS server authentication

HTTPS:

HTTPS │ ├── HTTP │ └── TLS │ ├── Confidentiality ├── Integrity └── Authentication

66. Complete Web Communication

Traditional HTTPS with HTTP/2:

Browser │ │ HTTP ↓ TLS │ ↓ TCP │ ↓ IP │ ↓ Wi-Fi/Ethernet │ ↓ Internet │ ↓ Server

HTTP/3:

Browser │ HTTP/3 ↓ QUIC ↓ UDP ↓ IP ↓ Internet ↓ Server

67. HTTP vs HTTPS vs TCP vs UDP

These protocols have different roles.

HTTP/HTTPS ↓ Application Layer TCP/UDP/QUIC ↓ Transport Layer IP ↓ Internet/Network Layer

For traditional HTTPS:

HTTPS ↓ TLS ↓ TCP ↓ IP

For HTTP/3:

HTTP/3 ↓ QUIC ↓ UDP ↓ IP

68. Important Ports

Remember:

HTTP TCP 80 HTTPS TCP 443

For HTTP/3:

HTTP/3 UDP 443

So:

Port 443 can carry HTTPS over TCP or HTTP/3 over UDP, depending on the protocol being used.

69. HTTP Request-Response Example

CLIENT │ │ │ GET /index.html │ ↓ SERVER │ │ │ 200 OK │ Content-Type: text/html │ ↓ CLIENT

70. HTTPS Request-Response Example

CLIENT │ │ TLS handshake ↓ SERVER │ │ Secure session established ↓ CLIENT │ │ Encrypted HTTP request ↓ SERVER │ │ Encrypted HTTP response ↓ CLIENT

71. Most Important HTTP Methods

GET ↓ Read/retrieve POST ↓ Submit/create/process PUT ↓ Replace PATCH ↓ Partial update DELETE ↓ Delete

72. Most Important Status Codes

200 → OK 201 → Created 204 → No Content 301 → Permanent Redirect 302 → Redirect 304 → Not Modified 400 → Bad Request 401 → Authentication required/failed 403 → Forbidden 404 → Not Found 405 → Method Not Allowed 429 → Too Many Requests 500 → Internal Server Error 502 → Bad Gateway 503 → Service Unavailable 504 → Gateway Timeout

73. Final Revision Table

ConceptHTTPHTTPS
PurposeWeb communicationSecure web communication
Application layerYesYes
Encryption❌✅ TLS
Integrity❌ Cryptographic integrity not provided✅
Authentication❌✅ Server authentication via TLS certificates
Common portTCP 80TCP 443
HTTP/3❌HTTP/3 uses QUIC over UDP
Request/Response✅✅
Cookies✅✅
APIs✅✅
Secure login❌ Not appropriate✅

74. Key Things to Remember

HTTP │ ├── Application-layer protocol ├── Request/response ├── Methods │ ├── GET │ ├── POST │ ├── PUT │ ├── PATCH │ └── DELETE │ ├── Status codes │ ├── 2xx Success │ ├── 3xx Redirect │ ├── 4xx Client error │ └── 5xx Server error │ └── Commonly TCP 80 HTTPS │ ├── HTTP over TLS ├── Encryption ├── Integrity ├── Server authentication ├── Commonly TCP 443 └── HTTP/3 → QUIC → UDP 443

One-line exam answer

HTTP is an application-layer request-response protocol used for communication between web clients and servers, while HTTPS is HTTP protected by TLS, providing confidentiality, integrity, and server authentication.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy