Break up HTTP protocol from JSON data generation, should make it easier to write tests.