没有自动Proxy-Connection标头的libcurl HTTP HEAD请求 [英] libcurl HTTP HEAD request without automatic Proxy-Connection header
本文介绍了没有自动Proxy-Connection标头的libcurl HTTP HEAD请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在以下方面使用libcurl进行澄清:
I need clarifications on using libcurl for the following:
我需要发送如下所示的http HEAD请求::
I need to send an http HEAD request shown as below ::
HEAD /mshare/3/30002:12:primary/stream_xNKNVH.mpeg HTTP/1.1
Host: 192.168.70.1:8080
Accept: */*
User-Agent: Kreatel_IP-STB
getcontentFeatures.dlna.org: 1
我编写的代码(如下所示)以略有不同的方式发送HEAD请求:
The code I wrote (shown below) , sends the HEAD Request in slightly different way:
curl_global_init(CURL_GLOBAL_ALL);
CURL* ctx = NULL;
const char *url = "http://192.168.70.1:8080/mshare/3/30002:12:primary/stream_xNKNVH.mpeg" ;
char *returnString;
struct curl_slist *headers = NULL;
ctx = curl_easy_init();
headers = curl_slist_append(headers,"Accept: */*");
headers = curl_slist_append(headers,"User-Agent: Kreatel_IP-STB");\
headers = curl_slist_append(headers,"getcontentFeatures.dlna.org: 1");
headers = curl_slist_append(headers,"Pragma:");
headers = curl_slist_append(headers,"Proxy-Connection:");
curl_easy_setopt(ctx,CURLOPT_HTTPHEADER , headers );
curl_easy_setopt(ctx,CURLOPT_NOBODY ,1 );
curl_easy_setopt(ctx,CURLOPT_VERBOSE, 1);
curl_easy_setopt(ctx,CURLOPT_URL,url );
curl_easy_setopt(ctx,CURLOPT_NOPROGRESS ,1 );
curl_easy_perform(ctx);
curl_easy_cleanup(ctx);
curl_global_cleanup();
上面显示的代码以略有不同的形式发送HEAD请求,并添加了Proxy-Connection
标头(如下所示)
The code shown above sends the HEAD Request in slightly different form, adding a Proxy-Connection
header (shown below)
HEAD http://192.168.70.1:8080/mshare/3/30002:12:primary/stream_xNKNVH.mpeg HTTP/1.1
Host: 192.168.70.1:8080
Proxy-Connection: Keep-Alive
Accept: */*
User-Agent: Kreatel_IP-STB
getcontentFeatures.dlna.org: 1
任何人都可以共享适当的代码吗?
Can any one , share the appropriate code ?
推荐答案
如果您不想使用http_proxy环境,请按如下所示的空值调用函数.
if you don't want to use http_proxy envirionment, call function by empty value like below.
curl_easy_setopt(curl, CURLOPT_PROXY, "");
这篇关于没有自动Proxy-Connection标头的libcurl HTTP HEAD请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文