• <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++博客 首頁 新隨筆 聯(lián)系 聚合 管理
              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自定義命令

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

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

            下面是一個(gè)簡(jiǎn)單的例子,在文件傳輸操作操作之前刪除指定文件:

            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); // 在數(shù)據(jù)傳輸之后操行刪除操作
            curl_easy_perform(easyhandle); /* transfer ftp data! */ curl_slist_free_all(headers); /* free the header list */

            FTP服務(wù)器執(zhí)行命令的順序,同這些命令被添加到列表中順序是一致的。發(fā)往服務(wù)器的命令列表中,只要有一個(gè)命令執(zhí)行失敗,ftp服務(wù)器就會(huì)返回一個(gè)錯(cuò)誤代碼,此時(shí)libcurl將直接返回CURLE_QUOTE_ERROR,不再執(zhí)行剩余的FTP命令。

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

            FTP自定義CUSTOMREQUEST

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

            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 閱讀(594) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            91精品国产91久久久久福利 | 久久人人爽人人爽人人片AV不 | 欧美黑人又粗又大久久久 | 久久不见久久见免费影院www日本| 国产精品日韩欧美久久综合| 久久人妻少妇嫩草AV无码蜜桃| 亚洲国产成人精品久久久国产成人一区二区三区综 | 国内精品久久久久影院优| 91精品久久久久久无码| 人妻无码精品久久亚瑟影视| 久久精品夜夜夜夜夜久久| 精品人妻伦一二三区久久| 无码国内精品久久人妻| 国产精品免费看久久久香蕉| 一本久道久久综合狠狠爱| 国产精品综合久久第一页| 无码久久精品国产亚洲Av影片| 97久久精品人人澡人人爽| 久久综合给久久狠狠97色| 看全色黄大色大片免费久久久| 国内精品久久久久影院优| 久久久久久久女国产乱让韩| 久久久WWW成人免费精品| 久久久久高潮毛片免费全部播放| 无码精品久久一区二区三区| 国产亚州精品女人久久久久久| 久久精品免费观看| 久久夜色精品国产网站| 久久夜色精品国产亚洲| 中文成人无码精品久久久不卡 | 综合久久一区二区三区| 久久黄视频| 91久久福利国产成人精品| 97久久国产亚洲精品超碰热| 久久精品亚洲一区二区三区浴池| 99久久这里只精品国产免费 | 99久久99久久| 久久亚洲精品中文字幕| 久久香蕉超碰97国产精品| 国产精品久久久久久久久| 久久精品午夜一区二区福利|