Movatterモバイル変換


[0]ホーム

URL:


everything curl

    curl easy options

    You set options in the easy handle to control how that transfer is going to bedone, or in some cases you can actually set options and modify the transfer'sbehavior while it is in progress. You set options withcurl_easy_setopt()and you provide the handle, the option you want to set and the argument to theoption. All options take exactly one argument and you must always pass exactlythree parameters to thecurl_easy_setopt() calls.

    Since thecurl_easy_setopt() call accepts several hundred different optionsand the various options accept a variety of different types of arguments, itis important to read up on the specifics and provide exactly the argumenttype the specific option supports and expects. Passing in the wrong type canlead to unexpected side-effects or hard to understand hiccups.

    The perhaps most important option that every transfer needs, is the URL.libcurl cannot perform a transfer without knowing which URL it concerns so youmust tell it. The URL option name isCURLOPT_URL as all options are prefixedwithCURLOPT_ and then the descriptive name — all using uppercaseletters. An example line setting the URL to get thehttp://example.com HTTPcontents could look like:

    CURLcode ret = curl_easy_setopt(easy, CURLOPT_URL, "http://example.com");

    Again: this only sets the option in the handle. It does not do the actualtransfer or anything. It just tells libcurl to copy the given string and ifthat works it returns OK.

    It is, of course, good form to check the return code to see that nothing wentwrong.

    Get options

    There is no way to extract the values previously set withcurl_easy_setopt(). If you need to be able to extract the information againthat you set earlier, we encourage you to keep track of that data yourself inyour application.


    [8]ページ先頭

    ©2009-2025 Movatter.jp