Mimic CURLOPT_POST in GuzzleHttpRequest
[lhc/web/wiklou.git] / includes / http / GuzzleHttpRequest.php
index e6b2892..4741ead 100644 (file)
@@ -41,11 +41,12 @@ class GuzzleHttpRequest extends MWHttpRequest {
 
        protected $handler = null;
        protected $sink = null;
+       /** @var array */
        protected $guzzleOptions = [ 'http_errors' => false ];
 
        /**
         * @param string $url Url to use. If protocol-relative, will be expanded to an http:// URL
-        * @param array $options (optional) extra params to pass (see Http::request())
+        * @param array $options (optional) extra params to pass (see HttpRequestFactory::create())
         * @param string $caller The method making this request, for profiling
         * @param Profiler|null $profiler An instance of the profiler for profiling, or null
         * @throws Exception
@@ -139,6 +140,10 @@ class GuzzleHttpRequest extends MWHttpRequest {
                                $this->guzzleOptions['form_params'] = $postData;
                        } else {
                                $this->guzzleOptions['body'] = $postData;
+                               // mimic CURLOPT_POST option
+                               if ( !isset( $this->reqHeaders['Content-Type'] ) ) {
+                                       $this->reqHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
+                               }
                        }
 
                        // Suppress 'Expect: 100-continue' header, as some servers