Cleaned up code for collecting HTTP response.