Allow passing postdata in Http::post() options...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 30 Jul 2009 22:11:44 +0000 (22:11 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 30 Jul 2009 22:11:44 +0000 (22:11 +0000)
Note -- CURL allows you to pass an array which it will encode as multipart, but this doesn't seem to work for me.
Until resolved, do URL form encoding yourself with wfArrayToCGI() and pass in a string.
Todo: implement also for non-CURL mode if possible?

includes/HttpFunctions.php

index e4b73f9..338f1e0 100644 (file)
@@ -287,6 +287,7 @@ class HttpRequest {
                $this->upload_session_key = ( isset( $opt['upload_session_key'] ) ) ? $opt['upload_session_key'] : false;
                $this->headers_only = ( isset( $opt['headers_only'] ) ) ? $opt['headers_only'] : false;
                $this->do_close_session_update = isset( $opt['do_close_session_update'] );
+               $this->postData = isset( $opt['postdata'] ) ? $opt['postdata'] : '';
        }
 
        /**
@@ -331,7 +332,7 @@ class HttpRequest {
                        curl_setopt( $c, CURLOPT_HEADER, true );
                } elseif ( $this->method == 'POST' ) {
                        curl_setopt( $c, CURLOPT_POST, true );
-                       curl_setopt( $c, CURLOPT_POSTFIELDS, '' );
+                       curl_setopt( $c, CURLOPT_POSTFIELDS, $this->postData );
                } else {
                        curl_setopt( $c, CURLOPT_CUSTOMREQUEST, $this->method );
                }