cURL / Mailing Lists / curl-library / Single Mail

curl-library

followlocation/header/file

From: jonatan <jonatan_at_cyberdude.com>
Date: Fri, 31 Aug 2001 18:30:19 +0200

some pseudo-code:

   curl_global_init( CURL_GLOBAL_ALL );
   curl = curl_easy_init();
   curl_easy_setopt( curl, CURLOPT_FOLLOWLOCATION, 1 );
   curl_easy_setopt( curl, CURLOPT_HEADER, 1 );
   curl_easy_setopt( curl, CURLOPT_FILE, fopen( "out", "w" ) );
   curl_easy_setopt( curl, CURLOPT_URL, "http://curl.haxx.se/libcurl" );
   curl_easy_perform( curl );
   curl_easy_cleanup( curl );
   curl_global_cleanup();

"http://curl.haxx.se/libcurl" will redirect to "http://curl.haxx.se/libcurl/".

the file "out" will contain both http response headers:

   HTTP/1.1 301 Moved Permanently
   Date: Fri, 31 Aug 2001 16:05:27 GMT
   Server: Apache/1.3.17 (Unix) PHP/4.0.4pl1
   Location: http://curl.haxx.se/libcurl/
   Transfer-Encoding: chunked
   Content-Type: text/html; charset=iso-8859-1

   HTTP/1.1 200 OK
   Date: Fri, 31 Aug 2001 16:05:27 GMT
   Server: Apache/1.3.17 (Unix) PHP/4.0.4pl1
   Last-Modified: Thu, 16 Aug 2001 13:00:07 GMT
   ETag: "e3c2d-144f-3b7bc3d7"
   Accept-Ranges: bytes
   Content-Length: 5199
   Content-Type: text/html; charset=iso-8859-1

   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
   [snip]

is this the correct behavior? shouldn't the file start from the last
http header? i'm using 7.8.1.

---
btw, the docs/examples/*.c files seem to lack curl_global_*() calls.
Received on 2001-09-01