Understanding HTTP responses
The result of the HTTP.get
invocation is an object that closely mirrors a raw HTTP response. The package makes our lives easier by extracting the raw HTTP data and neatly setting it up in a data structure, which makes manipulating it a breeze.
Let's take a look at its properties (or fields in Julia's lingo):
julia> fieldnames(typeof(resp))
(:version, :status, :headers, :body, :request)
The fieldnames
function accepts a type as its argument and returns a tuple containing the names of the fields (or properties) of the argument. In order to get the type of a value, we can use the typeof
function, like in the previous example.
Right! The status
, headers
, and body
fields should by now sound familiar. The version
field represents the version of the HTTP protocol (the HTTP/1.1
 part in the first line of the response). Most web servers on the internet today use version 1.1 of the protocol, but a new major version, 2.0, is almost ready for wide deployment. Finally, the...