Chunked HTTP and REST calls support

Changes required to properly support returning results from REST calls as a series of individually serialized chunks (using chunked encoding) rather than one big JSON object.  Useful for streaming results out of a query.  Also deals with segfaults when a client disconnects.