How to set CURL options when using Kohana Request

假装没事ソ 提交于 2020-04-13 11:03:12

问题


Trying to use the Request class to get an external resources, but can't figure out how to set more default curl options.

I get the data like this:

$data = Request::factory($url)->execute()->body();

I figured adding CURL options was a simple matter of making a copy of system/config/curl.php into my application config folder and then setting the options there (I assume they will be merged?).

But those options don't seem to be used at all? Tried to do a var_dump in Kohana_Request_Client_Curl after all the options should've been set, but I can only find the ones set directly there in that method, which makes sense as I can't seem to find anywhere these options are actually fetched from the config file...

What am I doing wrong here?


回答1:


Here is more detailed example:

$request = Request::factory($some_url);

$request->client()->options(array(
    CURLOPT_SSL_VERIFYPEER => FALSE
));



回答2:


The Request_Curl class doesn't look at that config file. You'll have to use ->options() manually to set the curl params.



来源:https://stackoverflow.com/questions/10774976/how-to-set-curl-options-when-using-kohana-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!