Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CURLOPT_CUSTOMREQUEST for get/post function #85

Merged
merged 1 commit into from
Aug 29, 2022

Conversation

mean-cj
Copy link
Contributor

@mean-cj mean-cj commented May 18, 2022

No description provided.

@nadar
Copy link
Member

nadar commented Jul 29, 2022

Hi @mean-cj

Whats to benefit of introducing this? What does it change? Could you please elaborate?

@mean-cj
Copy link
Contributor Author

mean-cj commented Jul 29, 2022

Hi nada

When we need to call $curl->get() after $curl->post() ,
curl option "CURLOPT_CUSTOMREQUEST" doesn't work because curl option remember CURLOPT_CUSTOMREQUEST = POST

fixed
add $this->setOpt(CURLOPT_CUSTOMREQUEST, "GET"); into the get method.

@nadar nadar requested review from nadar and amouhzi July 29, 2022 09:21
Copy link
Member

@nadar nadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then you should create two objects any how. That old code design of this project is somewhat outdated and the response should be immutable or stored in separate object, but its not. So i would recommend:

$get = (new Curl())->get(...)
$post = (new Curl())->post(...)

But since we set customrequest also for put, patch, delete, this looks good to me.

@nadar
Copy link
Member

nadar commented Aug 29, 2022

When you change the request method by setting CURLOPT_CUSTOMREQUEST to something, you do not actually change how libcurl behaves or acts in regards to the particular request method, it will only change the actual string sent in the request.

@nadar nadar merged commit 7e506d8 into php-mod:master Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants