PATCH method with cocos2d::network::HttpRequest

Hi all,

How can I use PATCH method same as https://www.youtube.com/watch?v=duG6y17CEMw&t=6m44s with cocos2d::network::HttpRequest ?

In cocos2d::network::HttpRequest::Type , I cannot find PATCH method !

Thanks ,

Hmm… my options:

  • Edit HttpRequest class (or talk with cocos developers for add in future versions).
  • Use another library (libcurl for example).
  • Use PUT instead of PATCH (I know it’s similar but it’s not the same).

Anyway, be careful if you want to use PUT, PATCH, etc. because some servers don’t support it for security. In my case, I simulated a PUT with a POST for this problem.

Hope it helps.

Hi @tranthor

If you have 1GB data on server :cry: , How to use PUT instead PATH method ?
I think it is not a good solution.
With curl soultion ,It’s same as HttpRequest , I cannot find HTTP PATCH method in curl.h

Can you give me another soultion ?
Thanks

Again, try with curl :stuck_out_tongue:
I didn’t test it, but you can instruct libcurl to use a specific method you like with CURLOPT_CUSTOMREQUEST.

https://ec.haxx.se/libcurl-http-requests.html

For example:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PATCH");

Otherwise, you could search other libraries, for example:

But i recommend you to try cURL, it’s the most popular.
Also, if you’re developing in c++, you could try with curlpp, it’s a c++ wrapper around libcURL.

1 Like

hi @tranthor

I think I found a solution , I will let you know if it works !

thanks you very much ! :+1: :+1: :+1: