refactor to make http handler more portable; make tests more reliable

Signed-off-by: Johannes Petzold <jpetzold@pivotallabs.com>
factor out keep-alive logic for reuse in TC

Signed-off-by: Alex Jackson <ajackson@pivotallabs.com>
finish websocket handler refactoring

Signed-off-by: Johannes Petzold <jpetzold@pivotallabs.com>