Learn you some HTTP for fun and glory
A Software Engineer passionate about public good projects and making technology to serve society en masse.
Search for a command to run...
A Software Engineer passionate about public good projects and making technology to serve society en masse.
No comments yet. Be the first to comment.
HS (Harmonised System) Codes help classify customs authorities and businesses around the world to ensure appropriate import/export control. This system recursively classifies a product into finer granularity of categories. Figure 1: A simple exercis...
Jan allows you to deploy and run LLMs on your Windows or macOS computer! 16 Gigabytes of memory and a M1 chip was enough for me to run Mistral locally. Now how do you take Jan and use libraries like Langchain? https://jan.ai Local API Server Click ...
My talk at PyCon Thailand 2023 on the security aspects and possible attack vectors of LLM Applications, tailored to both product people and engineers! https://youtu.be/_fvk_Qa5OsM Thank you PyCon TH team!
Looking for a flat for rent, with LLMs
Code generators replace mindless coding with productivity; a pure function that produces predictable code, given a (set of) input(s). Generating boilerplate classes or templates — a common use case for Codegen. Use-case: Generating Classes We will be...
We all use HTTP, develop for HTTP and think that we know HTTP. But, I believe as engineers we should never take things for granted; rather we should dissect everything that comes before us, recursively as many times as possible. So, let's keep applying this principle for HTTP.
cURL is a great tool for sending HTTP requests. Let's try to send one.
curl http://httpbin.org/ip

Hmm, okay it can do stuff. Let's make it a bit more verbose shall we? Just add a -v flag.
curl -v http://httpbin.org/ip

Ah now things are interesting. Do you see a few lines starting with '>'? Well those are the headers that are SENT to the server. And the lines starting with '<'? They are response headers that are received. The last part is the content itself. Of course, the < and > are there for representation only, they are not transmitted.
telnet is a great tool to make raw socket connections and really dissect almost any TCP based protocol like HTTP. Lets try this.
telnet httpbin.org 80
Afterwards, type in a raw HTTP request yourself!
GET /ip HTTP/1.1
Host: httpbin.org
Now, press enter or return twice!

Who needs Firefox, Chrome or cURL! Looks like Telnet is all we need ;) Okay enough jokes for now. This is serious business. You see in the end HTTP is just a plain socket connection that has some specific "lingo" to send requests and receive responses. (Protocol, duh).
Let's see how exactly we made the request.
GET /ip HTTP/1.1
Host: httpbin.org
Pretty straightforward. The HTTP method in caps, the path and the HTTP version in the first line. After that, the request headers follow. In our case we just mentioned the 'Host' header to play safe with VirtualHost-enabled systems.
Back in the days, running a website was expensive because you needed an entire box (a server computer) to host a single website. Then we invented a way to serve multiple websites from the same IP address / machine with virtual hosts in the Apache Web Server.
The internet as we know it exists for this 'Host' header.
The two newlines indicate we are done with our request, and the server can parse it and send back a response.
Let's send a malformed HTTP request (muhahaha).
telnet httpbin.org 80
Afterwards, type in a malformed request yourself!
muhahahaha
Now, press enter or return twice!

Yup :( It was a Bad Request. We'll write our own HTTP server with plain old sockets soon. Till then, why not explore the exciting world of HTTP response headers on Google ;) Yeah and take a look at RFC 2616.