Bird
Raised Fist0
Interview Prepcomputer-networkseasyAmazonGoogleMicrosoftFlipkartSwiggyRazorpayZepto

HTTP Methods - GET, POST, PUT, PATCH, DELETE & Idempotency

Choose your preparation mode3 modes available
▶
Steps
setup

Client prepares GET request

The client constructs an HTTP GET request packet to retrieve data from the server.

💡 This step shows how a simple GET request is formed before sending, establishing the starting point of communication.
Line:request = HTTPRequest(method='GET', url='/resource')
💡 Understanding the initial request setup is crucial to follow the packet flow.
📊
HTTP Methods - GET, POST, PUT, PATCH, DELETE & Idempotency - Watch the Algorithm Execute, Step by Step
Watching each HTTP method's request and response flow helps you understand the fundamental differences and the concept of idempotency in HTTP.
Step 1/20
·Active fill★Answer cell
Client prepares GET request packet.
Hop: 0
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→GET /resource HTTP/1.1
Packet is in transit from client to server.
Hop: 1
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadGET /resource HTTP/1.1
🔌 protocolHTTP
🚩 flags
src→192.168.1.2:12345
dst→192.168.1.10:80
data→GET /resource HTTP/1.1
GET: client→server (request)
Server is processing GET request.
Hop: 1
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→GET /resource HTTP/1.1
GET: client→server (request)
Server sends response packet to client.
Hop: 2
Client
Server
📦Packet
↗ fromserver
↘ toclient
📄 payloadHTTP/1.1 200 OK Content: resource data
🔌 protocolHTTP
🚩 flags
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 200 OK Content: resource data
GET: client→server (request)
200 OK: server→client (response)
Client processes response data.
Hop: 2
Client
Server
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 200 OK Content: resource data
GET: client→server (request)
200 OK: server→client (response)
Client prepares POST request packet.
Hop: 0
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→POST /resource HTTP/1.1 Body: new data
GET: client→server (request)
200 OK: server→client (response)
POST request packet is in transit.
Hop: 1
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadPOST /resource HTTP/1.1 Body: new data
🔌 protocolHTTP
🚩 flags
src→192.168.1.2:12345
dst→192.168.1.10:80
data→POST /resource HTTP/1.1 Body: new data
GET: client→server (request)
200 OK: server→client (response)
POST: client→server (request)
Server processes POST request and updates resource.
Hop: 1
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→POST /resource HTTP/1.1 Body: new data
GET: client→server (request)
200 OK: server→client (response)
POST: client→server (request)
Server sends POST response to client.
Hop: 2
Client
Server
📦Packet
↗ fromserver
↘ toclient
📄 payloadHTTP/1.1 201 Created
🔌 protocolHTTP
🚩 flags
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 201 Created
200 OK: server→client (response)
POST: client→server (request)
201 Created: server→client (response)
Client processes POST response.
Hop: 2
Client
Server
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 201 Created
200 OK: server→client (response)
POST: client→server (request)
201 Created: server→client (response)
Client prepares PUT request packet.
Hop: 0
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→PUT /resource HTTP/1.1 Body: updated data
200 OK: server→client (response)
POST: client→server (request)
201 Created: server→client (response)
PUT request packet is in transit.
Hop: 1
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadPUT /resource HTTP/1.1 Body: updated data
🔌 protocolHTTP
🚩 flags
src→192.168.1.2:12345
dst→192.168.1.10:80
data→PUT /resource HTTP/1.1 Body: updated data
POST: client→server (request)
201 Created: server→client (response)
PUT: client→server (request)
Server processes PUT request and updates resource.
Hop: 1
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→PUT /resource HTTP/1.1 Body: updated data
POST: client→server (request)
201 Created: server→client (response)
PUT: client→server (request)
Server sends PUT response to client.
Hop: 2
Client
Server
📦Packet
↗ fromserver
↘ toclient
📄 payloadHTTP/1.1 200 OK
🔌 protocolHTTP
🚩 flags
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 200 OK
201 Created: server→client (response)
PUT: client→server (request)
200 OK: server→client (response)
Client processes PUT response.
Hop: 2
Client
Server
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 200 OK
201 Created: server→client (response)
PUT: client→server (request)
200 OK: server→client (response)
Client prepares DELETE request packet.
Hop: 0
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→DELETE /resource HTTP/1.1
201 Created: server→client (response)
PUT: client→server (request)
200 OK: server→client (response)
DELETE request packet is in transit.
Hop: 1
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadDELETE /resource HTTP/1.1
🔌 protocolHTTP
🚩 flags
src→192.168.1.2:12345
dst→192.168.1.10:80
data→DELETE /resource HTTP/1.1
PUT: client→server (request)
200 OK: server→client (response)
DELETE: client→server (request)
Server processes DELETE request and removes resource.
Hop: 1
Client
Server
src→192.168.1.2:12345
dst→192.168.1.10:80
data→DELETE /resource HTTP/1.1
PUT: client→server (request)
200 OK: server→client (response)
DELETE: client→server (request)
Server sends DELETE response to client.
Hop: 2
Client
Server
📦Packet
↗ fromserver
↘ toclient
📄 payloadHTTP/1.1 200 OK
🔌 protocolHTTP
🚩 flags
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 200 OK
200 OK: server→client (response)
DELETE: client→server (request)
200 OK: server→client (response)
Client processes DELETE response.
Hop: 2
Client
Server
src→192.168.1.10:80
dst→192.168.1.2:12345
data→HTTP/1.1 200 OK
200 OK: server→client (response)
DELETE: client→server (request)
200 OK: server→client (response)

Key Takeaways

✓ HTTP methods differ in how they affect server state and idempotency.

Reading code alone doesn't clearly show how repeated requests behave differently; watching packet flows clarifies this.

✓ GET requests retrieve data without side effects, while POST requests submit data and are not idempotent.

Visualizing the request and response packets helps understand why POST can cause multiple changes if repeated.

✓ PUT and DELETE methods are idempotent, meaning repeated identical requests result in the same server state.

Seeing the packet flow and server processing steps highlights the idempotency concept concretely.

Practice

(1/5)
1. Why might DHCP not be suitable for assigning IP addresses in a network with extremely high client churn and very short connection durations?
medium
A. Because the overhead of frequent DHCP Discover and Request messages can cause network congestion
B. Because DHCP cannot assign IP addresses dynamically in such environments
C. Because DHCP servers do not support IP address leasing
D. Because clients must manually configure IP addresses in such cases

Solution

  1. Step 1: Understand DHCP overhead

    Each new client connection triggers the DORA sequence, which adds network traffic.
  2. Step 2: Analyze impact of high churn

    Frequent IP requests can overload the DHCP server and increase broadcast traffic, causing congestion.
  3. Step 3: Evaluate other options

    Because DHCP cannot assign IP addresses dynamically in such environments is false; DHCP is designed for dynamic assignment. Because DHCP servers do not support IP address leasing is incorrect; DHCP supports leasing. Because clients must manually configure IP addresses in such cases is unrelated to DHCP limitations.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    High churn leads to excessive DHCP message overhead.
Hint: High churn -> many DHCP messages -> potential congestion
Common Mistakes:
  • Believing DHCP cannot assign dynamically in such cases
  • Confusing DHCP leasing with static assignment
  • Assuming manual configuration is required when DHCP is unsuitable
2. Which of the following statements about subnet masks is INCORRECT?
medium
A. A subnet mask separates the network and host portions of an IP address by masking bits
B. The subnet mask must always be contiguous ones followed by zeros in binary
C. Changing the subnet mask does not affect the total number of IP addresses in the network
D. Subnet masks can be represented in dotted decimal or CIDR notation

Solution

  1. Step 1: Review subnet mask function

    Subnet masks define network and host bits, affecting subnet size and number of IP addresses.
  2. Step 2: Analyze each statement

    A subnet mask separates the network and host portions of an IP address by masking bits is true; subnet masks separate network and host bits. The subnet mask must always be contiguous ones followed by zeros in binary is true; subnet masks must be contiguous ones then zeros. Subnet masks can be represented in dotted decimal or CIDR notation is true; subnet masks can be in dotted decimal or CIDR.
  3. Step 3: Identify incorrect statement

    Changing the subnet mask does not affect the total number of IP addresses in the network is false; changing subnet mask changes subnet size and total IP addresses available.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Subnet mask directly impacts number of IP addresses in a subnet [OK]
Hint: Subnet mask length controls subnet size and IP count
Common Mistakes:
  • Believing subnet masks can have non-contiguous bits
  • Thinking subnet mask changes don't affect IP count
  • Confusing subnet mask notation formats
3. In a network where ARP spoofing attacks are frequent, which advanced mitigation technique can be employed to detect and prevent such attacks beyond static ARP entries?
hard
A. Implementing dynamic ARP inspection (DAI) on switches to validate ARP packets against a trusted database.
B. Disabling ARP entirely and relying solely on IP addresses for communication.
C. Using DHCP snooping to assign static IP addresses to all devices.
D. Increasing the ARP cache timeout to reduce ARP traffic.

Solution

  1. Step 1: Understand advanced ARP spoofing mitigation

    Dynamic ARP Inspection (DAI) is a security feature on switches that intercepts ARP packets and verifies them against a trusted binding database.
  2. Step 2: Why not disabling ARP?

    ARP is essential for IP-to-MAC resolution; disabling it breaks local communication.
  3. Step 3: DHCP snooping is complementary but not sufficient

    DHCP snooping helps build trusted bindings but does not directly inspect ARP packets.
  4. Step 4: Increasing ARP cache timeout worsens spoofing risk

    Longer cache times mean stale or poisoned entries persist longer.
  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    DAI validates ARP packets to prevent spoofing effectively [OK]
Hint: DAI inspects ARP packets dynamically to prevent spoofing [OK]
Common Mistakes:
  • Thinking ARP can be disabled safely
  • Confusing DHCP snooping with ARP inspection
  • Believing longer ARP cache timeout improves security
4. If a TCP connection experiences frequent packet loss but the receiver's advertised window remains large, which adjustment should the sender prioritize to improve throughput?
hard
A. Increase retransmission timeout to avoid premature retransmissions
B. Decrease the receiver's advertised window to slow down sending rate
C. Ignore congestion signals and rely solely on sliding window flow control
D. Reduce congestion window size according to AIMD to alleviate network congestion

Solution

  1. Step 1: Analyze the scenario

    Large receiver window means flow control is not limiting sender; packet loss indicates network congestion.
  2. Step 2: Identify correct sender adjustment

    Sender should reduce congestion window per AIMD to reduce congestion and improve throughput.
  3. Step 3: Reject decreasing receiver window

    Sender cannot control receiver's advertised window; it's a receiver-side parameter.
  4. Step 4: Reject ignoring congestion or increasing timeout

    Ignoring congestion worsens loss; increasing timeout delays recovery, not throughput improvement.
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    Congestion control adjusts sending rate; flow control limits receiver buffer usage.
Hint: When receiver window is large but loss occurs, adjust congestion window, not flow control.
Common Mistakes:
  • Confusing flow control with congestion control adjustments
  • Thinking sender can reduce receiver window
  • Believing retransmission timeout tuning solves congestion
5. If a new network protocol requires encryption and compression before data transmission, which TCP/IP model layer would be the best place to implement these features to maintain compatibility and efficiency?
hard
A. Network Interface Layer, since it deals with physical transmission
B. Transport Layer, because it manages data segmentation and reliability
C. Internet Layer, as it routes packets across networks
D. Application Layer, since it handles end-user protocols and data formatting

Solution

  1. Step 1: Identify layer responsibilities relevant to encryption and compression

    Encryption and compression are data transformations related to how data is presented and formatted for applications, which fits the Application Layer's role in TCP/IP (combining OSI's Application, Presentation, and Session layers).
  2. Step 2: Why not other layers?

    Transport Layer manages segmentation and reliability, not data formatting. Internet Layer handles routing, not data content. Network Interface Layer deals with physical transmission, not data processing.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Application Layer is the correct place for encryption/compression to maintain compatibility [OK]
Hint: Encryption/compression belong at Application Layer in TCP/IP
Common Mistakes:
  • Placing encryption at Transport Layer (confusing with TLS)
  • Thinking Internet Layer handles data content
  • Assuming Network Interface Layer manages data transformations
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard