private function doDispatchAsyncJobFor($type, $title, $parameters, $dispatchableCallbackJob)
 {
     $parameters['async-job'] = array('type' => $type, 'title' => $title->getPrefixedDBkey());
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_METHOD, 'POST');
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONTENT_TYPE, "application/x-www-form-urlencoded");
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONTENT, 'parameters=' . json_encode($parameters));
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONNECTION_FAILURE_REPEAT, 2);
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function ($requestResponse) {
         wfDebugLog('smw', 'SMW\\DeferredRequestDispatchManager: ' . json_encode($requestResponse->getList()) . "\n");
     });
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function ($requestResponse) use($dispatchableCallbackJob, $title, $type, $parameters) {
         wfDebugLog('smw', "SMW\\DeferredRequestDispatchManager: Connection to SpecialDeferredRequestDispatcher failed therefore adding {$type} for " . $title->getPrefixedDBkey() . "\n");
         call_user_func_array($dispatchableCallbackJob, array($title, $parameters));
     });
     $this->httpRequest->execute();
     return true;
 }
 /**
  * Execute a HTTP-based SPARQL POST request according to
  * http://www.w3.org/2009/sparql/docs/http-rdf-update/.
  * The method throws exceptions based on
  * GenericHttpDatabaseConnector::mapHttpRequestError(). If errors occur and this
  * method does not throw anything, then an empty result with an error
  * code is returned.
  *
  * @note This protocol is not part of the SPARQL standard and may not
  * be supported by all stores. To avoid using it, simply do not provide
  * a data endpoint URL when configuring the SPARQL database. If used,
  * the protocol might lead to a better performance since there is less
  * parsing required to fetch the data from the request.
  * @note Some stores (e.g. 4Store) support another mode of posting data
  * that may be implemented in a special database handler.
  *
  * @param $payload string Turtle serialization of data to send
  *
  * @return boolean
  */
 public function doHttpPost($payload)
 {
     if ($this->repositoryClient->getDataEndpoint() === '') {
         throw new BadHttpDatabaseResponseException(BadHttpDatabaseResponseException::ERROR_NOSERVICE, "SPARQL POST with data: {$payload}", 'not specified');
     }
     $defaultGraph = $this->repositoryClient->getDefaultGraph();
     $this->httpRequest->setOption(CURLOPT_URL, $this->repositoryClient->getDataEndpoint() . ($defaultGraph !== '' ? '?graph=' . urlencode($defaultGraph) : '?default'));
     $this->httpRequest->setOption(CURLOPT_POST, true);
     // POST as file (fails in 4Store)
     $payloadFile = tmpfile();
     fwrite($payloadFile, $payload);
     fseek($payloadFile, 0);
     $this->httpRequest->setOption(CURLOPT_INFILE, $payloadFile);
     $this->httpRequest->setOption(CURLOPT_INFILESIZE, strlen($payload));
     $this->httpRequest->setOption(CURLOPT_HTTPHEADER, array('Content-Type: application/x-turtle'));
     $this->httpRequest->execute();
     if ($this->httpRequest->getLastErrorCode() == 0) {
         return true;
     }
     // TODO The error reporting based on SPARQL (Update) is not adequate for the HTTP POST protocol
     $this->mapHttpRequestError($this->repositoryClient->getDataEndpoint(), $payload);
     return false;
 }
 private function doPostJobWith($type, $title, $parameters, $dispatchableCallbackJob)
 {
     // Build requestToken as source verification during the POST request
     $parameters['timestamp'] = time();
     $parameters['requestToken'] = SpecialDeferredRequestDispatcher::getRequestToken($parameters['timestamp']);
     $parameters['async-job'] = array('type' => $type, 'title' => $title->getPrefixedDBkey());
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_METHOD, 'POST');
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONTENT_TYPE, "application/x-www-form-urlencoded");
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONTENT, 'parameters=' . json_encode($parameters));
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONNECTION_FAILURE_REPEAT, 2);
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function ($requestResponse) use($parameters) {
         $requestResponse->set('type', $parameters['async-job']['type']);
         $requestResponse->set('title', $parameters['async-job']['title']);
         wfDebugLog('smw', 'SMW\\DeferredRequestDispatchManager: ' . json_encode($requestResponse->getList(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\n");
     });
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function ($requestResponse) use($dispatchableCallbackJob, $title, $type, $parameters) {
         $requestResponse->set('type', $parameters['async-job']['type']);
         $requestResponse->set('title', $parameters['async-job']['title']);
         wfDebugLog('smw', "SMW\\DeferredRequestDispatchManager: Connection to SpecialDeferredRequestDispatcher failed on {$type} with " . json_encode($requestResponse->getList(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . " " . $title->getPrefixedDBkey() . "\n");
         call_user_func_array($dispatchableCallbackJob, array($title, $parameters));
     });
     $this->httpRequest->execute();
     return true;
 }