returns an array of the form ('header'=>..,'response'=>...) on success, a string an error.

@param string $sTargetPath
@param array  $aData

@return array|string
339856
protected function SendRequestToEasyCash($sTargetPath, $aData)
    {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, self::EASY_CASH_API_SERVER.$sTargetPath);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

        // Set user and pwd
        curl_setopt($ch, CURLOPT_USERPWD, $this->GetConfigParameter('sPaymasterUser').':'.$this->GetConfigParameter('sPaymasterPassword'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);

        $sData = str_replace('&amp;', '&', TTools::GetArrayAsURL($aData));
        // build request
        curl_setopt($ch, CURLOPT_POSTFIELDS, $sData);
        $response = curl_exec($ch);

        $aFullResponse = null;
        if (curl_errno($ch)) {
            TTools::WriteLogEntry('Payment EasyCash Error: '.curl_error($ch), 1, __FILE__, __LINE__);
            $aFullResponse = curl_errno($ch).': '.curl_error($ch);
        } else {
            $aFullResponse = array('header' => substr($response, 0, (strpos($response, "\r\n\r\n"))), 'response' => substr($response, (strpos($response, "\r\n\r\n") + 4)));
        }
        curl_close($ch);

        return $aFullResponse;
    }
876147
private function get($path, $params = null, $headers = null)
    {
        return $this->run($path, array('method' => 'get', 'params' => $params, 'headers' => $headers));
    }
373275
public static function responseError($mdata = array(), $status = null, $msg = null)
    {
        if (!$status) {
            $status = 400;
        }

        if (method_exists($mdata, 'getFile')) {
            $data = [
                "msg" => $msg ?: $mdata->getMessage(),
                "status" => $status,
                "data" => [],
            ];
            if (LEVEL_ENV < 2) {
                $data['data']['file'] = $mdata->getFile();
                $data['data']['line'] = $mdata->getLine();
                $data['data']['code'] = $mdata->getCode();
                $data['data']['debug'] = debug_backtrace();
            }
        } else{
            $data = [
                "msg" => $msg,
                "status" => $status,
                "data" => $mdata,
            ];
        }

        return $data;
    }
693009
private function get($path, array $params = [])
    {
        $request = $this->createHttpGetRequest($this->buildUrl($path), $params);

        $response = $this->httpClient->sendRequest($request);

        return $this->parseResponse($response, $request);
    }
782042
private function getRequireData($requestPath, array $getData = [])
    {
        $responseData = $this->get($requestPath, $getData);

        return self::requireNotNull($responseData);
    }
873320
public function getDownloadData($path, array $data = []): ?array
    {
        $path = Controller::replaceInsertTags($path);

        if (Validator::isUuid($path)) {
            $file = System::getContainer()->get('huh.utils.file')->getFileFromUuid($path);
        } else {
            try {
                $file = new File(urldecode($path));
            } catch (\Exception $e) {
                return null;
            }
        }

        if (null === $file) {
            return null;
        }

        $model = $file->getModel();

        if (null === $model) {
            try {
                Dbafs::addResource($file->path);
            } catch (\Exception $e) {
                return null;
            }

            if (null === $model) {
                return null;
            }
        }

        $requestedFile = System::getContainer()->get('huh.request')->getGet('file', true);

        // Send the file to the browser and do not send a 404 header (see #4632)
        if ('' != $requestedFile && $requestedFile == $file->path) {
            try {
                Controller::sendFileToBrowser($requestedFile);
            } catch (ResponseException $e) {
                $e->getResponse()->send();
            }

            return null;
        }

        $fileData['model'] = $file->getModel()->row();

        $allowedDownload = StringUtil::trimsplit(',', strtolower(Config::get('allowedDownload')));

        // Return if the file type is not allowed
        if (!\in_array($file->extension, $allowedDownload)) {
            return null;
        }

        if (!isset($data['linkTitle'])) {
            $fileData['linkTitle'] = StringUtil::specialchars($file->basename);
        }

        $strHref = Environment::get('request');

        // Remove an existing file parameter (see #5683)
        if (preg_match('/(&(amp;)?|\?)file=/', $strHref)) {
            $strHref = preg_replace('/(&(amp;)?|\?)file=[^&]+/', '', $strHref);
        }

        $strHref .= (false !== strpos($strHref, '?') ? '&amp;' : '?').'file='.System::urlEncode($file->value);

        $fileData['link'] = $fileData['linkTitle'];
        $fileData['title'] = StringUtil::specialchars($data['titleText'] ?: sprintf($GLOBALS['TL_LANG']['MSC']['download'], $file->basename));
        $fileData['href'] = $strHref;
        $fileData['filesize'] = System::getReadableSize($file->filesize, 1);
        $fileData['icon'] = Image::getPath($file->icon);
        $fileData['mime'] = $file->mime;
        $fileData['extension'] = $file->extension;
        $fileData['path'] = $file->dirname;

        return array_merge($fileData, $data);
    }
469961
public function request($path, $body, $httpMethod = 'GET', array $headers = [], array $options = [])
	{
		$request = $this->createRequest($httpMethod, $path, $body, $headers);

		try {
			$response = $this->client->send($request, $options);
		} catch (\LogicException $e) {
			throw new \ErrorException($e->getMessage(), $e->getCode(), $e);
		} catch (\RuntimeException $e) {
			throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
		}

		$this->lastRequest  = $request;
		$this->lastResponse = $response;

		return $response;
	}
649063
public static function headersToArray($header_text)
    {
        $headers = array();


        foreach (explode("\r\n", $header_text) as $i => $line)
            if ($i === 0)
                $headers['http_code'] = $line;
            else
            {
                if(!empty($line) && strpos($line, ':') !== false){
                    list ($key, $value) = explode(': ', $line);

                    $headers['headers'][] = array(
                        'key' => $key,
                        'value' => $value,
                    );
                }
            }

        return $headers;
    }
633852
public function trigger($sEvent, $sNamespace = 'nails/common', $aData = [])
    {
        $this->addHistory($sEvent, $sNamespace);

        $sEvent     = strtoupper($sEvent);
        $sNamespace = strtoupper($sNamespace);

        if (!empty($this->aSubscriptions[$sNamespace][$sEvent])) {
            foreach ($this->aSubscriptions[$sNamespace][$sEvent] as $sSubscriptionHash => $oSubscription) {
                if (is_callable($oSubscription->callback)) {
                    call_user_func_array($oSubscription->callback, $aData);
                }

                if ($oSubscription->is_once) {
                    unset($this->aSubscriptions[$sNamespace][$sEvent][$sSubscriptionHash]);
                }
            }
        }

        return $this;
    }
1114688
public function render($aData)
    {
        if (empty($aData['likertTerms'])) {
            $aData['likertTerms'] = $this->aLikertTerms;
        }

        $oView = Factory::service('View');
        $sOut  = $oView->load('formbuilder/fields/open', $aData, true);
        $sOut  .= $oView->load('formbuilder/fields/body-likert', $aData, true);
        $sOut  .= $oView->load('formbuilder/fields/close', $aData, true);

        return $sOut;
    }
994512
public function getFileContents($filePath, $showError = true)
    {
        $filePath = realpath($filePath);

        if ($this->fileIsReadable($filePath) === false) {
            if ($showError === true) {
                // This file was not readable! We need to tell the user!
                $this->pool->messages->addMessage('fileserviceAccess', array($this->filterFilePath($filePath)));
            }
            // Return empty string.
            return '';
        }

        // Is it readable and does it have any content?
        $size = filesize($filePath);
        if ($size > 0) {
            $file = fopen($filePath, 'r');
            $result = fread($file, $size);
            fclose($file);
            return $result;
        }

        // Empty file returns an empty string.
        return '';
    }
722407
private function getContents(string $path)
    {
        set_error_handler(static function ($type, $msg) use (&$error): void {
            $error = $msg;
        });
        $content = file_get_contents($path);
        restore_error_handler();
        if (false === $content) {
            throw new \RuntimeException($error);
        }

        return $content;
    }
667626
public function getBySlug($sSlug, array $aData = [])
    {
        if (!$this->tableSlugColumn) {
            throw new ModelException(static::class . '::getBySlug() Column variable not set.', 1);
        }

        return $this->getByColumn($this->tableSlugColumn, $sSlug, $aData);
    }
767639
protected function get(string $path, array $params = [], array $headers = [])
    {
        $response = $this->pureGet($path, $params, $headers);

        return ResponseMediator::getContent($response);
    }
8335
public function getByRef($sRef, $aData = [])
    {
        if (empty($aData['where'])) {
            $aData['where'] = [];
        }

        $aData['where'][] = [$this->sTableAlias . '.ref', $sRef];

        $aEmails = $this->getAll(null, null, $aData);

        return !empty($aEmails) ? reset($aEmails) : false;
    }
902984
public function getMetaData(string $path): array
    {
        $path = $this->normalizePath($path);
        $this->assertPresent($path);

        return $this->getAdapter()->getMetaData($path);
    }
545384
protected function loadMeta($path, \DOMNode $context = null)
    {
        $result = [];

        /** @var \DOMElement $node */
        foreach ($this->xpath->query($path, $context) as $node) {
            $attribute = $node->tagName;
            $lang = $this->xpath->query('@lang', $node)->item(0)->nodeValue;

            if (!isset($result[$node->tagName])) {
                $result[$attribute] = [];
            }
            $result[$attribute][$lang] = $node->textContent;
        }

        return $result;
    }