REST JSON support in the agent

This implements REST JSON support in the cockpit-agent. Allows us to do:

 * polling/monitoring
 * reliable streaming
 * Better byte handling, length handling, etc...