• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Error

            C++博客 首頁 新隨筆 聯系 聚合 管理
              217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks

            官方文檔:

            FTP Custom Commands

            Not all protocols are HTTP-like, and thus the above may not help you when you want to make, for example, your FTP transfers to behave differently.

            Sending custom commands to a FTP server means that you need to send the commands exactly as the FTP server expects them (RFC 959 is a good guide here), and you can only use commands that work on the control-connection alone. All kinds of commands that require data interchange and thus need a data-connection must be left to libcurl's own judgement. Also be aware that libcurl will do its very best to change directory to the target directory before doing any transfer, so if you change directory (with CWD or similar) you might confuse libcurl and then it might not attempt to transfer the file in the correct remote directory.

            A little example that deletes a given file before an operation:

            headers = curl_slist_append(headers, "DELE file-to-remove");

            /* pass the list of custom commands to the handle */  curl_easy_setopt(easyhandle, CURLOPT_QUOTE, headers);

            curl_easy_perform(easyhandle); /* transfer ftp data! */

            curl_slist_free_all(headers); /* free the header list */

            If you would instead want this operation (or chain of operations) to happen _after_ the data transfer took place the option to curl_easy_setopt(3) would instead be called CURLOPT_POSTQUOTE and used the exact same way.

            The custom FTP command will be issued to the server in the same order they are added to the list, and if a command gets an error code returned back from the server, no more commands will be issued and libcurl will bail out with an error code (CURLE_QUOTE_ERROR). Note that if you use CURLOPT_QUOTE to send commands before a transfer, no transfer will actually take place when a quote command has failed.

            If you set the CURLOPT_HEADER to 1, you will tell libcurl to get information about the target file and output "headers" about it. The headers will be in "HTTP-style", looking like they do in HTTP.

            The option to enable headers or to run custom FTP commands may be useful to combine with CURLOPT_NOBODY. If this option is set, no actual file content transfer will be performed.

            FTP Custom CUSTOMREQUEST

            If you do want to list the contents of a FTP directory using your own defined FTP command, CURLOPT_CUSTOMREQUEST will do just that. "NLST" is the default one for listing directories but you're free to pass in your idea of a good alternative.

             

            中文:

            FTP自定義命令

            并不是所以的協議都像HTTP那樣,通過消息頭來告訴服務器如何處理請求。對于FTP,你就要使用另外的方式來處理。

            發送自定義的命令到ftp服務器,意味著你發送的命令必須是能被ftp服務器理解的命令(FTP協議中定義的命令,參考rfc959)。

            下面是一個簡單的例子,在文件傳輸操作操作之前刪除指定文件:

            headers = curl_slist_append(headers, "DELE file-to-remove"); /* pass the list of custom commands to the handle */ curl_easy_setopt(easyhandle, CURLOPT_QUOTE, headers); //curl_easy_setopt(easyhandle, CURLOPT_POSTQUOTE, headers); // 在數據傳輸之后操行刪除操作
            curl_easy_perform(easyhandle); /* transfer ftp data! */ curl_slist_free_all(headers); /* free the header list */

            FTP服務器執行命令的順序,同這些命令被添加到列表中順序是一致的。發往服務器的命令列表中,只要有一個命令執行失敗,ftp服務器就會返回一個錯誤代碼,此時libcurl將直接返回CURLE_QUOTE_ERROR,不再執行剩余的FTP命令。

            將CURLOPT_HEADER設置為1,libcurl獲取目標文件的信息,并以HTTP消息頭的樣式來輸出消息頭。

            FTP自定義CUSTOMREQUEST

            使用CURLOPT_CUSTOMREQUEST屬性,可以向FTP服務器發送命令。”NLST”是ftp默認的列出文件列表的命令。 下面的代碼用于列出FTP服務器上的文件列表:

            int main(int argc, char **argv) { curl_global_init(CURL_GLOBAL_WIN32); CURL *easy_handle = curl_easy_init(); curl_easy_setopt(easy_handle, CURLOPT_URL, "ftp://127.0.0.1/");curl_easy_setopt(easy_handle, CURLOPT_CUSTOMREQUEST, "NLST");
            curl_easy_perform(easy_handle); curl_easy_cleanup(easy_handle); curl_global_cleanup(); return 0; }
            posted on 2012-06-29 00:14 Enic 閱讀(595) 評論(0)  編輯 收藏 引用
            狠狠色丁香久久婷婷综合_中| 久久99亚洲网美利坚合众国| 国内精品久久久久久久coent| 精品综合久久久久久88小说| 欧美激情精品久久久久久久| 亚洲欧美成人综合久久久| 好久久免费视频高清| 久久综合视频网站| 777米奇久久最新地址| 久久精品?ⅴ无码中文字幕| 2021国内精品久久久久久影院| 久久精品亚洲日本波多野结衣| 久久精品一区二区影院 | 亚洲欧洲中文日韩久久AV乱码| 天天影视色香欲综合久久| 国产一区二区三区久久| 久久亚洲AV成人无码软件| 亚洲一区中文字幕久久| 九九精品99久久久香蕉| 久久久久亚洲精品日久生情 | 久久久中文字幕| av色综合久久天堂av色综合在| 精品久久久久久无码中文字幕| 久久夜色精品国产网站| 青青草原综合久久大伊人导航| 久久狠狠色狠狠色综合| 99久久99久久久精品齐齐| 97精品依人久久久大香线蕉97| 久久免费国产精品| 人妻精品久久久久中文字幕| 伊人色综合久久| 国产一区二区精品久久凹凸| 国产精品久久久久久影院| 精品久久久噜噜噜久久久| 影音先锋女人AV鲁色资源网久久| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区| 久久天天躁狠狠躁夜夜avapp| 99久久国产亚洲综合精品| 久久综合亚洲鲁鲁五月天| 人人妻久久人人澡人人爽人人精品| 日本久久久久久久久久|