| |
|
|
|
cURL Mailing List Monthly Index Single Mail
curl-library Mailing List Archives
Re: Help - retriveal of header & body info
From: Arunachalam, Sasikanth <Sasikanth.Arunachalam_at_geometricglobal.com>
Date: Mon, 4 Jan 2010 12:12:22 +0530
Hi,
CURL *curl_handle;
static const char *headerfilename = "head.out";
FILE *headerfile;
static const char *bodyfilename = "body.out";
FILE *bodyfile;
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
CURLcode retCode = CURLE_OK ;
const char *pErrMsg = NULL;
/* Setting Proxy*/
retCode = curl_easy_setopt(curl_handle, CURLOPT_PROXY, "");
/* set URL to get */
retcode = curl_easy_setopt(curl_handle, CURLOPT_URL,
/* no progress meter please */
retCode = curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
//headerfile = fopen(headerfilename,"w");
headerfile = fopen("/homes/head.out","w");
if (headerfile == NULL)
{
curl_easy_cleanup(curl_handle);
return -1;
}
bodyfile = fopen("/homes/ body.out","w");
if (bodyfile == NULL)
{
curl_easy_cleanup(curl_handle);
return -1; }
/* we want the headers to this file handle */
retCode = curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER,
retCode = curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA,
/* get it! */
retCode = curl_easy_perform(curl_handle);
/* close the header file */
fclose(headerfile);
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
Still I am not getting the information in body.out file.
I could see that the stream is getting retrieved inside write_data
size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) {
Please let me know if you can give me some inputs why this information
Br
Message: 1
Hi,
I am using libcurl version 7.19.7 . I have tried the following
CURL *curl_handle;
static const char *headerfilename = "head.out";
FILE *headerfile;
static const char *bodyfilename = "body.out";
FILE *bodyfile;
curl_global_init(CURL_GLOBAL_ALL);
/* init the curl session */
curl_handle = curl_easy_init();
CURLcode retCode = CURLE_OK ;
const char *pErrMsg = NULL;
/* Setting Proxy*/
retCode = curl_easy_setopt(curl_handle, CURLOPT_PROXY, "");
pErrMsg = curl_easy_strerror(retCode);
/* set URL to get */
retcode = curl_easy_setopt(curl_handle, CURLOPT_URL,
pErrMsg = curl_easy_strerror(retCode);
/* no progress meter please */
retCode = curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
pErrMsg = curl_easy_strerror(retCode);
/* send all data to this function */
retCode =curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION,
pErrMsg = curl_easy_strerror(retCode);
/* open the files */
//headerfile = fopen(headerfilename,"w");
headerfile = fopen("/homes/head.out","w");
if (headerfile == NULL)
{
curl_easy_cleanup(curl_handle);
return -1;
}
bodyfile = fopen("/homes/ body.out","w");
if (bodyfile == NULL)
{
curl_easy_cleanup(curl_handle);
return -1; }
/* we want the headers to this file handle */
retCode = curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER,
pErrMsg = curl_easy_strerror(retCode);
/*
* Notice here that if you want the actual data sent anywhere else
* stdout, you should consider using the CURLOPT_WRITEDATA option.
retCode = curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA,
pErrMsg = curl_easy_strerror(retCode);
/* get it! */
retCode = curl_easy_perform(curl_handle);
pErrMsg = curl_easy_strerror(retCode);
/* close the header file */
fclose(headerfile);
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
I am not able to retrieve the header & body information using the above
I got the content of head.out as
HTTP/1.1 200 OK
content-language: en-US
content-type: text/html;charset=ISO-8859-1
date: Thu, 31 Dec 2009 11:27:15 GMT
p3p: CP="NON CUR OTPi OUR NOR UNI"
server: IBM_HTTP_Server
x-old-content-length: 1041
transfer-encoding: chunked
cache-control: no-cache
pragma: no-cache
expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: AMWEBJCT!%2FAppl!JSESSIONID=0000XIgzYlq7yx3qKdAUaCxtfWN:-1;
Set-Cookie: PD_STATEFUL_a705f792-72e2-11db-b0e3-000629c30555=%2FAppl;
& the empty information in body.out file.
On the other hand, I have performed the same operation in Windows with
Request you to please let me know whether I need to set any specific
Br
Sasikanth
-------------- next part --------------
------------------------------
Message: 2
Hi,
> ????? retCode =curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION,
You are overriding the default write function here.
> I am not able to retrieve the header & body information using the
[snipped the header information]
> & the? empty information in body.out file.
Do you get something in body.out if you remove the above line in your
Best regards,
------------------------------
_______________________________________________
End of curl-library Digest, Vol 52, Issue 59
These mail archives are generated by hypermail. |
Page updated November 12, 2010.
web site info