Example #1
0
 /**
  * Gibt entweder einen gecachten oder einen echten Request zurück
  * 
  */
 public function createRequest($url, File $cookieJar = NULL)
 {
     $loaded = FALSE;
     $request = $this->requestsCache->load(array($url), $loaded);
     if (!$loaded) {
         $request = new Request($url, $cookieJar);
         $request->getManager()->bind($this, Request::EVENT_PROCESSED);
         // stored dann wenn process() aufgerufen wurde
     }
     return $request;
 }
 public function testAjaxImage()
 {
     $this->markTestSkipped('Akzeptanztest (es fehlen die Passwörter in der DB)');
     $url = 'http://download.serienjunkies.org/f-3c346d11cb64efec/fc_HMM-701-rar.html';
     $json = $this->ajaxTestRequest('/ajax.php?todo=ctrl&ctrlTodo=check', array('type' => 'captcha', 'url' => $url));
     $imageURL = $json->content;
     $this->assertRegexp('|/captchas/[0-9]+/image|', $imageURL);
     $this->assertEquals('captcha', $json->type);
     $request = new Request($hostURL . $imageURL);
     $this->assertNotEmpty($pngRaw = $request->init()->process());
     $this->assertInternalType('resource', imagecreatefromstring($pngRaw));
 }
Example #3
0
 /**
  * @return Psc\URL\Request
  */
 protected function getRequest()
 {
     if (!isset($this->request)) {
         $this->request = new \Psc\URL\Request($this->expandUrl($this->url));
         $this->request->setAuthentication($this->hostConfig->req('cmf.user'), $this->hostConfig->req('cmf.password'), CURLAUTH_BASIC);
         $this->request->setHeaderField('X-Psc-Cms-Connection', 'tests');
         $this->request->setHeaderField('X-Psc-Cms-Debug-Level', 15);
         if ($this->method == 'GET' || $this->method == 'POST') {
             $this->request->setType($this->method);
         } else {
             $this->request->setType('POST');
             $this->request->setHeaderField('X-Psc-Cms-Request-Method', $this->method);
         }
         $this->setContentType('html');
         // this is great for debugging, but it slows down 50%
         if ($this->sendDebugSessionCookie && $this->hostConfig->get('uagent-key') != NULL) {
             $this->request->setHeaderField('Cookie', 'XDEBUG_SESSION=' . $this->hostConfig->get('uagent-key'));
         }
     }
     return $this->request;
 }
 public function getBoardIds()
 {
     $this->logger->writeln('Lade BoardIds');
     $cache = new \Psc\Data\FileCache();
     $ser = $cache->load('boardIds', $loaded);
     if (!$loaded) {
         $this->logger->writeln('BoardIds nicht im Cache, mache URL Request');
         $this->req = new URLRequest('http://www.subcentral.de/index.php?s=' . $this->sessionId, $this->cookieJar);
         $html = $this->req->init()->process();
         $boardIds = array();
         $dom = xml::doc($html);
         foreach (xml::query($dom, '#search select[name=boardID] option') as $option) {
             $title = $option->nodeValue;
             $boardIds[mb_strtolower($title)] = (int) $option->getAttribute('value');
         }
         $this->logger->writeln(count($boardIds) . ' BoardIds gefunden. Speichere im Cache');
         $ser = serialize($boardIds);
         $cache->store('boardIds', $ser);
     } else {
         $boardIds = unserialize($ser);
         $this->logger->writeln(count($boardIds) . ' BoardIds im Cache gefunden');
     }
     return $boardIds;
 }
Example #5
0
 protected function assertCommonRequest(Request $request)
 {
     $json = $this->test->json($request->getData());
     $this->assertNotEmpty($json->apikey);
     return $json;
 }
Example #6
0
 protected function passwordRequest($username, $password, $url)
 {
     $req = new Request($url);
     $req->setAuthentication($username, $password);
     return $req;
 }