help needed on libcurl programming in sending HTTP HEAD Request.

Posted by Mani on Stack Overflow See other posts from Stack Overflow or by Mani
Published on 2010-06-02T07:20:17Z Indexed on 2010/06/02 7:33 UTC
Read the original article Hit count: 258

Filed under:
|

Hi all,

I need clarifications on using libcurl for the following:

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

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();

The code shown above sends the HEAD Request in slightly different form (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 ?

© Stack Overflow or respective owner

Related posts about c

    Related posts about libcurl