summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Knauf <lists@gknw.net>2013-06-20 22:53:37 +0200
committerGuenter Knauf <lists@gknw.net>2013-06-20 22:53:37 +0200
commitda0db499fd1fed3ab061d8c03d25c06164c9f429 (patch)
tree27ae15f01343d459085d9bad4b174ca3c4b13394
parent88c5c63ffc3312a8c8471b48a44ec5f50420f2e3 (diff)
downloadgnurl-da0db499fd1fed3ab061d8c03d25c06164c9f429.tar.gz
gnurl-da0db499fd1fed3ab061d8c03d25c06164c9f429.tar.bz2
gnurl-da0db499fd1fed3ab061d8c03d25c06164c9f429.zip
Use opened body.out file and write content to it.
-rw-r--r--docs/examples/sepheaders.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/docs/examples/sepheaders.c b/docs/examples/sepheaders.c
index afa14fc85..d944ab99d 100644
--- a/docs/examples/sepheaders.c
+++ b/docs/examples/sepheaders.c
@@ -54,23 +54,22 @@ int main(void)
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
/* open the files */
- headerfile = fopen(headerfilename,"w");
+ headerfile = fopen(headerfilename,"wb");
if (headerfile == NULL) {
curl_easy_cleanup(curl_handle);
return -1;
}
- bodyfile = fopen(bodyfilename,"w");
+ bodyfile = fopen(bodyfilename,"wb");
if (bodyfile == NULL) {
curl_easy_cleanup(curl_handle);
return -1;
}
- /* we want the headers to this file handle */
+ /* we want the headers be written to this file handle */
curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, headerfile);
- /*
- * Notice here that if you want the actual data sent anywhere else but
- * stdout, you should consider using the CURLOPT_WRITEDATA option. */
+ /* we want the body be written to this file handle instead of stdout */
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, bodyfile);
/* get it! */
curl_easy_perform(curl_handle);
@@ -78,6 +77,9 @@ int main(void)
/* close the header file */
fclose(headerfile);
+ /* close the body file */
+ fclose(bodyfile);
+
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);