refactored HTTP transport code