Exemple #1
0
 /**
  * @return HTTP_Request2
  * @throws BuildException
  * @throws HTTP_Request2_LogicException
  */
 protected function createRequest()
 {
     if (!isset($this->dir)) {
         throw new BuildException("Required attribute 'dir' is missing");
     }
     $config = array('ssl_verify_peer' => $this->sslVerifyPeer);
     if (isset($this->proxy)) {
         $config['proxy'] = $this->proxy;
     }
     if (null !== $this->followRedirects) {
         $config['follow_redirects'] = $this->followRedirects;
     }
     $request = parent::createRequest();
     $request->setConfig($config);
     $this->log("Fetching " . $this->url);
     return $request;
 }
Exemple #2
0
 /**
  * Creates and configures an instance of HTTP_Request2
  *
  * @return HTTP_Request2
  */
 protected function createRequest()
 {
     $request = parent::createRequest();
     if ($this->method == HTTP_Request2::METHOD_POST) {
         $request->setMethod(HTTP_Request2::METHOD_POST);
         foreach ($this->postParameters as $postParameter) {
             $request->addPostParameter($postParameter->getName(), $postParameter->getValue());
         }
     }
     if ($this->verbose) {
         $observer = new HTTP_Request2_Observer_Log();
         // set the events we want to log
         $observer->events = $this->observerEvents;
         $request->attach($observer);
     }
     return $request;
 }
Exemple #3
0
 public function perform()
 {
     $data = ['type' => 'STORE', 'key_id' => \Kademlia\Node::binId2hex($this->key_id), 'value' => base64_encode($this->value), 'expire' => $this->expire];
     $results = parent::perform($data);
     $stored = false;
     foreach ($results as $r) {
         if ($r['data'] === "{}") {
             $stored = true;
             break;
         }
     }
     if ($stored) {
         $this->emit('success');
     } else {
         $this->emit('failed');
     }
 }