【问题标题】:Prevent libcurl from sending FTP LIST command阻止 libcurl 发送 FTP LIST 命令
【发布时间】:2013-03-24 22:51:17
【问题描述】:

当连接到服务器并发送特定的 QUOTE 命令时,libcurl(7.29.0) 似乎正在请求目录列表,即使我不想要这个。 这是我得到的响应,表明在发送 MDTM 命令后 libcurl 发送了一个我不想要的 LIST 命令。如何防止它发送 LIST?

* Request has same path as previous transfer
> MDTM fileName
< 213 20130324223404
> EPSV
* Connect data stream passively
< 229 Entering Extended Passive Mode (|||x|)
*   Trying ip...
* Connecting to ip (ip) port x
> LIST
< 150 Here comes the directory listing.

curl 会话代码的一部分(我在这里重用了一个 curl 句柄,该句柄以前将远程目录更改为 fileName 所在的位置,并为其他目的获取目录列表):

    headers = NULL;
    headers = curl_slist_append(headers, "MDTM fileName");
    curl_easy_setopt(curlSession, CURLOPT_QUOTE, headers);       
    curl_easy_setopt(curlSession, CURLOPT_WRITEHEADER, &fileModResponse);
    res = curl_easy_perform(curlSession);

【问题讨论】:

    标签: libcurl


    【解决方案1】:

    我下载了 libcurl 源码并找到了答案。指定 CURLOPT_NOBODY 选项会阻止它发送 FTP LIST 命令。

    curl_easy_setopt(curlSession, CURLOPT_NOBODY, 1);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-12
      • 2015-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      相关资源
      最近更新 更多