websocket: Expose the web_socket_util_parse_status_line() function

We'd like to use this to parse status lines in other Cockpit code
so expose this, document it and give it a non-private name.

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
doc: Document the new rest-json1 payload
cockpit: Add cockpit_pipe_get_buffer() function

This allows us to access the input buffer of a pipe even when we're
not in the 'read' event. It can change during the main loop.
cockpit: Implement a generic cockpit_pipe_connect() constructor

We'll have multiple things connecting to pipes, so implement the
connection logic in CockpitPipe.

Also make it async and connect in the main loop where possible.
cockpit: Add a cockpit_pipe_skip() function

For skipping bytes in a data buffer without returning them or doing
anything with them. Useful for channels that operate directly on
the bytes in the buffer.
cockpit: Add cockpit_json_get_string() and cockpit_json_get_int()

These functions are safe wrappers for getting strings and int fields
of JSON objects. Rather than repeating this code everywhere, consolidate
it into one place.

JSON GLib is a bit tricky here because we have to check the types, and
a bit of conversion is possible (such as double -> int).
cockpit: Add cockpit_json_int_hash() and cockpit_json_int_equal()

These are for putting the gint64 type that JSON GLib uses for integers
into GHashTable.

Note these are similar to g_int_hash() and g_int_equal() in that they
take a pointer to a gint64. They are not like g_direct_hash() and
g_direct_equal() which take a pointer (and possibly an int cast to
a pointer).
cockpit: Add cockpit_json_skip() function for splitting JSON

Some services like Docker return multiple JSON blocks in their
REST JSON output. We have to split these apart before passing them
to the JSON parser.

The cockpit_json_skip() function allows this, including finding
whitespace and so on.

It does not validate the JSON blocks. It assumes that the blocks
are valid and/or will be parsed to find errors.

This is part of: Fix #265
cockpit: Verify that JsonParser trims whitespace

Our REST JSON code depends on the fact that JsonParser trims
whitespace before and after parsing. Verify this in our tests so we can
catch it if it changes.
cockpit: Add cockpit_json_equal() which checks for equality

This function checks for logical equality between two JSON nodes.
If the nodes are of different types, then the equality fails, even
if they can be converted to the same type.

Part of fix #267
agent: Implement CockpitRestJson and the 'rest-json1' payload type

This is an implementation of the REST JSON payload type. It's fairly
complete, supporting streaming, monitoring, and other necessary
things.

Monitoring currently is only driven by an interval, where it could
also be driven off of output from another request.

Part of fix for #268, #267 and #265
web: Allow Channel.close() to accept a problem

Even though it's on the web side, we should allow Channel.close()
to accept a problem code which listeners can then react to. This allows
a consistent flow of problem codes no matter where they come from.
The problem code doesn't need to be sent to the web service or agent.
web: Use new rest-json1 protocol to implement web rest client
web: Add Rest.poll() and req.cancel() req.restart()

Add Rest.poll() function for setting up a REST JSON poll. In addition
we add the ability to restart() requests and cancel() them. The latter
are neccessary to restart the requests that the poll() is watching,
with the same cookie.
web: Use new REST functionality to watch Docker /events