<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[DecodeWithRish]]></title><description><![CDATA[A space where I decode the building blocks of software, one byte at a time. Notes, thoughts, and insights from my raw, curious journey through computer science ]]></description><link>https://decodewithrish.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 20:36:22 GMT</lastBuildDate><atom:link href="https://decodewithrish.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[🥘 Understanding the Ingredients of APIs: Requests, Responses & Headers]]></title><description><![CDATA[Intro
This is the start of a series where I learn backend concepts step by step and write them down.
I don’t want to just “use” APIs, I want to see what’s really going on when a client and server talk to each other.Before I touch databases or framewo...]]></description><link>https://decodewithrish.hashnode.dev/understanding-the-ingredients-of-apis-requests-responses-and-headers</link><guid isPermaLink="true">https://decodewithrish.hashnode.dev/understanding-the-ingredients-of-apis-requests-responses-and-headers</guid><category><![CDATA[APIs]]></category><category><![CDATA[http]]></category><category><![CDATA[backend]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[Client-side rendering]]></category><category><![CDATA[developer-journey]]></category><category><![CDATA[basics]]></category><category><![CDATA[Computer Science]]></category><dc:creator><![CDATA[Yerragogu Rishitha]]></dc:creator><pubDate>Wed, 17 Sep 2025 11:22:34 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-intro">Intro</h2>
<p>This is the start of a series where I learn backend concepts step by step and write them down.</p>
<p>I don’t want to just “use” APIs, I want to see what’s really going on when a client and server talk to each other.<br />Before I touch databases or frameworks, I need to understand the basics: requests, responses, headers, status codes, tools like Postman and curl.</p>
<p>This first post is that groundwork. Think of it as the “ingredients check” before we start building APIs.</p>
<h2 id="heading-clientserver-and-how-http-makes-it-work">Client–Server and How HTTP Makes It Work</h2>
<p>When we talk about APIs, we’re really talking about <strong>how clients and servers communicate</strong>.</p>
<ul>
<li><p><strong>Client</strong> → anything that sends a request (browser, Postman, curl).</p>
</li>
<li><p><strong>Server</strong> → anything that listens for requests and sends responses (Node.js server, public API, etc.).</p>
</li>
</ul>
<p>Every action — fetching a webpage, hitting an API, sending data — follows this pattern:</p>
<pre><code class="lang-powershell">Client  ---&gt;  Request  ---&gt;  Server
Client  &lt;---  Response &lt;---  Server
</code></pre>
<h3 id="heading-why-http">Why HTTP?</h3>
<p>APIs work over <strong>HTTP (Hypertext Transfer Protocol)</strong> — the “language” clients and servers use to talk to each other.</p>
<p>Without HTTP:</p>
<ul>
<li><p>Clients wouldn’t know how to format requests.</p>
</li>
<li><p>Servers wouldn’t know how to interpret them.</p>
</li>
</ul>
<p>HTTP gives structure to every message:</p>
<ol>
<li><p><strong>Request line</strong> → what the client wants (method + path + version)</p>
</li>
<li><p><strong>Headers</strong> → extra information about the client, format, auth, versioning</p>
</li>
<li><p><strong>Body</strong> → optional data being sent (for POST/PUT/PATCH)</p>
</li>
</ol>
<p>The server responds similarly:</p>
<ol>
<li><p><strong>Status line</strong> → did it succeed or fail?</p>
</li>
<li><p><strong>Headers</strong> → info about the response (format, caching, encoding)</p>
</li>
<li><p><strong>Body</strong> → the data itself</p>
</li>
</ol>
<p>💡 HTTP is the <strong>protocol that enforces this structure</strong>. Every API you interact with, whether a joke API or Twitter’s API, follows these rules.</p>
<h2 id="heading-anatomy-of-an-http-request-and-response-hands-on-with-a-joke-api">Anatomy of an HTTP Request and Response (Hands-On with a Joke API)</h2>
<p>Enough theory — let’s see it live. Open your terminal or PowerShell and run:</p>
<pre><code class="lang-plaintext">curl -v https://official-joke-api.appspot.com/random_joke
</code></pre>
<blockquote>
<p><code>-v</code> stands for verbose — it shows the full request and response, including headers, status codes, and the body.</p>
</blockquote>
<p>what actually happens behind the scenes is that <strong>curl builds a full HTTP request</strong> for you. The first line of that request — the <strong>request line</strong> — looks like this:</p>
<pre><code class="lang-plaintext">GET /random_joke HTTP/1.1
</code></pre>
<p>Here’s how curl translates your simple command:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Part</td><td>Explanation</td></tr>
</thead>
<tbody>
<tr>
<td><code>GET</code></td><td>HTTP method — tells the server what action you want.</td></tr>
<tr>
<td><code>/random_joke</code></td><td>Endpoint/resource path — the API route you’re requesting.</td></tr>
<tr>
<td><code>HTTP/1.1</code></td><td>Protocol version — curl defaults to 1.1 unless you specify otherwise.</td></tr>
</tbody>
</table>
</div><p>💡 So your one-liner curl command becomes a <strong>structured HTTP request</strong> that the server can understand.</p>
<h3 id="heading-common-http-methods">Common HTTP Methods</h3>
<p>HTTP defines several methods to indicate what kind of operation the client wants to perform. Here’s a quick rundown:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Method</td><td>Purpose</td></tr>
</thead>
<tbody>
<tr>
<td><strong>GET</strong></td><td>Retrieve data from the server (like our joke). No body.</td></tr>
<tr>
<td><strong>POST</strong></td><td>Send data to the server to create a new resource (body required).</td></tr>
<tr>
<td><strong>PUT</strong></td><td>Update an existing resource completely.</td></tr>
<tr>
<td><strong>PATCH</strong></td><td>Update part of an existing resource.</td></tr>
<tr>
<td><strong>DELETE</strong></td><td>Remove a resource.</td></tr>
<tr>
<td><strong>HEAD</strong></td><td>Same as GET but only fetch headers, no body.</td></tr>
<tr>
<td><strong>OPTIONS</strong></td><td>Ask the server which methods and headers it supports.</td></tr>
</tbody>
</table>
</div><h2 id="heading-http-request-headers-the-invisible-instructions">HTTP Request Headers — The Invisible Instructions</h2>
<p>When you make an HTTP request, whether via curl, Postman, or a browser, your request isn’t just a method and a URL. It carries <strong>headers</strong>, which are like little instructions telling the server <em>“here’s who I am, what I want, and how to handle me.”</em></p>
<p>For example, when you ran:</p>
<pre><code class="lang-plaintext">curl -v https://official-joke-api.appspot.com/random_joke
</code></pre>
<p>you probably saw lines like:</p>
<pre><code class="lang-plaintext">Host: official-joke-api.appspot.com
User-Agent: curl/7.88.1
Accept: */*
</code></pre>
<ul>
<li><p><strong>Host</strong> is mandatory for HTTP/1.1. It tells the server which domain you’re hitting — super important if the server hosts multiple sites.</p>
</li>
<li><p><strong>User-Agent</strong> identifies your client. Curl, Postman, and browsers all leave a signature here. Some servers even respond differently depending on who’s asking.</p>
</li>
<li><p><strong>Accept</strong> is a polite request saying, <em>“I can handle JSON, HTML, or whatever you send.”</em> Curl defaults to <code>*/*</code> (anything goes).</p>
</li>
</ul>
<p>Most of these headers are added <strong>automatically</strong>. You don’t have to type them, but sometimes you want to <strong>control the headers yourself</strong>.</p>
<ul>
<li><p><strong>API Version:</strong> (<code>Accept-Version: v1</code>)<br />  Lets you specify which version of the API you want. Great for evolving the backend without breaking older clients.</p>
</li>
<li><p><strong>Authorization:</strong> (<code>Authorization: Bearer &lt;token&gt;</code>)<br />  Used for protected endpoints. Tells the server you’re authenticated. Works with JWTs, API keys, or OAuth tokens.</p>
</li>
<li><p><strong>Content-Type:</strong> (<code>Content-Type: application/json</code>)<br />  Specifies the format of the request body for POST or PUT requests. Curl/Postman automatically sets <code>Content-Length</code> (size of the body in bytes).</p>
</li>
<li><p><strong>Accept-Encoding:</strong> (<code>Accept-Encoding: gzip, deflate, br</code>)<br />  Tells the server which compression formats you support. Saves bandwidth and speeds up responses.</p>
</li>
<li><p><strong>Cookie:</strong> (<code>Cookie: sessionId=abc123</code>)<br />  Maintains session information between requests.</p>
</li>
<li><p><strong>Caching Headers:</strong> (<code>If-None-Match: "etag-value"</code>, <code>If-Modified-Since: Wed, 17 Sep 2025 00:00:00 GMT</code>)<br />  Lets the server respond with <code>304 Not Modified</code> if the resource hasn’t changed — caching magic.</p>
</li>
<li><p><strong>Custom Headers:</strong> (<code>X-Request-ID: 123e4567-e89b-12d3-a456-426614174000</code>)<br />  Track requests for debugging or logging. Many custom headers start with <code>X-</code> by convention.</p>
</li>
</ul>
<p>💡 <strong>Key idea:</strong> Headers don’t carry the main data — that’s the body — but they guide the server. They’re like polite instructions attached to your request, telling the server exactly how to handle it.</p>
<h2 id="heading-the-request-body-the-meat-of-your-request">The Request Body — The Meat of Your Request</h2>
<p>Headers tell the server <em>how</em> to handle your request, but the <strong>body is where the actual data lives</strong>. Think of it as the main message you’re sending, for methods like <code>POST</code>, <code>PUT</code>, or <code>PATCH</code>.</p>
<p>For a simple <code>GET</code> request like our joke API, there’s usually <strong>no body</strong> — the request line, headers, and optional query parameters are enough. But when you want to <strong>send data to the server</strong>, that’s when the body comes in.</p>
<h2 id="heading-what-happens-when-the-server-responds">What Happens When the Server Responds</h2>
<p>When you sent your joke API request, you probably got something like this in PowerShell:</p>
<pre><code class="lang-javascript">VERBOSE: GET <span class="hljs-keyword">with</span> <span class="hljs-number">0</span>-byte payload
<span class="hljs-attr">VERBOSE</span>: received <span class="hljs-number">148</span>-byte response <span class="hljs-keyword">of</span> content type application/json; charset=utf<span class="hljs-number">-8</span>

<span class="hljs-attr">StatusCode</span>        : <span class="hljs-number">200</span>
<span class="hljs-attr">StatusDescription</span> : OK
<span class="hljs-attr">Content</span>           : {<span class="hljs-string">"type"</span>:<span class="hljs-string">"programming"</span>,<span class="hljs-string">"setup"</span>:<span class="hljs-string">"There are 10 types of people in this world..."</span>,<span class="hljs-string">"punchline"</span>:<span class="hljs-string">"Those who understand binary and those who don't"</span>,<span class="hljs-string">"id"</span>:<span class="hljs-number">28</span>}
<span class="hljs-attr">RawContent</span>        : HTTP/<span class="hljs-number">1.1</span> <span class="hljs-number">200</span> OK
                    <span class="hljs-attr">vary</span>: Accept-Encoding
                    access-control-allow-origin: *
                    x-cloud-trace-context: <span class="hljs-number">7</span>fc1d0a29f554fa21ca36d8e2d363e83
                    Alt-Svc: h3=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>,h3<span class="hljs-number">-29</span>=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>
                    Content-Length...
Forms             : {}
<span class="hljs-attr">Headers</span>           : {[vary, Accept-Encoding], [access-control-allow-origin, *], [x-cloud-trace-context, <span class="hljs-number">7</span>fc1d0a29f554fa21ca36d8e2d363e83], [Alt-Svc, h3=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>,h3<span class="hljs-number">-29</span>=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>]...}
<span class="hljs-attr">Images</span>            : {}
<span class="hljs-attr">InputFields</span>       : {}
<span class="hljs-attr">Links</span>             : {}
<span class="hljs-attr">ParsedHtml</span>        : mshtml.HTMLDocumentClass
<span class="hljs-attr">RawContentLength</span>  : <span class="hljs-number">148</span>
</code></pre>
<p>At first glance, it’s a lot of info, but let’s break it down so it makes sense.</p>
<h3 id="heading-1-status-code-amp-description">1. Status Code &amp; Description</h3>
<pre><code class="lang-powershell">StatusCode        : <span class="hljs-number">200</span>
StatusDescription : OK
</code></pre>
<ul>
<li><p><code>200</code> is the <strong>HTTP status code</strong>, meaning your request was successful.</p>
</li>
<li><p><code>OK</code> is a human-readable description.</p>
</li>
</ul>
<p>Always check the status code first — it tells you if your request worked before eve</p>
<p>Some common status codes you’ll see when working with APIs:</p>
<ul>
<li><p><code>200 OK</code> → everything went well (GET, PUT).</p>
</li>
<li><p><code>201 Created</code> → something was successfully created (POST).</p>
</li>
<li><p><code>204 No Content</code> → action succeeded, but no body returned (DELETE).</p>
</li>
<li><p><code>400 Bad Request</code> → something was wrong with your request.</p>
</li>
<li><p><code>404 Not Found</code> → the requested resource doesn’t exist.</p>
</li>
<li><p><code>413 Payload Too Large</code> → your body was too big.</p>
</li>
<li><p><code>415 Unsupported Media Type</code> → your Content-Type isn’t supported.</p>
</li>
<li><p><code>500 Internal Server Error</code> → server failed to handle the request.n looking at the content.</p>
</li>
</ul>
<h3 id="heading-2-content-response-body">2. Content - Response Body</h3>
<p>The <strong>body</strong> contains the actual data you requested:</p>
<pre><code class="lang-powershell">{
  <span class="hljs-string">"type"</span>: <span class="hljs-string">"programming"</span>,
  <span class="hljs-string">"setup"</span>: <span class="hljs-string">"There are 10 types of people in this world..."</span>,
  <span class="hljs-string">"punchline"</span>: <span class="hljs-string">"Those who understand binary and those who don't"</span>,
  <span class="hljs-string">"id"</span>: <span class="hljs-number">28</span>
}
</code></pre>
<ul>
<li><p>This is where the joke lives!</p>
</li>
<li><p>GET requests usually return the resource.</p>
</li>
<li><p>POST or PUT might return the newly created resource.</p>
</li>
<li><p>DELETE often returns nothing (<code>204 No Content</code>).</p>
</li>
</ul>
<p>💡 <strong>Pro tip:</strong> The client parses the body based on <code>Content-Type</code>. JSON means parse as JSON, HTML means render HTML, etc. Mismatched types can break your app.</p>
<h3 id="heading-3-rawcontent">3. RawContent</h3>
<pre><code class="lang-powershell">RawContent        : HTTP/<span class="hljs-number">1.1</span> <span class="hljs-number">200</span> OK
                    vary: Accept<span class="hljs-literal">-Encoding</span>
                    access<span class="hljs-literal">-control</span><span class="hljs-literal">-allow</span><span class="hljs-literal">-origin</span>: *
                    x<span class="hljs-literal">-cloud</span><span class="hljs-literal">-trace</span><span class="hljs-literal">-context</span>: <span class="hljs-number">7</span>fc1d0a29f554fa21ca36d8e2d363e83
                    Alt<span class="hljs-literal">-Svc</span>: h3=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>,h3<span class="hljs-literal">-29</span>=<span class="hljs-string">":443"</span>; ma=<span class="hljs-number">2592000</span>
                    Content<span class="hljs-literal">-Length</span>...
</code></pre>
<ul>
<li><p>This shows the <strong>full raw HTTP response</strong>, exactly what the server sent over the network.</p>
</li>
<li><p>Includes the <strong>status line</strong> (<code>HTTP/1.1 200 OK</code>), all the <strong>response headers</strong>, and the body.</p>
</li>
</ul>
<h3 id="heading-4-headers">4. Headers</h3>
<p>Just like requests, responses have <strong>headers</strong> too. They carry <strong>metadata about the response</strong>, such as format, caching, and cookies:</p>
<p>for example</p>
<pre><code class="lang-powershell">Content<span class="hljs-literal">-Type</span>: application/json; charset=utf<span class="hljs-literal">-8</span>
Date: Tue, <span class="hljs-number">17</span> Sep <span class="hljs-number">2025</span> <span class="hljs-number">06</span>:<span class="hljs-number">10</span>:<span class="hljs-number">00</span> GMT
Cache<span class="hljs-literal">-Control</span>: no<span class="hljs-literal">-cache</span>
</code></pre>
<ul>
<li><p><strong>Content-Type</strong> → tells the client how to parse the body (JSON, HTML, text).</p>
</li>
<li><p><strong>Date</strong> → when the server processed the request.</p>
</li>
<li><p><strong>Cache-Control</strong> → caching instructions.</p>
</li>
</ul>
<hr />
<p><a target="_blank" href="https://www.postman.com/">Postman</a> is a free, beginner-friendly tool to <strong>send HTTP requests, inspect responses, and organize APIs</strong>. It makes testing APIs way easier than typing curl commands in the terminal and you can see everything in a clean, visual interface, so check it out.</p>
<blockquote>
<h3 id="heading-the-best-way-to-really-understand-apis-is-to-play-with-them-yourself">The best way to really understand APIs is to <strong>play with them yourself</strong>.</h3>
</blockquote>
<p>Here’s a list of <strong>fun and interesting APIs</strong> you can try right now: <a target="_blank" href="https://medium.com/codex/15-fun-and-interesting-apis-to-use-for-your-next-coding-project-in-2022-86a4ff3a2742">15 Fun and Interesting APIs to Use for Your Next Coding Project</a></p>
<p>From jokes and memes to space data and Pokémon info, these APIs are perfect for experimenting and <strong>learning by doing</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[🖥️ We’ve All Used localhost But Have You Ever Wondered How It Works?]]></title><description><![CDATA[We’ve all typed localhost to test our web apps.It’s almost like muscle memory at this point.
But only recently, I paused and thought:

“How does localhost actually work? Why does it magically know to point to my computer?”

Turns out, the answer is b...]]></description><link>https://decodewithrish.hashnode.dev/weve-all-used-localhost-but-have-you-ever-wondered-how-it-works</link><guid isPermaLink="true">https://decodewithrish.hashnode.dev/weve-all-used-localhost-but-have-you-ever-wondered-how-it-works</guid><category><![CDATA[localhost]]></category><category><![CDATA[networks]]></category><category><![CDATA[webdevelopment]]></category><category><![CDATA[operating system]]></category><category><![CDATA[#computernetwork ]]></category><category><![CDATA[Developer]]></category><category><![CDATA[dns]]></category><category><![CDATA[Learning Journey]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Yerragogu Rishitha]]></dc:creator><pubDate>Thu, 07 Aug 2025 11:49:25 GMT</pubDate><content:encoded><![CDATA[<p>We’ve all typed <a target="_blank" href="http://localhost"><code>localhost</code></a> to test our web apps.<br />It’s almost like muscle memory at this point.</p>
<p>But only recently, I paused and thought:</p>
<blockquote>
<p><em>“How does</em> <a target="_blank" href="http://localhost"><code>localhost</code></a> actually work? Why does it magically know to point to my computer?”</p>
</blockquote>
<p>Turns out, the answer is both <strong>simple</strong> and <strong>cool</strong>. Let's explore.</p>
<h2 id="heading-what-is-localhosthttplocalhost">What Is <a target="_blank" href="http://localhost"><code>localhost</code></a>?</h2>
<p>At its core, <a target="_blank" href="http://localhost"><code>localhost</code></a> is just a <strong>hostname</strong>, a label used to refer to a network device.</p>
<p>But unlike <a target="_blank" href="http://google.com"><code>google.com</code></a> or <a target="_blank" href="http://facebook.com"><code>facebook.com</code></a>, <a target="_blank" href="http://localhost"><code>localhost</code></a> <strong>always points to your own computer</strong>.</p>
<p>By default, it maps to:</p>
<pre><code class="lang-plaintext">127.0.0.1   // IPv4 loopback address
::1         // IPv6 loopback address
</code></pre>
<p>When your browser connects to <a target="_blank" href="http://localhost"><code>localhost</code></a>, it loops back internally to your own system, <strong>no router or internet needed</strong>.</p>
<h2 id="heading-where-is-this-mapping-stored">Where Is This Mapping Stored?</h2>
<p>That magic mapping of <a target="_blank" href="http://localhost"><code>localhost</code></a> to <code>127.0.0.1</code> happens in a simple text file called the <strong>hosts file</strong>.</p>
<h3 id="heading-on-windows">On Windows:</h3>
<pre><code class="lang-plaintext">C:\Windows\System32\drivers\etc\hosts
</code></pre>
<p>And inside, you’ll usually find:</p>
<pre><code class="lang-plaintext">127.0.0.1   localhost
::1         localhost
</code></pre>
<p>These lines tell your system that <a target="_blank" href="http://localhost"><code>localhost</code></a> is just another name for <code>127.0.0.1</code>.</p>
<h2 id="heading-how-your-os-resolves-hostnames">How Your OS Resolves Hostnames</h2>
<p>Whenever you open a URL in your browser, here’s what your OS does:</p>
<ol>
<li><p><strong>Check the</strong> <code>hosts</code> file</p>
</li>
<li><p>If not found, ask the <strong>DNS server</strong></p>
</li>
<li><p>If DNS doesn’t know, show an error</p>
</li>
</ol>
<p>That means your system looks into the <code>hosts</code> file <em>before</em> touching the internet.</p>
<p>So technically, the <code>hosts</code> file is like a <strong>mini local DNS</strong>. You can override any domain, reroute URLs, and more.</p>
<blockquote>
<p>It’s fascinating how something we use every day hides such an elegant little system under the hood.</p>
</blockquote>
]]></content:encoded></item></channel></rss>