We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Binary Data

As we've covered, HTTP is a text-based protocol, but that doesn't mean it can't send binary data. In fact, HTTP is quite good at sending binary data, and it does so by using the Content-Type header to indicate the type of data being sent. For example, if you're sending an image, you might use Content-Type: image/png, and if you're sending a video, you might use Content-Type: video/mp4.

That way, the client knows how to interpret the body. Rather than reading it as raw text, it can expect a specific format of video data, for example.

Assignment

The beauty of our current abstraction is that we already have all the tools we need to respond with binary data! Let's add a handler that responds with a video.

  1. mkdir assets
    curl -o assets/vim.mp4 https://storage.googleapis.com/qvault-webapp-dynamic-assets/lesson_videos/vim-vs-neovim-prime.mp4
    

    Add the assets folder to .gitignore, so you don't accidentally commit it.

Pretty cool right! This stuff's not so scary.

Run and submit the CLI tests.