Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.4

Doc Bug #14635 Data is not allowed in PUT requests.
Submitted: 2008-09-10 11:21 UTC
From: anderslemke Assigned: avb
Status: Closed Package: HTTP_Request (version 1.4.3)
PHP Version: 5.2.6 OS: Mac OS
Roadmaps: 1.4.4    

 [2008-09-10 11:21 UTC] anderslemke (Anders Lemke)
Description: ------------ When creating a HTTP request with method PUT, it is not possible to add any data to the body. Test script: --------------- $fileName = "testFile2.txt"; $fileHandle = fopen($fileName, 'w') or die("can't open file"); $stringData = "Testfilsdfasdfsdaen"; fwrite($fileHandle, $stringData); fclose($fileHandle); $request = new HTTP_Request(); $request->setURL("".$fileName); if($request->addFile("test-file", $fileName)){ $request->setMethod("PUT"); $request->sendRequest(); } Expected result: ---------------- A PUT request should be sent to with the contents of the file created. Actual result: -------------- The body of the request gets removed, because the method is not POST.


 [2008-09-10 11:31 UTC] avb (Alexey Borzov)
addFile() is only useful for POST requests, for PUT you should simply add your $stringData via setBody(). Anyway, this could be documented better.
 [2008-09-10 11:42 UTC] anderslemke (Anders Lemke)
Ah ok... But why is it that the functionality provided by addFile is restricted to POST requests?
 [2008-09-10 16:27 UTC] avb (Alexey Borzov)
Probably because adding data to PUT request is trivial, while generating a multipart/form-data request body for POST is not.
 [2008-10-10 16:38 UTC] avb (Alexey Borzov)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.