public function loadResponse($id) { if (!isset($this->connectionData[$id])) { throw new \InvalidArgumentException('Tried to get response for invalid ID $id.'); } $connectionData = $this->connectionData[$id]; $action = $connectionData->getAction(); if (empty($action)) { $this->log->error('Request type missing.'); $connectionData->setNullResponse(); return; } $fileNamePrefix = $this->getFileNamePrefix($connectionData); $fileExtension = $this->getFileExtension($connectionData); $queryString = $this->getQueryString($connectionData); $fileName = $this->getFileName($fileNamePrefix, md5($queryString), $fileExtension); if (!$this->hasFileNameChanged($id, $fileName)) { return; } $this->log->info("Trying to load file: {$fileName}"); $fileContent = null; if (!($fileContent = @file_get_contents($fileName))) { throw new \Exception('File "' . $fileName . ' (original: ' . $fileNamePrefix . $queryString . $fileExtension . '" not found'); } $response = FF::getInstance('Core\\Server\\Response', $fileContent, 200, 0, ''); $connectionData->setResponse($response, $fileName); }
public function loadResponse($id) { if (!isset($this->connectionData[$id])) { throw new \InvalidArgumentException('Tried to get response for invalid ID $id.'); } $connectionData = $this->connectionData[$id]; $action = $connectionData->getAction(); if (empty($action)) { $this->log->error('Request type missing.'); $connectionData->setNullResponse(); return; } $fileName = $this->getFileName($connectionData); if (!$this->hasFileNameChanged($id, $fileName)) { return; } $this->log->info("Trying to load file: {$fileName}"); $response = FF::getInstance('Core\\Server\\Response', file_get_contents($fileName), 200, 0, ''); $connectionData->setResponse($response, $fileName); }
private function logResult($response) { $httpCode = $response->getHttpCode(); $curlError = $response->getConnectionError(); if ($httpCode >= 400) { $this->log->error("Connection failed. HTTP code: {$httpCode}"); } else { if ($httpCode == 0) { $this->log->error("Connection refused. cURL error: {$curlError}"); } else { if (floor($httpCode / 100) == 2) { // all successful status codes (2**) $this->log->info("Request successful!"); } } } }
protected function useXmlResponseContentProcessor() { $this->responseContentProcessor = function ($string) { libxml_use_internal_errors(true); // The constructor throws an exception on error $response = new \SimpleXMLElement($string); if (isset($response->error)) { $this->error = strip_tags($response->error); $this->log->error("FACT-Finder returned error: " . $this->error); if (isset($response->stacktrace)) { $this->stackTrace = $response->stacktrace; $this->log->error("Stacktrace:\n" . $this->stackTrace); } } return $response; }; }
/** * Remove all references to the connection data object identified by $id. * * @param mixed $id The ID corresponding to the connection data object to be * removed from the DataProvider. */ public function unregister($id) { unset($this->connectionData[$id]); $this->log->debug("Unregistered connection data for ID {$id}."); }