From: Alexander Ebert Date: Mon, 30 Sep 2013 17:38:50 +0000 (+0200) Subject: Added support for JSON strings instead of an array of POST parameters X-Git-Tag: 2.0.0_Beta_10~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1b20f9903758b54f671f9cf3bb4cc1123f21d49f;p=GitHub%2FWoltLab%2FWCF.git Added support for JSON strings instead of an array of POST parameters Fixes #1521 --- diff --git a/wcfsetup/install/files/lib/util/HTTPRequest.class.php b/wcfsetup/install/files/lib/util/HTTPRequest.class.php index 9bd8b8689c..1277f7251e 100644 --- a/wcfsetup/install/files/lib/util/HTTPRequest.class.php +++ b/wcfsetup/install/files/lib/util/HTTPRequest.class.php @@ -109,10 +109,10 @@ final class HTTPRequest { * * @param string $url URL to connect to * @param array $options - * @param array $postParameters Parameters to send via POST + * @param mixed $postParameters Parameters to send via POST * @param array $files Files to attach to the request */ - public function __construct($url, array $options = array(), array $postParameters = array(), array $files = array()) { + public function __construct($url, array $options = array(), $postParameters = array(), array $files = array()) { $this->setURL($url); $this->postParameters = $postParameters; @@ -126,7 +126,13 @@ final class HTTPRequest { $this->addHeader('Accept-Language', WCF::getLanguage()->getFixedLanguageCode()); if ($this->options['method'] !== 'GET') { if (empty($this->files)) { - $this->body = http_build_query($this->postParameters, '', '&'); + if (is_array($postParameters)) { + $this->body = http_build_query($this->postParameters, '', '&'); + } + else if (is_string($postParameters) && !empty($postParameters)) { + $this->body = $postParameters; + } + $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); } else {