【问题标题】:use of HTTP Proxy using cURL in C在 C 中使用 cURL 使用 HTTP 代理
【发布时间】:2010-11-04 06:40:40
【问题描述】:

我正在研究这个在 c 中使用代理服务器和 curl 的项目,但我找不到一个很好的教程来教我如何做。你能帮我么??我需要一个示例代码来显示使用代理服务器连接到 google.com。也许使用 CURLOPT_PROXY 选项.. 提前致谢。

【问题讨论】:

    标签: c curl proxy


    【解决方案1】:

    您所做的只是您的normal curl 检索,但只需设置代理服务器选项。

       curl_easy_setopt(handle, CURLOPT_PROXY, "127.0.0.1:96666");
    

    编辑

      /* create headers */
      struct curl_slist *headers=NULL;
      headers = curl_slist_append(headers, "Content-Type: text/xml");
    
      /* pass our list of custom made headers */
      curl_easy_setopt(easyhandle, CURLOPT_HTTPHEADER, headers);
    

    【讨论】:

    • thanx.. 但是如果我需要在发送请求之前添加一些额外的 http 标头怎么办??
    猜你喜欢
    • 2016-10-31
    • 2012-08-01
    • 2010-12-11
    • 1970-01-01
    • 2021-04-09
    • 1970-01-01
    • 2017-12-12
    相关资源
    最近更新 更多