private function handleResponse(ApiClient $apiClient, HttpRequest $request, $curl, $response, $url) {
		$httpHeaderSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
		$httpHeader = substr($response, 0, $httpHeaderSize);
		$httpBody = substr($response, $httpHeaderSize);
		$responseInfo = curl_getinfo($curl);

		// debug HTTP response body
		if ($apiClient->isDebuggingEnabled()) {
			error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($httpBody, true).PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
		}

		if ($responseInfo['http_code'] === 0) {
			$curlErrorMessage = curl_error($curl);

			// curl_exec can sometimes fail but still return a blank message from curl_error().
			if (!empty($curlErrorMessage)) {
				throw new ConnectionException($url, $request->getLogToken(), $curlErrorMessage);
			} else {
				throw new ConnectionException($url, $request->getLogToken(), 'API call failed for an unknown reason. This could happen if you are disconnected from the network.');
			}
		} else {
			return new HttpResponse($responseInfo['http_code'], $httpHeader, $httpBody);
		}
	}