<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: elshamah baraka</title>
    <description>The latest articles on DEV Community by elshamah baraka (@elshamah_baraka).</description>
    <link>https://dev.to/elshamah_baraka</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3934510%2F6a9782c4-ad5f-4d0d-a625-d930f7910865.png</url>
      <title>DEV Community: elshamah baraka</title>
      <link>https://dev.to/elshamah_baraka</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elshamah_baraka"/>
    <language>en</language>
    <item>
      <title># What Actually Happens When You Make an HTTP Request?</title>
      <dc:creator>elshamah baraka</dc:creator>
      <pubDate>Fri, 14 Aug 2026 13:58:39 +0000</pubDate>
      <link>https://dev.to/elshamah_baraka/-what-actually-happens-when-you-make-an-http-request-4la9</link>
      <guid>https://dev.to/elshamah_baraka/-what-actually-happens-when-you-make-an-http-request-4la9</guid>
      <description>&lt;p&gt;When we work with APIs, it's easy to think of a request as simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Server → Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But underneath that simple interaction is a lifecycle with several distinct stages.&lt;/p&gt;

&lt;p&gt;Understanding that lifecycle changed how I think about backend development.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The client creates the request
&lt;/h2&gt;

&lt;p&gt;Everything starts with the client deciding it needs something from a server.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/users/42&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;api.example.com&lt;/span&gt;
&lt;span class="na"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;application/json&lt;/span&gt;
&lt;span class="na"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Bearer &amp;lt;token&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An HTTP request can contain several pieces of information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Method — what operation is being requested&lt;/li&gt;
&lt;li&gt;URL — which resource is being targeted&lt;/li&gt;
&lt;li&gt;Headers — metadata and instructions&lt;/li&gt;
&lt;li&gt;Body — data sent to the server, when applicable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a &lt;code&gt;GET&lt;/code&gt;, there is typically no request body.&lt;/p&gt;

&lt;p&gt;For something like &lt;code&gt;POST&lt;/code&gt;, the body might contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"John Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"john@example.com"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. The request travels to the server
&lt;/h2&gt;

&lt;p&gt;Before the application can process anything, the request has to reach the correct server.&lt;/p&gt;

&lt;p&gt;At a lower level, this involves networking concepts such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DNS
 ↓
TCP connection
 ↓
TLS (for HTTPS)
 ↓
HTTP request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one reason backend development isn't isolated from networking.&lt;/p&gt;

&lt;p&gt;The application may ultimately deal with an HTTP request object, but getting that request there involves several layers underneath.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The server receives and routes the request
&lt;/h2&gt;

&lt;p&gt;Once the request reaches the application server, the HTTP framework needs to determine what should handle it.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /users/42
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;might be matched against:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /users/:id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The router identifies the appropriate endpoint and extracts information such as the &lt;code&gt;id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Before the request reaches business logic, middleware may also run.&lt;/p&gt;

&lt;p&gt;Authentication, logging, rate limiting, CORS handling, and other cross-cutting concerns can happen here.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The request is validated
&lt;/h2&gt;

&lt;p&gt;The server shouldn't blindly trust incoming data.&lt;/p&gt;

&lt;p&gt;If a client sends:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"not-an-email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"twenty"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the API should detect that the request doesn't satisfy its contract.&lt;/p&gt;

&lt;p&gt;This is where validation and DTOs become important.&lt;/p&gt;

&lt;p&gt;A simplified flow might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
   ↓
Routing
   ↓
Middleware
   ↓
Validation
   ↓
Controller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal is to reject invalid input as close to the boundary as practical.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Business logic executes
&lt;/h2&gt;

&lt;p&gt;Once the request is valid, the application can perform the actual operation.&lt;/p&gt;

&lt;p&gt;A controller might delegate to a service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Controller
    ↓
Service
    ↓
Data Access
    ↓
Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation is important.&lt;/p&gt;

&lt;p&gt;The controller deals with the HTTP layer.&lt;/p&gt;

&lt;p&gt;The service deals with application/business logic.&lt;/p&gt;

&lt;p&gt;The data-access layer deals with persistence.&lt;/p&gt;

&lt;p&gt;Keeping those responsibilities separate makes the system easier to reason about and change.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The server creates a response
&lt;/h2&gt;

&lt;p&gt;After processing the request, the server constructs an HTTP response.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt; &lt;span class="ne"&gt;OK&lt;/span&gt;
&lt;span class="na"&gt;Content-Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;application/json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with a body such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"John Doe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"john@example.com"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response communicates more than just the data.&lt;/p&gt;

&lt;p&gt;The status code tells the client what happened.&lt;/p&gt;

&lt;p&gt;The headers provide metadata.&lt;/p&gt;

&lt;p&gt;The body contains the representation of the result.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200 → Successful request
201 → Resource created
400 → Invalid request
401 → Authentication required/failed
403 → Access forbidden
404 → Resource not found
500 → Server-side failure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. The client processes the response
&lt;/h2&gt;

&lt;p&gt;Finally, the response travels back to the client.&lt;/p&gt;

&lt;p&gt;The client can then use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the status code to determine the outcome&lt;/li&gt;
&lt;li&gt;the headers to understand metadata&lt;/li&gt;
&lt;li&gt;the body to access the returned representation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the lifecycle is complete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CLIENT
  ↓
HTTP REQUEST
  ↓
NETWORK
  ↓
SERVER
  ↓
ROUTING
  ↓
MIDDLEWARE / VALIDATION
  ↓
BUSINESS LOGIC
  ↓
DATA ACCESS
  ↓
HTTP RESPONSE
  ↓
CLIENT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The bigger insight
&lt;/h3&gt;

&lt;p&gt;The HTTP lifecycle is more than a sequence of technical steps.&lt;/p&gt;

&lt;p&gt;It explains &lt;strong&gt;where responsibilities belong&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Networking gets the request to the server.&lt;/p&gt;

&lt;p&gt;Routing determines where it goes.&lt;/p&gt;

&lt;p&gt;Middleware handles cross-cutting concerns.&lt;/p&gt;

&lt;p&gt;Validation protects the application boundary.&lt;/p&gt;

&lt;p&gt;Business logic determines what should happen.&lt;/p&gt;

&lt;p&gt;Data access handles persistence.&lt;/p&gt;

&lt;p&gt;The HTTP response communicates the result back to the client.&lt;/p&gt;

&lt;p&gt;Once you understand that flow, frameworks like Express, FastAPI, Django, Spring, or ASP.NET start to feel less like collections of framework-specific features.&lt;/p&gt;

&lt;p&gt;They're different implementations built around the same fundamental request/response model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The framework may change. The lifecycle doesn't.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that's one of the most useful mental models to have when building backend systems.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
