WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 22 months ago

#24156 closed defect (bug)

If you submit file through wp curl it doesnt send boundary params for file mutlipart — at Version 1

Reported by: samnani Owned by:
Milestone: Priority: normal
Severity: major Version: 3.5.1
Component: HTTP API Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

If you submit file through wp curl it doesnt send boundary params for file multipart, because in class-http.php at line 174 $r['body'] array is converted to string:

$r['body'] = http_build_query( $r['body'], null, '&' );

And curl wants array to send file boundary to rest api , in that case it fails.
ex.

$headers['Content-type'] = 'multipart/form-data';   
$args['file'] = '@/pathtofile';
$request = new WP_Http;
$result = $request->request($url,$args);

Let me know if you have questions

Change History (1)

comment:1 @SergeyBiryukov2 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.