/** * */ protected function getURLContents() { if (isset($this->cache) && !$this->refresh) { $contents = $this->cache->load('URLContents', $loaded); if ($loaded) { return $contents; } } $contents = $this->request->init()->process(); if ($contents === FALSE) { throw new Exception('URL konnte nicht gelesen werden: ' . Code::varInfo($this->request->getURL())); } if (isset($this->cache)) { $this->cache->store('URLContents', $contents); } return $contents; }
/** * Erstellt einen Request zur BaseURL mit den Credentials in der Host-Config * * ist das deprecated? wegen RequestDispatcher? * @param string $contentType html|json * @return Psc\URL\Request */ public function createCMSRequest($relativeURL, $contentType = NULL, $baseURL = NULL, \Webforge\Configuration\Configuration $hostConfig = NULL) { $url = $baseURL ?: $this->getProject()->getBaseURL(); $url .= ltrim($relativeURL, '/'); $hostConfig = $hostConfig ?: $this->getHostConfig(); $curl = new \Psc\URL\Request($url); $curl->setAuthentication($hostConfig->req('cms.user'), $hostConfig->req('cms.password'), CURLAUTH_BASIC); $curl->setHeaderField('X-Psc-Cms-Connection', 'tests'); if ($hostConfig->get('uagent-key') != NULL) { $curl->setHeaderField('Cookie', 'XDEBUG_SESSION=' . $hostConfig->get('uagent-key')); } if (isset($contentType)) { if (mb_strtolower($contentType) === 'html') { $curl->setHeaderField('Accept', 'text/html'); } elseif (mb_strtolower($contentType) === 'json') { $curl->setHeaderField('Accept', 'application/json'); } else { $curl->setHeaderField('Accept', $contentType); } } return $curl; }
protected function createRequest($url, array $postData = NULL) { $req = new \Psc\URL\Request($this->url . '/' . ltrim($url, '/')); if (isset($postData)) { $req->setType('POST'); $req->setData((object) $postData); } return $req; }