From 1b20f9903758b54f671f9cf3bb4cc1123f21d49f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 30 Sep 2013 19:38:50 +0200 Subject: [PATCH] Added support for JSON strings instead of an array of POST parameters Fixes #1521 --- .../install/files/lib/util/HTTPRequest.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 { -- 2.20.1