Bug Report #4641

Request external PUT does not work (CURL)

Added by dexcell - almost 2 years ago. Updated over 1 year ago.

Status:ClosedStart date:10/31/2012
Priority:NormalDue date:
Assignee:Jeremy Bush% Done:

0%

Category:Core
Target version:3.3.1
Resolution:fixed Points:1

Description

From:
http://forum.kohanaframework.org/discussion/11214/request-external-put-does-not-work-curl-kohana-3-2-2

Hi guys, i wonder if you have same problem.

Here is the request part

Request::factory('http://api.example.com/item/17')
    ->method(HTTP_Request::PUT)
    ->post(array(
        'hello' => 'world',
    ))
    ->execute();

I also tried example from : http://kohanaframework.org/3.2/guide/kohana/requests#external-requests

Receive part (the API):

echo $this->request->body();

But it does not show anything.

After some googling, i found out the problem is because we are using CURLOPT_PUT http://stackoverflow.com/questions/2081894/handling-put-delete-arguments-in-php

So, if we comment some part in Kohana_Request_Client_Curl like code below:

public function _set_curl_request_method(Request $request, array $options)
{
    switch ($request->method()) {
        case Request::POST:
            $options[CURLOPT_POST] = TRUE;
            break;
//          case Request::PUT:
//              $options[CURLOPT_PUT] = TRUE;
//              break;
        default:
            $options[CURLOPT_CUSTOMREQUEST] = $request->method();
            break;
    }
    return $options;
}

It works.

Thank you

Associated revisions

Revision 5abef4f1
Added by Alex Mayhew over 1 year ago

Fixing #4641: Curl PUT request does not post request body

Revision 5a103a18
Added by Jeremy Bush over 1 year ago

Merge pull request #334 from acidtv/3.3/develop

Fixing #4641: Curl PUT request does not post request body

History

#1 Updated by Sergio Zia over 1 year ago

I encounter exactly the same bug !
Is it possible to increase this bug priority ?

#2 Updated by Scott Jungwirth over 1 year ago

Yes, I had the same issue, took a while to debug. Major problem for integrating with RESTful APIs.

#3 Updated by Jeremy Bush over 1 year ago

  • Category set to Core
  • Status changed from New to Closed
  • Assignee set to Jeremy Bush
  • Target version changed from v3.2.3 to 3.3.1
  • Resolution set to fixed

Also available in: Atom PDF