00:00:11.960
Thank you so much for coming and taking time out of your day at this conference. I'm Julian, and today we're going to talk about HTTP, but I want to approach it from a more narrative perspective rather than just a technical talk.
00:00:17.279
Recently, I started a new job at a great company, and I know absolutely nothing about geospatial systems. I’m sure some of you can relate to this feeling of being new and overwhelmed. I was sitting down at my computer reading up on Go and the company's projects, and soon I found myself with over 100 tabs open. It’s a sinking feeling, knowing there's so much to learn. I want to remind everyone that feeling is completely normal. Even experienced developers know the struggle, and it’s important to learn how to navigate that complexity.
00:01:01.600
The purpose of this talk is to explore one way to tackle that complexity by focusing on the fundamentals instead of being overwhelmed by the details. We all use web browsers every day, which contain tens of millions of lines of code. It's fascinating and a bit scary to think that there’s more code in a web browser than in the Linux kernel or probably even in Windows. Yet, anyone can become a great web developer without needing to understand all that code. Today, I want to show you a cool tool called Netcat, and we'll do some fun experiments to reinforce these foundational concepts.
00:01:43.520
Netcat, or nc, is a simple command-line utility that operates on the client-server model. One program listens for requests while others connect to it. Let’s run it in server mode, specifying a port, like 2001, and enabling it to handle multiple requests. Once started, we can switch to another instance—running it in client mode—and connect back to our server. When we type messages like ‘hello’ in the client, they appear on the server side, demonstrating basic network communication. The simplicity of this tool shows us the essence of how data can be sent and received over a network.
00:03:20.120
Next, let's have a look at a web server we have running. It’s hosting an HTML page that has elements like headers and images. To see how it works, we'll connect to this server on port 3000. When we send a GET request using HTTP/1.1, we can observe the server's response, beginning with a status code of 200, which indicates that everything is okay. The response details the content type, and if you’ve ever used developer tools in Chrome or Firefox, you will recognize these headers. Importantly, this is not just a visual representation; it’s the actual text being transferred over the network.
00:04:46.840
We can dive deeper into what happens when we structure our requests more carefully. For instance, by sending HTTP headers and sending back an HTML page with additional styles, we see that browsers like Firefox wait for requests and then begin sending requests for any stylesheets or other assets. This highlights the multiple round trips that can occur just to load a single web page. If you’ve ever noticed a spinner while your browser is loading, that’s likely due to multiple requests being resolved sequentially. It gives us insights into how critical it is to minimize these round trips for better user experience.
00:06:23.080
Let's also talk about cookies. Currently residing in Berlin, I see numerous banners asking for cookie consent on various websites. To illustrate this, we will set a simple cookie in our network response. Just like our HTML responses, cookies are sent as header lines and can store information for future requests. They allow our server to remember state, making all web applications more user-friendly. Cookies can be as simple or complex as needed, but at their core, they just represent data stored in headers.
00:07:46.640
Now, let's explore JavaScript. I have a simple Rails app set up that will make our demonstration a bit easier. The app will execute a GET request and reload its content dynamically using jQuery. When we trigger this request, it’s crucial to understand that the server will respond with the appropriate headers and content type, but communication must also confirm security measures using appropriate headers like CORS (Cross-Origin Resource Sharing). This is vital because modern web applications cannot just run scripts from any server due to security protocols.
00:09:05.400
HTTP/2 just gained formal approval, which introduces enhancements across the board. For instance, one significant improvement is that HTTP/2 allows servers to anticipate the necessary resources a web page may need. Instead of waiting for requests from the client side, the server can preemptively send stylesheets and scripts when it knows they'll be needed, significantly improving page load times. It combines efficiency with security in a way that enhances the overall user experience online.
00:10:48.279
Lastly, let’s talk about testing and debugging requests that involve binary data or more complex messages. For such cases, Netcat can allow us to send files. By using the command line, you can create a file containing the request or response you wish to send and use Netcat to transmit it. This is immensely useful when working with files or complex data that may be cumbersome to type manually. Demonstrating it by sending an image, we can serve our files directly over the network using simple commands. This way, vertical integration can easily allow the delivery of content directly upon request.