?
Referenced as Pull Request for: # 6561
avatar ghost
ghost
23 Mar 2015

Steps to reproduce the issue

  1. Create a JHttp object using JHttpFactory::getHttp().
  2. Try to make a PUT request: $http->put();
  3. The server you are trying to make a PUT request doesn't receive the data properly.

Expected result

The result expected is a 200 HTTP status code.

Actual result

400 HTTP status code because the server doesn't receive the data properly.

System information (as much as possible)

Apache Server installed on an Ubuntu machine using PHP v5.3.29

Additional comments

I have seen the code in the libraries folder of Joomla! CMS repository is quite different than the HTTP Package in Joomla Framework. The code in the HTTP package repository works fine. I suggest to update it in the next version because I'm not able to use the JHttp library because I cannot send a PUT request.

avatar victor-tech victor-tech - open - 23 Mar 2015
avatar victor-tech victor-tech - change - 23 Mar 2015
Labels Removed: ?
avatar brianteeman brianteeman - change - 23 Mar 2015
Labels Added: ?
avatar PhilETaylor
PhilETaylor - comment - 23 Mar 2015

I can confirm this as a bug.

Test REST PUT/POST endpoint of http://docs.myjoomla.io/debug/issue/6556 established for your testing purposes. The end point was independently tested with PostMan App to show working PUT request output, and then when tested with JHTTP it failed to return the data sent (http://screenshot.myjoomla.io/image/2O0K2P120c1D)

Furthermore the correct data is not received by the end point as it is never sent correctly by JHTTP
http://screenshot.myjoomla.io/image/1i3Y0J350N3B

Gist that documents/highlights/provides a test case for this is here:
https://gist.github.com/a4ee67f8f48d3674221d

avatar orware
orware - comment - 3 Apr 2015

Hi Phil,

Thanks for the extra details!

On my end it looks like if we remove these 3 lines (which causes PUT requests to be made using CURLOPT_CUSTOMREQUEST instead of CURLOPT_PUT) it seems to allow it to start working:
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/http/transport/curl.php#L77-L79


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6556.
avatar PhilETaylor
PhilETaylor - comment - 3 Apr 2015

please comment on #6561 as well and ensure you test the proposed pull request - The pull request will not be merged without people testing...

The reason I leave case 'PUT': in, is to stop up going through all this again when someone notices its not there, leaving it in, as part of the default block (allowed in PHP) allows us to know in the future that it has been thought about and not just forgot it...

avatar orware
orware - comment - 3 Apr 2015

Another option it appears would be to switch out the lines I mention above for the following:

case 'PUT':
    $headers['X-HTTP-Method-Override'] = 'PUT';
    break;

According to this comment:
http://php.net/manual/en/function.curl-setopt.php#109634


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6556.
avatar orware
orware - comment - 3 Apr 2015

It looks like the framework has opted for the first option I mentioned (using CURLOPT_CUSTOMREQUEST for all types: GET, POST, PUT, DELETE, etc.):
https://github.com/joomla/joomla-framework/blob/staging/src/Joomla/Http/Transport/Curl.php#L67-L68

So that might be the one to go with for consistency.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6556.
avatar PhilETaylor
PhilETaylor - comment - 3 Apr 2015

Which is exactly what the proposed pull request #6561 achieves

avatar orware
orware - comment - 3 Apr 2015

Thanks for the links to the other issue numbers Phil, it sounds like you came to the same conclusions already and had that PR ready in #6561.

I've confirmed that PR should fix what's mentioned in this issue.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6556.
avatar orware
orware - comment - 3 Apr 2015

@PhilETaylor (I apologize I wasn't checking my email when your initial reply had come in so I kept on digging and writing replies on on my end before I saw it).


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6556.
avatar brianteeman brianteeman - change - 8 May 2015
Status New Confirmed
avatar brianteeman
brianteeman - comment - 24 May 2015

closed as we have a PR #6561


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6556.

avatar brianteeman brianteeman - change - 24 May 2015
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2015-05-24 10:43:39
Closed_By brianteeman
avatar brianteeman brianteeman - change - 24 May 2015
Build 3.4.1 staging
avatar brianteeman brianteeman - close - 24 May 2015

Add a Comment

Login with GitHub to post a comment