ZF-4236: POST field order not fully preserved when uploading files
When you add both regular POST fields and file uploads in an HTTP request, the file uploads are always be sent after the regular fields, even if they were added before them the regular fields.
For example, if you have the following code:
$httpClient->setParameterPost('fieldA', 'valueA'); $httpClient->setFileUpload('filename.txt', 'fieldB', 'file contents', 'text/plain'); $httpClient->setParameterPost('fieldC', 'valueC');
Zend_Http_Client will reorder them as fieldA, fieldC, and fieldB when it sends it to the web server. I'm working with using Zend_Http_Client against a web application that is sensitive about the ordering of fields, and Zend_Http_Client's current behavior breaks this application.
I am attaching a patch that fixes this problem by preserving the order in which regular and file upload fields are added to Zend_Http_Client. With this patch, the field order for the previous example would be fieldA, fieldB, and fieldC.