Implemented strict http request serialization for APIs that forbid a session to be used in concurrent requests (e.g. dedimania).

Updated all API requests in DedimaniaPlugin to be serialized by this mechanism. Closes #139.
This commit is contained in:
Sebastian Büttner
2017-05-22 22:32:15 +02:00
parent d03f155415
commit b0732bee96
5 changed files with 77 additions and 12 deletions

View File

@ -36,6 +36,7 @@ class AsyncHttpRequest implements UsageInformationAble {
private $contentType = 'text/xml; charset=UTF-8;';
private $timeout = 60;
private $headers = array();
private $serialize = false;
public function __construct($maniaControl, $url) {
$this->maniaControl = $maniaControl;
@ -58,6 +59,7 @@ class AsyncHttpRequest implements UsageInformationAble {
->set(CURLOPT_RETURNTRANSFER, true)//
->set(CURLOPT_FOLLOWLOCATION, true)// support redirect
->set(CURLOPT_SSL_VERIFYPEER, false);
$request->setSerialize($this->serialize); // serialize requests to this host
return $request;
}
@ -228,4 +230,13 @@ class AsyncHttpRequest implements UsageInformationAble {
public function setTimeout($timeout) {
$this->timeout = $timeout;
}
/**
* Sets whether the request to the same host should be serialized.
*
* @param bool $serialize
*/
public function setSerialize($serialize = true) {
$this->serialize = $serialize;
}
}