<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Http on AminBytes</title><link>https://aminbytes.dev/tags/http/</link><description>Recent content in Http on AminBytes</description><generator>Hugo</generator><language>en</language><atom:link href="https://aminbytes.dev/tags/http/index.xml" rel="self" type="application/rss+xml"/><item><title>Build a tiny HTTP server</title><link>https://aminbytes.dev/bytes/http/hands-on/build-a-server/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/hands-on/build-a-server/</guid><description>&lt;p&gt;Time to be the server. We&amp;rsquo;ll build a small to-do &lt;a class="gl" href="https://aminbytes.dev/glossary/#api" data-gl="api" data-gl-term="API" data-gl-aka="Application Programming Interface" data-gl-def="A way for programs to talk to each other. A web API is a set of URLs that answer with data (usually JSON) instead of web pages." data-gl-see="/bytes/http/requests/http-methods/"&gt;API&lt;/a&gt; using only Node&amp;rsquo;s built-in &lt;code&gt;http&lt;/code&gt; module, then talk to it with &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>HTTP methods</title><link>https://aminbytes.dev/bytes/http/requests/http-methods/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/requests/http-methods/</guid><description>&lt;p&gt;The first word of every request is the &lt;a class="gl" href="https://aminbytes.dev/glossary/#method" data-gl="method" data-gl-term="Method" data-gl-aka="HTTP verb" data-gl-def="The first word of a request, like GET or POST. It says what you want to do with the resource."&gt;&lt;strong&gt;method&lt;/strong&gt;&lt;/a&gt;. It says &lt;em&gt;what you want to do&lt;/em&gt; with the resource in the path.&lt;span class="sn"&gt;&lt;button type="button" class="sn-ref" aria-expanded="false"&gt;&lt;span class="sr-only"&gt;Note&lt;/span&gt;&lt;/button&gt;&lt;span class="sn-body" role="note"&gt;There are a few more, like &lt;code&gt;HEAD&lt;/code&gt; (only the headers, no body) and &lt;code&gt;OPTIONS&lt;/code&gt; (&amp;ldquo;what am I allowed to do here?&amp;rdquo;), which browsers send for cross-site requests.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Status codes</title><link>https://aminbytes.dev/bytes/http/responses/status-codes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/responses/status-codes/</guid><description>&lt;p&gt;The first line of every &lt;a class="gl" href="https://aminbytes.dev/glossary/#response" data-gl="response" data-gl-term="Response" data-gl-def="What the server sends back: a status code, headers, and usually a body." data-gl-see="/bytes/http/basics/what-is-http/"&gt;response&lt;/a&gt; has a &lt;a class="gl" href="https://aminbytes.dev/glossary/#status-code" data-gl="status-code" data-gl-term="Status code" data-gl-def="The three-digit number at the start of a response that says how it went. 2xx is success, 4xx is your mistake, 5xx is the server&amp;rsquo;s."&gt;&lt;strong&gt;status code&lt;/strong&gt;&lt;/a&gt;:&lt;/p&gt;</description></item><item><title>What is HTTP?</title><link>https://aminbytes.dev/bytes/http/basics/what-is-http/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/basics/what-is-http/</guid><description>&lt;p&gt;&lt;strong&gt;HTTP&lt;/strong&gt; (HyperText Transfer Protocol)&lt;span class="sn"&gt;&lt;button type="button" class="sn-ref" aria-expanded="false"&gt;&lt;span class="sr-only"&gt;Note&lt;/span&gt;&lt;/button&gt;&lt;span class="sn-body" role="note"&gt;Tim Berners-Lee designed the first version at CERN around 1990, together with HTML and the very first web browser.&lt;/span&gt;&lt;/span&gt; is a set of rules for how a &lt;a class="gl" href="https://aminbytes.dev/glossary/#client" data-gl="client" data-gl-term="Client" data-gl-def="The program that sends a request, like your browser, curl or a mobile app."&gt;&lt;em&gt;client&lt;/em&gt;&lt;/a&gt; asks for something and how a &lt;a class="gl" href="https://aminbytes.dev/glossary/#server" data-gl="server" data-gl-term="Server" data-gl-def="A program that waits for requests and answers them. Also the machine it runs on."&gt;&lt;em&gt;server&lt;/em&gt;&lt;/a&gt; answers.&lt;/p&gt;</description></item><item><title>Anatomy of a URL</title><link>https://aminbytes.dev/bytes/http/basics/anatomy-of-a-url/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/basics/anatomy-of-a-url/</guid><description>&lt;p&gt;Before a &lt;a class="gl" href="https://aminbytes.dev/glossary/#request" data-gl="request" data-gl-term="Request" data-gl-def="What the client sends: a method and path, headers, and sometimes a body." data-gl-see="/bytes/http/basics/what-is-http/"&gt;request&lt;/a&gt; is sent, the &lt;a class="gl" href="https://aminbytes.dev/glossary/#url" data-gl="url" data-gl-term="URL" data-gl-aka="web address" data-gl-def="The full address of a resource, like https://example.com/docs?page=2. It&amp;rsquo;s made of a scheme, host, port, path, query and fragment."&gt;URL&lt;/a&gt; tells the client &lt;strong&gt;where&lt;/strong&gt; to go and &lt;strong&gt;what&lt;/strong&gt; to ask for.&lt;span class="sn"&gt;&lt;button type="button" class="sn-ref" aria-expanded="false"&gt;&lt;span class="sr-only"&gt;Note&lt;/span&gt;&lt;/button&gt;&lt;span class="sn-body" role="note"&gt;URL means &lt;em&gt;Uniform Resource Locator&lt;/em&gt;. You&amp;rsquo;ll also see &lt;strong&gt;URI&lt;/strong&gt;, the broader term. For web addresses the two mean practically the same thing.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Content types</title><link>https://aminbytes.dev/bytes/http/responses/content-types/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/responses/content-types/</guid><description>&lt;p&gt;A response body is just bytes. The &lt;a class="gl" href="https://aminbytes.dev/glossary/#content-type" data-gl="content-type" data-gl-term="Content-Type" data-gl-aka="MIME type, media type" data-gl-def="A header that says what format a body is in, like text/html or application/json."&gt;&lt;code&gt;Content-Type&lt;/code&gt;&lt;/a&gt; header tells the client how to interpret them.&lt;/p&gt;</description></item><item><title>Request headers</title><link>https://aminbytes.dev/bytes/http/requests/request-headers/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/requests/request-headers/</guid><description>&lt;p&gt;After the first line come &lt;a class="gl" href="https://aminbytes.dev/glossary/#header" data-gl="header" data-gl-term="Header" data-gl-def="A Name: value line sent before the body. Headers carry extra information like the content type, cookies or who you are."&gt;&lt;strong&gt;headers&lt;/strong&gt;&lt;/a&gt;: &lt;code&gt;Name: value&lt;/code&gt; pairs, one per line, ending with an empty line.&lt;/p&gt;</description></item><item><title>Sending data</title><link>https://aminbytes.dev/bytes/http/requests/sending-data/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/requests/sending-data/</guid><description>&lt;p&gt;There are three common ways to send data to a server.&lt;/p&gt;&#10;&lt;h2 id="1-in-the-url-query-strings"&gt;1. In the URL: query strings&lt;a class="anchor" data-pagefind-ignore="all" href="#1-in-the-url-query-strings" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Good for &lt;strong&gt;filters, search terms and pagination&lt;/strong&gt; on &lt;code&gt;GET&lt;/code&gt; requests:&lt;/p&gt;</description></item><item><title>The request/response cycle</title><link>https://aminbytes.dev/bytes/http/basics/request-response-cycle/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://aminbytes.dev/bytes/http/basics/request-response-cycle/</guid><description>&lt;p&gt;You type &lt;code&gt;https://example.com&lt;/code&gt; and press Enter. Here&amp;rsquo;s what happens, in order.&lt;/p&gt;&#10;&lt;figure class="figure"&gt;&#10; &lt;img src="https://aminbytes.dev/bytes/http/basics/request-response-cycle/cycle.svg" alt="The steps between browser and server" loading="lazy" decoding="async" class="zoomable"&gt;&#10; &lt;figcaption&gt;1. DNS lookup · 2. connect · 3. TLS handshake · 4. request · 5. response&lt;/figcaption&gt;&#10;&lt;/figure&gt;&lt;h2 id="1-dns-find-the-servers-address"&gt;1. DNS: find the server&amp;rsquo;s address&lt;a class="anchor" data-pagefind-ignore="all" href="#1-dns-find-the-servers-address" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Computers connect to &lt;a class="gl" href="https://aminbytes.dev/glossary/#ip-address" data-gl="ip-address" data-gl-term="IP address" data-gl-def="The number that identifies a machine on a network, like 93.184.215.14. Computers connect to these, not to names."&gt;IP addresses&lt;/a&gt;, not names. The browser asks a &lt;a class="gl" href="https://aminbytes.dev/glossary/#dns" data-gl="dns" data-gl-term="DNS" data-gl-aka="Domain Name System" data-gl-def="The internet&amp;rsquo;s phone book. It turns a name like example.com into an IP address computers can connect to."&gt;DNS&lt;/a&gt; resolver: *&amp;ldquo;what&amp;rsquo;s the IP of example.com?&amp;quot;*&lt;span class="sn"&gt;&lt;button type="button" class="sn-ref" aria-expanded="false"&gt;&lt;span class="sr-only"&gt;Note&lt;/span&gt;&lt;/button&gt;&lt;span class="sn-body" role="note"&gt;The answer is cached for a while (the record&amp;rsquo;s &lt;em&gt;TTL&lt;/em&gt;), so the next visit usually skips this step.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>